[formats] Change item to associative array

Previously the item class was used to dump literaly any data
into an object. The same can be archived by using an array
with named keys (associative array).

Technically it makes more sense to use an array as we want to
be able to store any parameter into our item.
This commit is contained in:
logmanoriginal 2016-08-22 18:54:36 +02:00
parent 6fd0bdd21e
commit 1f3361c6b4
3 changed files with 15 additions and 15 deletions

View file

@ -23,11 +23,11 @@ class AtomFormat extends FormatAbstract{
$entries = '';
foreach($this->getDatas() as $data){
$entryAuthor = is_null($data->author) ? '' : $this->xml_encode($data->author);
$entryTitle = is_null($data->title) ? '' : $this->xml_encode($data->title);
$entryUri = is_null($data->uri) ? '' : $this->xml_encode($data->uri);
$entryTimestamp = is_null($data->timestamp) ? '' : $this->xml_encode(date(DATE_ATOM, $data->timestamp));
$entryContent = is_null($data->content) ? '' : $this->xml_encode($this->sanitizeHtml($data->content));
$entryAuthor = is_null($data['author']) ? '' : $this->xml_encode($data['author']);
$entryTitle = is_null($data['title']) ? '' : $this->xml_encode($data['title']);
$entryUri = is_null($data['uri']) ? '' : $this->xml_encode($data['uri']);
$entryTimestamp = is_null($data['timestamp']) ? '' : $this->xml_encode(date(DATE_ATOM, $data['timestamp']));
$entryContent = is_null($data['content']) ? '' : $this->xml_encode($this->sanitizeHtml($data['content']));
$entries .= <<<EOD
<entry>

View file

@ -17,11 +17,11 @@ class HtmlFormat extends FormatAbstract{
$entries = '';
foreach($this->getDatas() as $data){
$entryAuthor = is_null($data->author) ? '' : '<br /><p class="author">by: ' . $data->author . '</p>';
$entryTitle = is_null($data->title) ? '' : $this->sanitizeHtml(strip_tags($data->title));
$entryUri = is_null($data->uri) ? $uri : $data->uri;
$entryTimestamp = is_null($data->timestamp) ? '' : '<time datetime="' . date(DATE_ATOM, $data->timestamp) . '">' . date(DATE_ATOM, $data->timestamp) . '</time>';
$entryContent = is_null($data->content) ? '' : '<div class="content">' . $this->sanitizeHtml($data->content). '</div>';
$entryAuthor = isset($data['author']) ? '<br /><p class="author">by: ' . $data['author'] . '</p>' : '';
$entryTitle = isset($data['title']) ? $this->sanitizeHtml(strip_tags($data['title'])) : '';
$entryUri = isset($data['uri']) ? $data['uri'] : $uri;
$entryTimestamp = isset($data['timestamp']) ? '<time datetime="' . date(DATE_ATOM, $data['timestamp']) . '">' . date(DATE_ATOM, $data['timestamp']) . '</time>' : '';
$entryContent = isset($data['content']) ? '<div class="content">' . $this->sanitizeHtml($data['content']). '</div>' : '';
$entries .= <<<EOD
<section class="feeditem">

View file

@ -21,11 +21,11 @@ class MrssFormat extends FormatAbstract{
$items = '';
foreach($this->getDatas() as $data){
$itemAuthor = is_null($data->author) ? '' : $this->xml_encode($data->author);
$itemTitle = strip_tags(is_null($data->title) ? '' : $this->xml_encode($data->title));
$itemUri = is_null($data->uri) ? '' : $this->xml_encode($data->uri);
$itemTimestamp = is_null($data->timestamp) ? '' : $this->xml_encode(date(DATE_RFC2822, $data->timestamp));
$itemContent = is_null($data->content) ? '' : $this->xml_encode($this->sanitizeHtml($data->content));
$itemAuthor = is_null($data['author']) ? '' : $this->xml_encode($data['author']);
$itemTitle = strip_tags(is_null($data['title']) ? '' : $this->xml_encode($data['title']));
$itemUri = is_null($data['uri']) ? '' : $this->xml_encode($data['uri']);
$itemTimestamp = is_null($data['timestamp']) ? '' : $this->xml_encode(date(DATE_RFC2822, $data['timestamp']));
$itemContent = is_null($data['content']) ? '' : $this->xml_encode($this->sanitizeHtml($data['content']));
$items .= <<<EOD
<item>