HtmlFormat.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Html
  4. * Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
  5. *
  6. * @name Html
  7. */
  8. class HtmlFormat extends FormatAbstract{
  9. public function stringify(){
  10. /* Datas preparation */
  11. $extraInfos = $this->getExtraInfos();
  12. $title = htmlspecialchars($extraInfos['name']);
  13. $uri = htmlspecialchars($extraInfos['uri']);
  14. $atomquery = str_replace('format=HtmlFormat', 'format=AtomFormat', htmlentities($_SERVER['QUERY_STRING']));
  15. $mrssquery = str_replace('format=HtmlFormat', 'format=MrssFormat', htmlentities($_SERVER['QUERY_STRING']));
  16. $entries = '';
  17. foreach($this->getDatas() as $data){
  18. $entryAuthor = is_null($data->author) ? '' : '<br /><p class="author">by: ' . $data->author . '</p>';
  19. $entryTitle = is_null($data->title) ? '' : $this->sanitizeHtml(strip_tags($data->title));
  20. $entryUri = is_null($data->uri) ? $uri : $data->uri;
  21. $entryTimestamp = is_null($data->timestamp) ? '' : '<time datetime="' . date(DATE_ATOM, $data->timestamp) . '">' . date(DATE_ATOM, $data->timestamp) . '</time>';
  22. $entryContent = is_null($data->content) ? '' : '<div class="content">' . $this->sanitizeHtml($data->content). '</div>';
  23. $entries .= <<<EOD
  24. <section class="feeditem">
  25. <h2><a class="itemtitle" href="{$entryUri}">{$entryTitle}</a></h2>
  26. {$entryTimestamp}
  27. {$entryAuthor}
  28. {$entryContent}
  29. </section>
  30. EOD;
  31. }
  32. /* Data are prepared, now let's begin the "MAGIE !!!" */
  33. $toReturn = <<<EOD
  34. <!DOCTYPE html>
  35. <html>
  36. <head>
  37. <meta charset="UTF-8">
  38. <title>{$title}</title>
  39. <link href="css/HtmlFormat.css" rel="stylesheet">
  40. <meta name="robots" content="noindex, follow">
  41. </head>
  42. <body>
  43. <h1 class="pagetitle"><a href="{$uri}" target="_blank">{$title}</a></h1>
  44. <div class="buttons">
  45. <a href="./#bridge-{$_GET['bridge']}"><button class="backbutton">← back to rss-bridge</button></a>
  46. <a href="./?{$atomquery}"><button class="rss-feed">RSS feed (ATOM)</button></a>
  47. <a href="./?{$mrssquery}"><button class="rss-feed">RSS feed (MRSS)</button></a>
  48. </div>
  49. {$entries}
  50. </body>
  51. </html>
  52. EOD;
  53. return $toReturn;
  54. }
  55. public function display() {
  56. $this
  57. ->setContentType('text/html; charset=' . $this->getCharset())
  58. ->callContentType();
  59. return parent::display();
  60. }
  61. }