rss-bridge/formats/HtmlFormat.php

71 lines
2.4 KiB
PHP
Raw Normal View History

2013-08-11 13:30:41 +02:00
<?php
/**
* Html
* Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
*
* @name Html
*/
class HtmlFormat extends FormatAbstract{
public function stringify(){
/* Datas preparation */
$extraInfos = $this->getExtraInfos();
$title = htmlspecialchars($extraInfos['name']);
$uri = htmlspecialchars($extraInfos['uri']);
$atomquery = str_replace('format=HtmlFormat', 'format=AtomFormat', htmlentities($_SERVER['QUERY_STRING']));
2016-08-09 17:17:37 +02:00
$mrssquery = str_replace('format=HtmlFormat', 'format=MrssFormat', htmlentities($_SERVER['QUERY_STRING']));
2013-08-11 13:30:41 +02:00
$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;
2016-08-03 20:07:49 +02:00
$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>';
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
}