1
0
Fork 0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2024-12-21 11:57:27 +03:00
rss-bridge/formats/HtmlFormat.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.3 KiB
PHP
Raw Normal View History

2013-08-11 15:30:41 +04:00
<?php
class HtmlFormat extends FormatAbstract
{
const MIME_TYPE = 'text/html';
public function stringify()
{
$queryString = $_SERVER['QUERY_STRING'];
$feedArray = $this->getFeed();
2022-07-06 13:14:04 +03:00
$formatFactory = new FormatFactory();
$buttons = [];
$linkTags = [];
foreach ($formatFactory->getFormatNames() as $formatName) {
// Dynamically build buttons for all formats (except HTML)
if ($formatName === 'Html') {
continue;
}
$formatUrl = '?' . str_ireplace('format=Html', 'format=' . $formatName, htmlentities($queryString));
$buttons[] = [
'href' => $formatUrl,
'value' => $formatName,
];
$format = $formatFactory->create($formatName);
$linkTags[] = [
'href' => $formatUrl,
'title' => $formatName,
'type' => $format->getMimeType(),
];
}
if (Configuration::getConfig('admin', 'donations') && $feedArray['donationUri']) {
$buttons[] = [
'href' => e($feedArray['donationUri']),
'value' => 'Donate to maintainer',
];
}
$items = [];
foreach ($this->getItems() as $item) {
$items[] = [
'url' => $item->getURI() ?: $feedArray['uri'],
'title' => $item->getTitle() ?? '(no title)',
'timestamp' => $item->getTimestamp(),
'author' => $item->getAuthor(),
'content' => $item->getContent() ?? '',
'enclosures' => $item->getEnclosures(),
'categories' => $item->getCategories(),
];
}
2013-08-11 15:30:41 +04:00
$html = render_template(__DIR__ . '/../templates/html-format.html.php', [
'charset' => $this->getCharset(),
'title' => $feedArray['name'],
'linkTags' => $linkTags,
'uri' => $feedArray['uri'],
'buttons' => $buttons,
'items' => $items,
]);
// Remove invalid characters
ini_set('mbstring.substitute_character', 'none');
$html = mb_convert_encoding($html, $this->getCharset(), 'UTF-8');
return $html;
}
2014-05-28 18:57:30 +04:00
}