Пример #1
0
 public static function OutputStartpage($containerclass = "")
 {
     $stdout = "";
     if (!empty($containerclass)) {
         $stdout .= "        <div id='" . $containerclass . "'>\r\n\r\n";
     }
     foreach ($GLOBALS["documentClass"]->getConfig("startpage") as $clarr) {
         if (!is_array($clarr) && $clarr == "clear") {
             $stdout .= "        <div class='column-end'></div>\r\n";
         } else {
             foreach ($clarr as $class => $arr) {
                 $stdout .= "        <!-- = = = = = = = = = = = = = = = = = = = = = = -->\r\n\r\n";
                 if (!empty($class)) {
                     $stdout .= "        <div class='" . $class . "'>\r\n\r\n";
                 }
                 if (is_array($arr)) {
                     foreach ($arr as $cmd) {
                         $stdout .= functions::outputFunctionCall($cmd);
                     }
                 }
                 if (!empty($class)) {
                     $stdout .= "\r\n        </div>\r\n";
                 }
             }
         }
         // end if
     }
     // end foreach
     $stdout .= "        <!-- = = = = = = = = = = = = = = = = = = = = = = -->\r\n\r\n";
     if (!empty($containerclass)) {
         $stdout .= "        </div> <!-- " . $containerclass . " -->\r\n";
     }
     return $stdout;
 }
Пример #2
0
 public function OutputPage()
 {
     // ---------------------------------------------------------------------------
     // READ CONFIGURATION OF THIS PAGE
     // ---------------------------------------------------------------------------
     $this->initiatePage();
     if ($this->isHeaderSent()) {
         return "";
     }
     $this->setHeaderSent();
     // ---------------------------------------------------------------------------
     // HANDLE EXCEPTIONAL DOCUMENTS
     // ---------------------------------------------------------------------------
     // -- For redirects
     if ($this->getConfig("url")) {
         header("X-Robots-Tag: noindex, nofollow");
         header("Cache-control: public, no-cache, must-revalidate");
         header("Expires: " . gmdate(RFC_TIME_FORMAT, time()));
         header("Location: " . $this->getConfig("url"));
         die;
     }
     // -- For plaintext output
     if ($this->getConfig("contenttype") == "plain") {
         header("Content-Type: text/plain; charset=" . CHARSET);
         $stdout = "";
         if (!is_null($this->getPageConfig("command"))) {
             foreach (explode(";", $this->getPageConfig("command")) as $cmd) {
                 $stdout .= functions::outputFunctionCall($cmd);
             }
         }
         return $stdout;
     }
     // -- Assumed to provide its own http headers
     if ($this->getConfig("contenttype") == "standalone") {
         $stdout = "";
         if (!is_null($this->getPageConfig("command"))) {
             foreach (explode(";", $this->getPageConfig("command")) as $cmd) {
                 $stdout .= functions::outputFunctionCall($cmd);
             }
         }
         return $stdout;
     }
     // -- RSS feed page
     if ($this->getConfig("contenttype") == "feed") {
         header("Content-Type: application/rss+xml; charset=" . CHARSET);
         $stdout = "";
         if (!is_null($this->getPageConfig("command"))) {
             foreach (explode(";", $this->getPageConfig("command")) as $cmd) {
                 $stdout .= functions::outputFunctionCall($cmd);
             }
         }
         return $stdout;
     }
     // ---------------------------------------------------------------------------
     // HANDLE REGUALR DOCUMENTS
     // ---------------------------------------------------------------------------
     // -- Check if browser sent request header "Accept-Encoding: gzip, deflate",
     //    and in that case send "Content-Encoding: gzip" response header:
     if (USE_COMPRESS && extension_loaded('zlib')) {
         ob_start("ob_gzhandler");
     }
     // -- Send other HTTP headers not supplied by the server:
     $this->outputHttpHeaders();
     // -- Create HTML code for entire page and return to calling script
     return $this->buildPageHtml();
 }
