2013-08-11 15:30:41 +04:00
|
|
|
<?php
|
2016-09-10 21:41:11 +03:00
|
|
|
class HtmlFormat extends FormatAbstract {
|
|
|
|
|
|
|
|
public function stringify(){
|
|
|
|
$extraInfos = $this->getExtraInfos();
|
|
|
|
$title = htmlspecialchars($extraInfos['name']);
|
|
|
|
$uri = htmlspecialchars($extraInfos['uri']);
|
|
|
|
$atomquery = str_replace('format=Html', 'format=Atom', htmlentities($_SERVER['QUERY_STRING']));
|
|
|
|
$mrssquery = str_replace('format=Html', 'format=Mrss', htmlentities($_SERVER['QUERY_STRING']));
|
|
|
|
|
|
|
|
$entries = '';
|
|
|
|
foreach($this->getItems() as $item){
|
|
|
|
$entryAuthor = isset($item['author']) ? '<br /><p class="author">by: ' . $item['author'] . '</p>' : '';
|
|
|
|
$entryTitle = isset($item['title']) ? $this->sanitizeHtml(strip_tags($item['title'])) : '';
|
|
|
|
$entryUri = isset($item['uri']) ? $item['uri'] : $uri;
|
2016-09-10 22:01:02 +03:00
|
|
|
|
|
|
|
$entryTimestamp = '';
|
|
|
|
if(isset($item['timestamp'])){
|
|
|
|
$entryTimestamp = '<time datetime="'
|
|
|
|
. date(DATE_ATOM, $item['timestamp'])
|
|
|
|
. '">'
|
|
|
|
. date(DATE_ATOM, $item['timestamp'])
|
|
|
|
. '</time>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$entryContent = '';
|
|
|
|
if(isset($item['content'])){
|
|
|
|
$entryContent = '<div class="content">'
|
|
|
|
. $this->sanitizeHtml($item['content'])
|
|
|
|
. '</div>';
|
|
|
|
}
|
|
|
|
|
2016-11-13 00:04:42 +03:00
|
|
|
$entryEnclosures = '';
|
|
|
|
if(isset($item['enclosures'])){
|
|
|
|
$entryEnclosures = '<div class="attachments"><p>Attachments:</p>';
|
|
|
|
|
|
|
|
foreach($item['enclosures'] as $enclosure){
|
|
|
|
$url = $this->sanitizeHtml($enclosure);
|
|
|
|
|
|
|
|
$entryEnclosures .= '<li class="enclosure"><a href="'
|
|
|
|
. $url
|
|
|
|
. '">'
|
|
|
|
. substr($url, strrpos($url, '/') + 1)
|
|
|
|
. '</a></li>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$entryEnclosures .= '</div>';
|
2016-11-09 20:59:17 +03:00
|
|
|
}
|
|
|
|
|
2016-09-10 21:41:11 +03:00
|
|
|
$entries .= <<<EOD
|
2013-08-11 15:30:41 +04:00
|
|
|
|
2016-08-03 21:07:49 +03:00
|
|
|
<section class="feeditem">
|
2016-09-10 21:41:11 +03:00
|
|
|
<h2><a class="itemtitle" href="{$entryUri}">{$entryTitle}</a></h2>
|
|
|
|
{$entryTimestamp}
|
|
|
|
{$entryAuthor}
|
|
|
|
{$entryContent}
|
2016-11-13 00:04:42 +03:00
|
|
|
{$entryEnclosures}
|
2016-08-03 21:07:49 +03:00
|
|
|
</section>
|
2013-08-11 15:30:41 +04:00
|
|
|
|
|
|
|
EOD;
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
2013-08-11 15:30:41 +04:00
|
|
|
|
2016-11-07 22:49:44 +03:00
|
|
|
$charset = $this->getCharset();
|
|
|
|
|
2016-09-10 21:41:11 +03:00
|
|
|
/* 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>
|
2016-11-07 22:49:44 +03:00
|
|
|
<meta charset="{$charset}">
|
2016-09-10 21:41:11 +03:00
|
|
|
<title>{$title}</title>
|
|
|
|
<link href="css/HtmlFormat.css" rel="stylesheet">
|
|
|
|
<meta name="robots" content="noindex, follow">
|
2014-05-28 18:57:30 +04:00
|
|
|
</head>
|
|
|
|
<body>
|
2016-09-10 21:41:11 +03: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 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;
|
|
|
|
|
2016-11-07 22:49:44 +03:00
|
|
|
// Remove invalid characters
|
|
|
|
ini_set('mbstring.substitute_character', 'none');
|
|
|
|
$toReturn = mb_convert_encoding($toReturn, $this->getCharset(), 'UTF-8');
|
2016-09-10 21:41:11 +03:00
|
|
|
return $toReturn;
|
|
|
|
}
|
2013-08-11 15:30:41 +04:00
|
|
|
|
2016-09-10 21:41:11 +03:00
|
|
|
public function display() {
|
|
|
|
$this
|
|
|
|
->setContentType('text/html; charset=' . $this->getCharset())
|
|
|
|
->callContentType();
|
2013-08-11 15:30:41 +04:00
|
|
|
|
2016-09-10 21:41:11 +03:00
|
|
|
return parent::display();
|
|
|
|
}
|
2014-05-28 18:57:30 +04:00
|
|
|
}
|