public function generatePage($pageUrl = null) { $file = self::$errorFile; if (null == $pageUrl || "index.html" == $pageUrl[0] || "index.php" == $pageUrl[0]) { if (is_file(self::$dir . self::$homeFile)) { $file = self::$homeFile; self::setHeaderCode(200); } } else { end($pageUrl); while (count($pageUrl) > 0) { $c = key($pageUrl); $p = implode("/", $pageUrl); $fn = str_replace(array(".html", ".htm", ".phtml", ".php"), "", $p) . ".php"; if (is_file(self::$dir . $fn)) { $file = $fn; self::setHeaderCode(200); break; } else { unset($pageUrl[$c]); } if (!empty($pageUrl)) { end($pageUrl); } } } ob_start(); include self::$dir . $file; $c = ob_get_contents(); ob_end_clean(); preg_match_all('~^\\s*//.*$~m', $c, $comments); self::$pageTitle = trim(!empty($comments[0][0]) ? $comments[0][0] : trim(str_replace(array(".php", "-", "+"), " ", $file)), "//"); self::$pageTemplate = trim(!empty($comments[0][1]) && file_exists(TEMPLATES . DS . $comments[0][1]) ? $comments[0][1] : self::$defailtPageTemplate, "//"); self::$pageContent = trim(preg_replace('~^\\s*//.*$~m', '', $c)); }
/** * Change the title of the page * @param String $title the title of the page */ public static function setTitle($title) { self::$pageTitle = $title; }