HtmlFormat.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. $entries = '';
  16. foreach($this->getDatas() as $data){
  17. $entryUri = is_null($data->uri) ? $uri : $data->uri;
  18. $entryTitle = is_null($data->title) ? '' : $this->sanitizeHtml(strip_tags($data->title));
  19. $entryTimestamp = is_null($data->timestamp) ? '' : '<time datetime="' . date(DATE_ATOM, $data->timestamp) . '">' . date(DATE_ATOM, $data->timestamp) . '</time>';
  20. $entryAuthor = is_null($data->author) ? '' : '<br /><p class="author">by: ' . $data->author . '</p>';
  21. $entryContent = is_null($data->content) ? '' : '<div class="content">' . $this->sanitizeHtml($data->content). '</div>';
  22. $entries .= <<<EOD
  23. <section class="feeditem">
  24. <h2><a class="itemtitle" href="{$entryUri}">{$entryTitle}</a></h2>
  25. {$entryTimestamp}
  26. {$entryAuthor}
  27. {$entryContent}
  28. </section>
  29. EOD;
  30. }
  31. /* Data are prepared, now let's begin the "MAGIE !!!" */
  32. $toReturn = <<<EOD
  33. <!DOCTYPE html>
  34. <html>
  35. <head>
  36. <meta charset="UTF-8">
  37. <title>{$title}</title>
  38. <link href="css/HtmlFormat.css" rel="stylesheet">
  39. <meta name="robots" content="noindex, follow">
  40. </head>
  41. <body>
  42. <h1 class="pagetitle">{$title}</h1>
  43. <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>
  44. {$entries}
  45. </body>
  46. </html>
  47. EOD;
  48. return $toReturn;
  49. }
  50. public function display() {
  51. $this
  52. ->setContentType('text/html; charset=' . $this->getCharset())
  53. ->callContentType();
  54. return parent::display();
  55. }
  56. }