Implemented feed item categories (#746)

This commit is contained in:
Eugene Molotov 2018-07-16 15:32:24 +05:00 committed by Teromene
parent 3f41d0593a
commit 049ee52fb5
4 changed files with 40 additions and 1 deletions

View file

@ -40,6 +40,16 @@ class AtomFormat extends FormatAbstract{
} }
} }
$entryCategories = '';
if(isset($item['categories'])) {
foreach($item['categories'] as $category) {
$entryCategories .= '<category term="'
. $this->xml_encode($category)
. '"/>'
. PHP_EOL;
}
}
$entries .= <<<EOD $entries .= <<<EOD
<entry> <entry>
@ -52,6 +62,7 @@ class AtomFormat extends FormatAbstract{
<updated>{$entryTimestamp}</updated> <updated>{$entryTimestamp}</updated>
<content type="html">{$entryContent}</content> <content type="html">{$entryContent}</content>
{$entryEnclosures} {$entryEnclosures}
{$entryCategories}
</entry> </entry>
EOD; EOD;

View file

@ -47,6 +47,20 @@ class HtmlFormat extends FormatAbstract {
$entryEnclosures .= '</div>'; $entryEnclosures .= '</div>';
} }
$entryCategories = '';
if(isset($item['categories'])) {
$entryCategories = '<div class="categories"><p>Categories:</p>';
foreach($item['categories'] as $category) {
$entryCategories .= '<li class="category">'
. $this->sanitizeHtml($category)
. '</li>';
}
$entryCategories .= '</div>';
}
$entries .= <<<EOD $entries .= <<<EOD
<section class="feeditem"> <section class="feeditem">
@ -55,6 +69,7 @@ class HtmlFormat extends FormatAbstract {
{$entryAuthor} {$entryAuthor}
{$entryContent} {$entryContent}
{$entryEnclosures} {$entryEnclosures}
{$entryCategories}
</section> </section>
EOD; EOD;

View file

@ -51,6 +51,16 @@ Some media files might not be shown to you. Consider using the ATOM format inste
} }
} }
$entryCategories = '';
if(isset($item['categories'])) {
foreach($item['categories'] as $category) {
$entryCategories .= '<category>'
. $category . '</category>'
. PHP_EOL;
}
}
$items .= <<<EOD $items .= <<<EOD
<item> <item>
@ -61,6 +71,7 @@ Some media files might not be shown to you. Consider using the ATOM format inste
<description>{$itemContent}{$entryEnclosuresWarning}</description> <description>{$itemContent}{$entryEnclosuresWarning}</description>
<author>{$itemAuthor}</author> <author>{$itemAuthor}</author>
{$entryEnclosures} {$entryEnclosures}
{$entryCategories}
</item> </item>
EOD; EOD;

View file

@ -69,12 +69,14 @@ a.backlink, a.backlink:link, a.backlink:visited, a.itemtitle, a.itemtitle:link,
} }
section > div.content, section > div.categories,
section > div.content, section > div.attachments { section > div.content, section > div.attachments {
padding: 10px; padding: 10px;
} }
section > div.categories > li.category,
section > div.attachments > li.enclosure { section > div.attachments > li.enclosure {
list-style-type: circle; list-style-type: circle;
@ -114,4 +116,4 @@ img {
max-width: 100%; max-width: 100%;
} }