Пример #3
0
 public static function get($cachename, $cachetype = "s", $callback = "")
 {
     $GLOBALS["nw_debug"]["fromcache_get"] = 0;
     // -- Must specify $callback
     if (empty($callback)) {
         $GLOBALS["nw_debug"]["fromcache_get"] = 1;
         return "";
     }
     // -- Must specify $cachename
     $cachename = strtolower(preg_replace("/\\W/", "", $cachename));
     // keep only "a-z0-9_"
     if (empty($cachename)) {
         $GLOBALS["nw_debug"]["fromcache_get"] = 2;
         return "";
     }
     //if (IS_SECURE and in_array($cachename,array("startpage"))) $cachename = REQUESTSCHEME . "_" . $cachename;
     // -- Collect any extra passed parameters that will be passed on to the $callback function.
     $args = func_get_args();
     unset($args[0]);
     unset($args[1]);
     unset($args[2]);
     $callbackFunction = $callback . "('" . implode("','", $args) . "')";
     // -- If page called with GET variable 'cache' (any value), per-page and per-session
     //    caches are emptied to guarantee clean regeneration.
     if (isset($_REQUEST["cache"])) {
         self::reset_page_cache();
         self::reset_session_cache();
     }
     // -- Fetch requested cache, or regenerate it if it doesn't exist:
     switch ($cachetype) {
         // ----------------------------------------------------------------------------
         // Cache stored in $GLOBALS (per-page cache)
         // ----------------------------------------------------------------------------
         case "g":
             if (isset($GLOBALS["cache"][$cachename])) {
                 return $GLOBALS["cache"][$cachename];
             } else {
                 $pagecontent = functions::outputFunctionCall($callbackFunction);
                 $GLOBALS["cache"][$cachename] = $pagecontent;
                 return $pagecontent;
             }
             break;
             // ----------------------------------------------------------------------------
             // Cache stored in $_SESSION (per-visit cache)
             // ----------------------------------------------------------------------------
         // ----------------------------------------------------------------------------
         // Cache stored in $_SESSION (per-visit cache)
         // ----------------------------------------------------------------------------
         case "s":
             if (isset($_SESSION["cache"][$cachename])) {
                 return $_SESSION["cache"][$cachename];
             } else {
                 $pagecontent = functions::outputFunctionCall($callbackFunction);
                 $_SESSION["cache"][$cachename] = $pagecontent;
                 return $pagecontent;
             }
             break;
             // ----------------------------------------------------------------------------
             // Cache stored in a file in '/tmp' regenerated every 12 or 24 hrs (per-site cache)
             // ----------------------------------------------------------------------------
         // ----------------------------------------------------------------------------
         // Cache stored in a file in '/tmp' regenerated every 12 or 24 hrs (per-site cache)
         // ----------------------------------------------------------------------------
         case "12":
         case "24":
             /*
             //TODO: call instead function that creates cache file name
                     $datestring = "Y-m-d" . ( ($cachetype=="12") ? "-A" : "" );
                     $cachefile =
                       CACHE_PATH .
                       //( in_array($cachename,array("startpage")) ? REQUESTSCHEME."_" : "" ) .
                       CACHE_DOCROOT_PREFIX . "_" .
                       strtoupper($cachename) . "_" .
                       date($datestring,time()).".html";
             */
             $cachefile = self::get_cache_filename($cachename, $cachetype);
             // Return contents of existing cache file:
             if (file_exists($cachefile)) {
                 $GLOBALS["nw_debug"]["fromcache_get"] = 4;
                 $pagecontent = unserialize(file_get_contents($cachefile));
                 if (!empty($pagecontent)) {
                     return $pagecontent;
                 }
             }
             // Recreate and return non-existing cache file:
             if (!file_exists($cachefile) || empty($pagecontent)) {
                 $GLOBALS["nw_debug"]["fromcache_get"] = 5;
                 $pagecontent = functions::outputFunctionCall($callbackFunction);
                 $fp = fopen($cachefile, "w");
                 fwrite($fp, serialize($pagecontent));
                 fclose($fp);
                 return $pagecontent;
             }
             break;
             // ----------------------------------------------------------------------------
         // ----------------------------------------------------------------------------
         default:
             $GLOBALS["nw_debug"]["fromcache_get"] = 6;
             return "";
     }
     // end switch
 }
Пример #4
0
 static function BstartpageAnnouncements($id = "announcements", $class = "", $openOnclick = false)
 {
     /* RESTORE if needed
         // If want accordion effect
         $class = str_replace("acc-item","",str_replace("onetab","",$class));
         $class .= ($openOnclick) ? " acc-item onetab openonclick" : "";
         $class = trim($class);
     */
     $items = "";
     /*
         $items =
           functions::callMethod('news','lib/news','drawLinkCurrentnewsissue','announce-news','','box infosection') .
           functions::callMethod('position','lib/position','outputProposePrograms','announce-programs','','box infosection') .
           functions::callMethod('position','lib/position','OutputOpenPositions','announce-positions','','box infosection','1','0','1') .
           functions::callMethod('event','lib/event','outputRegistrationOpen','announce-registration','','box infosection','1');
     */
     foreach ($GLOBALS["documentClass"]->getConfig("startpageannouncements") as $cmd) {
         $items .= functions::outputFunctionCall($cmd);
     }
     if ($openOnclick) {
         $items = "            <h2><span>Announcements</span></h2>\r\n" . "            <div>\r\n" . $items . "\r\n" . "            </div>\r\n";
     }
     $stdout = "          <div id='block-" . $id . "'" . (!empty($class) ? " class='" . $class . "'" : "") . ">\r\n" . "\r\n" . $items . "          </div> <!-- " . $id . " -->\r\n" . "\r\n";
     return $stdout;
 }