Improve HTML output

This commit is contained in:
Mitsukarenai 2014-05-28 16:57:30 +02:00
parent c4929d51e1
commit 0874e13824

View file

@ -12,39 +12,61 @@ class HtmlFormat extends FormatAbstract{
$extraInfos = $this->getExtraInfos(); $extraInfos = $this->getExtraInfos();
$title = htmlspecialchars($extraInfos['name']); $title = htmlspecialchars($extraInfos['name']);
$uri = htmlspecialchars($extraInfos['uri']); $uri = htmlspecialchars($extraInfos['uri']);
$atomquery = str_replace('format=HtmlFormat', 'format=AtomFormat', htmlentities($_SERVER['QUERY_STRING']));
$entries = ''; $entries = '';
foreach($this->getDatas() as $data){ foreach($this->getDatas() as $data){
$entryUri = is_null($data->uri) ? $uri : $data->uri; $entryUri = is_null($data->uri) ? $uri : $data->uri;
$entryTitle = is_null($data->title) ? '' : $this->sanitizeHtml(strip_tags($data->title)); $entryTitle = is_null($data->title) ? '' : $this->sanitizeHtml(strip_tags($data->title));
$entryTimestamp = is_null($data->timestamp) ? '' : '<small>' . date(DATE_ATOM, $data->timestamp) . '</small>'; $entryTimestamp = is_null($data->timestamp) ? '' : '<small><time datetime="' . date(DATE_ATOM, $data->timestamp) . '">' . date(DATE_ATOM, $data->timestamp) . '</time></small>';
$entryContent = is_null($data->content) ? '' : '<p>' . $this->sanitizeHtml($data->content). '</p>'; $entryContent = is_null($data->content) ? '' : '<p>' . $this->sanitizeHtml($data->content). '</p>';
$entries .= <<<EOD $entries .= <<<EOD
<div class="rssitem"> <div class="feeditem">
<h2><a href="{$entryUri}">{$entryTitle}</a></h2> <h2><a href="{$entryUri}">{$entryTitle}</a></h2>
{$entryTimestamp} {$entryTimestamp}
{$entryContent} {$entryContent}
</div> </div>
EOD; EOD;
} }
$styleCss = <<<'EOD' $styleCss = <<<'EOD'
body{font-family:"Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;font-size:10pt;background-color:#aaa;}div.rssitem{border:1px solid black;padding:5px;margin:10px;background-color:#fff;} body{
font-family:"Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;
font-size:10pt;
background-color:#aaa;
background-image:linear-gradient(#eee, #aaa);
background-attachment:fixed;
}
div.feeditem{border:1px solid black;padding:1em;margin:1em;background-color:#fff;}
div.feeditem:hover { background-color:#ebf7ff; }
h1 {border-bottom:dotted #bbb;margin:0 1em 1em 1em;}
h2 {margin:0;}
h2 a {color:black;text-decoration:none;}
h2 a:hover {text-decoration:underline;}
span.menu {margin-left:1em;}
span.menu img {vertical-align:middle;}
span.menu a { color:black; text-decoration:none; padding:0.4em; }
span.menu a:hover { background-color:white; }
EOD; EOD;
/* Data are prepared, now let's begin the "MAGIE !!!" */ /* Data are prepared, now let's begin the "MAGIE !!!" */
$toReturn = <<<EOD $toReturn = <<<EOD
<!DOCTYPE html>
<html> <html>
<head> <head>
<title>{$title}</title> <meta charset="UTF-8">
<style type="text/css">{$styleCss}</style> <title>{$title}</title>
</head> <style type="text/css">{$styleCss}</style>
<body> <meta name="robots" content="noindex, follow">
<h1>{$title}</h1> </head>
<body>
<h1>{$title}</h1>
<span class="menu"><a href="./" onclick="window.history.back()"> back to rss-bridge</a> <a title="Get the ATOM feed" href="./?{$atomquery}"><img alt="feed" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZAgMAAAC5h23wAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJUExURf+cCv/8+P/OhD2VurcAAAABdFJOU/4a4wd9AAAAbklEQVQI13XOMQ6AIAwFUGzCgLtHYPEUHMHBTwgTRyFOXoDdUT2ltCKbXV6b/iZV6qcMYmY1EJtw3MwFQRJU/Bfl6VaEzENQxbHIUxKTrY4Xgk4ct0EvcrYa9iTPGrxqbE3XHWSfRfIk1trp6O8+R38aBYbaAE4AAAAASUVORK5CYII="></a></span>
{$entries} {$entries}
</body> </body>
</html> </html>
EOD; EOD;