1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-07-30 21:30:14 +02:00
This commit is contained in:
Dag
2024-03-31 03:38:42 +02:00
committed by GitHub
parent 24e429969f
commit 545dc969d3
5 changed files with 47 additions and 40 deletions

View File

@@ -6,34 +6,26 @@ class HtmlFormat extends FormatAbstract
public function stringify()
{
// This query string comes in already url decoded
$queryString = $_SERVER['QUERY_STRING'];
$feedArray = $this->getFeed();
$formatFactory = new FormatFactory();
$buttons = [];
$linkTags = [];
foreach ($formatFactory->getFormatNames() as $formatName) {
// Dynamically build buttons for all formats (except HTML)
$formats = [];
// Create all formats (except HTML)
$formatNames = $formatFactory->getFormatNames();
foreach ($formatNames as $formatName) {
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',
// The format url is relative, but should be absolute in order to help feed readers.
$formatUrl = '?' . str_ireplace('format=Html', 'format=' . $formatName, $queryString);
$formatObject = $formatFactory->create($formatName);
$formats[] = [
'url' => $formatUrl,
'name' => $formatName,
'type' => $formatObject->getMimeType(),
];
}
@@ -50,13 +42,18 @@ class HtmlFormat extends FormatAbstract
];
}
$donationUri = null;
if (Configuration::getConfig('admin', 'donations') && $feedArray['donationUri']) {
$donationUri = $feedArray['donationUri'];
}
$html = render_template(__DIR__ . '/../templates/html-format.html.php', [
'charset' => $this->getCharset(),
'title' => $feedArray['name'],
'linkTags' => $linkTags,
'uri' => $feedArray['uri'],
'buttons' => $buttons,
'items' => $items,
'charset' => $this->getCharset(),
'title' => $feedArray['name'],
'formats' => $formats,
'uri' => $feedArray['uri'],
'items' => $items,
'donation_uri' => $donationUri,
]);
// Remove invalid characters
ini_set('mbstring.substitute_character', 'none');