1
0
Fork 0
forked from blallo/rss-bridge
rss-bridge/formats/HtmlFormat.php

65 lines
2.3 KiB
PHP
Raw Normal View History

2013-08-11 13:30:41 +02:00
<?php
class HtmlFormat extends FormatAbstract{
public function stringify(){
/* Datas preparation */
$extraInfos = $this->getExtraInfos();
$title = htmlspecialchars($extraInfos['name']);
$uri = htmlspecialchars($extraInfos['uri']);
$atomquery = str_replace('format=Html', 'format=Atom', htmlentities(filter_input(INPUT_SERVER, 'QUERY_STRING')));
$mrssquery = str_replace('format=Html', 'format=Mrss', htmlentities(filter_input(INPUT_SERVER, 'QUERY_STRING')));
2013-08-11 13:30:41 +02:00
$entries = '';
foreach($this->getDatas() as $data){
$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>' : '';
2013-08-11 13:30:41 +02:00
$entries .= <<<EOD
2016-08-03 20:07:49 +02:00
<section class="feeditem">
2016-08-09 17:17:37 +02:00
<h2><a class="itemtitle" href="{$entryUri}">{$entryTitle}</a></h2>
{$entryTimestamp}
{$entryAuthor}
{$entryContent}
2016-08-03 20:07:49 +02:00
</section>
2013-08-11 13:30:41 +02:00
EOD;
}
/* Data are prepared, now let's begin the "MAGIE !!!" */
$toReturn = <<<EOD
2014-05-28 16:57:30 +02:00
<!DOCTYPE html>
2013-08-11 13:30:41 +02:00
<html>
2014-05-28 16:57:30 +02:00
<head>
2016-08-09 17:17:37 +02:00
<meta charset="UTF-8">
<title>{$title}</title>
<link href="css/HtmlFormat.css" rel="stylesheet">
<meta name="robots" content="noindex, follow">
2014-05-28 16:57:30 +02:00
</head>
<body>
2016-08-09 17:17:37 +02:00
<h1 class="pagetitle"><a href="{$uri}" target="_blank">{$title}</a></h1>
<div class="buttons">
<a href="./#bridge-{$_GET['bridge']}"><button class="backbutton"> back to rss-bridge</button></a>
<a href="./?{$atomquery}"><button class="rss-feed">RSS feed (ATOM)</button></a>
<a href="./?{$mrssquery}"><button class="rss-feed">RSS feed (MRSS)</button></a>
</div>
2013-08-11 13:30:41 +02:00
{$entries}
2014-05-28 16:57:30 +02:00
</body>
2013-08-11 13:30:41 +02:00
</html>
EOD;
return $toReturn;
}
public function display() {
2013-08-11 13:30:41 +02:00
$this
->setContentType('text/html; charset=' . $this->getCharset())
->callContentType();
return parent::display();
}
2014-05-28 16:57:30 +02:00
}