PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/cls/header.php

https://github.com/abdallahchamas/haiti_tracker
PHP | 147 lines | 89 code | 31 blank | 27 comment | 19 complexity | 76907149578ee37a655ed255d75a7c0c MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. ###############################################################################
  3. # Gregarius - A PHP based RSS aggregator.
  4. # Copyright (C) 2003 - 2006 Marco Bonetti
  5. #
  6. ###############################################################################
  7. # This program is free software and open source software; you can redistribute
  8. # it and/or modify it under the terms of the GNU General Public License as
  9. # published by the Free Software Foundation; either version 2 of the License,
  10. # or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful, but WITHOUT
  13. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. # more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program; if not, write to the Free Software Foundation, Inc.,
  19. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit
  20. # http://www.gnu.org/licenses/gpl.html
  21. #
  22. ###############################################################################
  23. # E-mail: mbonetti at gmail dot com
  24. # Web page: http://gregarius.net/
  25. #
  26. ###############################################################################
  27. //
  28. class Header {
  29. var $active;
  30. var $cidfid;
  31. var $onLoadAction;
  32. var $options;
  33. var $links;
  34. var $javascriptFiles = array();
  35. var $docTitle;
  36. var $redirectUrl="";
  37. var $redirectTimeout=0;
  38. var $rawTitle;
  39. var $extraHTML = "";
  40. function Header($title = "", $active = 0, $cidfid = null, $onLoadAction = "", $options = HDR_NONE, $links = NULL) {
  41. _pf('Header() ctor');
  42. $this -> docTitle = $title;
  43. $this -> active = $active;
  44. $this -> cidfid = $cidfid;
  45. $this -> onLoadAction = $onLoadAction;
  46. $this -> options = $options;
  47. $this -> rawTitle = $title;
  48. $this -> extraHeaders = array();
  49. $this -> docTitle = makeTitle($title);
  50. if (getConfig("rss.output.titleunreadcnt") &&
  51. is_array($cidfid) &&
  52. ($uc = getUnreadCount($cidfid['cid'], $cidfid['fid']))) {
  53. $this->docTitle .= " ($uc ".__('unread').")";
  54. }
  55. if ($active == 1 && (MINUTE * getConfig('rss.config.refreshafter')) >= (40 * MINUTE)) {
  56. $this->redirectUrl = guessTransportProto().$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
  57. if (substr($this->redirectUrl, -1) != "/") {
  58. $this->redirectUrl .= "/";
  59. }
  60. $this->redirectUrl .= "update.php";
  61. $this->redirectTimeout = MINUTE * getConfig('rss.config.refreshafter');
  62. }
  63. $this -> links = array();
  64. $this -> links[] = array('search','Search',getPath() ."search.php");
  65. $this -> links[] = array('tags','Tags',getPath(). (getConfig('rss.output.usemodrewrite') ? "tag/" : "tags.php?alltags"));
  66. if ($links != NULL) {
  67. //var_dump($links);
  68. foreach ($links as $rel => $link) {
  69. $this -> links[] = array($rel,$link['title'],$link['href']);
  70. }
  71. }
  72. $this -> javascriptFiles[] = getPath()."ajax.php?js";
  73. $this -> javascriptFiles[] = getPath()."extlib/md5.js";
  74. if (getConfig('rss.output.channelcollapse')) {
  75. $this -> javascriptFiles[] = getPath()."extlib/fcollapse.js";
  76. }
  77. $GLOBALS['rss'] -> sideMenu = new SideMenu();
  78. $GLOBALS['rss'] -> sideMenu -> addMenu(__('Feeds'),'FeedList' , "_side('FeedList')");
  79. $GLOBALS['rss'] -> sideMenu -> addMenu(__('Categories'), 'CatList', "_side('CatList')");
  80. $GLOBALS['rss'] -> sideMenu -> addMenu(__('Tags'), 'TagList', "_side('TagList')");
  81. }
  82. function appendHeader($hdr) {
  83. $this ->extraHeaders[] = $hdr;
  84. }
  85. function preRender() {
  86. _pf('Header preRender()');
  87. if (!($this->options & HDR_NO_CACHECONTROL) && getConfig('rss.output.cachecontrol')) {
  88. $etag = getETag();
  89. $hdrs = rss_getallheaders();
  90. if (array_key_exists('If-None-Match', $hdrs) && $hdrs['If-None-Match'] == $etag) {
  91. header("HTTP/1.1 304 Not Modified");
  92. flush();
  93. exit ();
  94. } else {
  95. header('Last-Modified: '.gmstrftime("%a, %d %b %Y %T %Z", getLastModif()));
  96. header("ETag: $etag");
  97. }
  98. }
  99. if (count($this -> extraHeaders)) {
  100. foreach ($this -> extraHeaders as $hdr) {
  101. header($hdr);
  102. }
  103. }
  104. rss_plugin_hook('rss.plugins.bodystart', null);
  105. }
  106. function render() {
  107. $this -> javascriptFiles
  108. = rss_plugin_hook('rss.plugins.javascript', $this -> javascriptFiles);
  109. $GLOBALS['rss'] -> header = &$this;
  110. rss_require(RSS::getTemplateFile("header.php"));
  111. if ($this->extraHTML) {
  112. echo $this -> extraHTML;
  113. }
  114. }
  115. }
  116. ?>