rss-bridge/formats/HtmlFormat.php

66 lines
2.2 KiB
PHP
Raw Normal View History

2013-08-11 15:30:41 +04: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']);
2014-05-28 18:57:30 +04:00
$atomquery = str_replace('format=HtmlFormat', 'format=AtomFormat', htmlentities($_SERVER['QUERY_STRING']));
2013-08-11 15:30:41 +04:00
$entries = '';
foreach($this->getDatas() as $data){
$entryUri = is_null($data->uri) ? $uri : $data->uri;
$entryTitle = is_null($data->title) ? '' : $this->sanitizeHtml(strip_tags($data->title));
2016-08-03 21:07:49 +03:00
$entryTimestamp = is_null($data->timestamp) ? '' : '<time datetime="' . date(DATE_ATOM, $data->timestamp) . '">' . date(DATE_ATOM, $data->timestamp) . '</time>';
$entryAuthor = is_null($data->author) ? '' : '<br /><p class="author">by: ' . $data->author . '</p>';
$entryContent = is_null($data->content) ? '' : '<div class="content">' . $this->sanitizeHtml($data->content). '</div>';
2013-08-11 15:30:41 +04:00
$entries .= <<<EOD
2016-08-03 21:07:49 +03:00
<section class="feeditem">
<h2><a class="itemtitle" href="{$entryUri}">{$entryTitle}</a></h2>
2014-05-28 18:57:30 +04:00
{$entryTimestamp}
2015-10-13 19:04:45 +03:00
{$entryAuthor}
{$entryContent}
2016-08-03 21:07:49 +03:00
</section>
2013-08-11 15:30:41 +04:00
EOD;
}
/* Data are prepared, now let's begin the "MAGIE !!!" */
$toReturn = <<<EOD
2014-05-28 18:57:30 +04:00
<!DOCTYPE html>
2013-08-11 15:30:41 +04:00
<html>
2014-05-28 18:57:30 +04:00
<head>
<meta charset="UTF-8">
<title>{$title}</title>
2016-08-03 21:07:49 +03:00
<link href="css/HtmlFormat.css" rel="stylesheet">
2014-05-28 18:57:30 +04:00
<meta name="robots" content="noindex, follow">
</head>
<body>
<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</button></a></div>
2013-08-11 15:30:41 +04:00
{$entries}
2014-05-28 18:57:30 +04:00
</body>
2013-08-11 15:30:41 +04:00
</html>
EOD;
return $toReturn;
}
public function display() {
2013-08-11 15:30:41 +04:00
$this
->setContentType('text/html; charset=' . $this->getCharset())
->callContentType();
return parent::display();
}
2014-05-28 18:57:30 +04:00
}