From 5cae40795a87c304724782d18d64a974d7c0a185 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 14 Apr 2009 13:21:29 +0000 Subject: Added pages as a module. --- utils/pages.php | 104 -------------------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 utils/pages.php (limited to 'utils/pages.php') diff --git a/utils/pages.php b/utils/pages.php deleted file mode 100644 index 0ab52a8..0000000 --- a/utils/pages.php +++ /dev/null @@ -1,104 +0,0 @@ -title, ENT_QUOTES, "UTF-8") . "\"\n"); - fwrite($fp, " content=\"" . - htmlspecialchars($this->content, ENT_QUOTES, "UTF-8") . "\">\n"); - fwrite($fp, " \n"); - } - - public function show() - { - global $DATA_DIR, $modules; - - $str = Markdown($this->content); - - if(preg_match_all("/\[\[([\?,a-zA-Z0-9_]+)\]\]/", $str, $res)) { - - $modulecodes = array_unique($res[1]); - foreach($modulecodes as $modulecode) { - $m = explode("?", $modulecode); - $module = $m[0]; - $params = explode(",", $m[1]); - if($modules[$module]) { - $modulestr = $modules[$module]->run($params); - } else { - $modulestr = "

CMS ERROR: Could not find module: [[" . $modulecode . "]]

"; - } - - $str = str_replace("[[" . $modulecode . "]]", $modulestr, $str); - - } - } - - echo $str; - } - - public function Page($title, $content) - { - $this->title = $title; - $this->content = $content; - } -} - -class Pages { - - private $file; - private $pages = array(); - - public function getPage($title) - { - return $this->pages[$title]; - } - - public function add($page) { - $key = $page->title; - $this->pages[$key] = $page; - } - - public function write() - { - $fp = fopen($this->file, "w"); - fwrite($fp, "\n"); - - fwrite($fp, "\n"); - foreach($this->pages as $page) { - $page->write($fp); - } - fwrite($fp, "\n"); - - fclose($fp); - } - - private function read() - { - $dom = new DomDocument; - $dom->preserveWhiteSpace = TRUE; - $dom->load($this->file); - $pages = $dom->getElementsByTagName('page'); - - foreach ($pages as $p) { - $page = new Page($p->getAttribute('title'), - $p->textContent); - $this->add($page); - } - } - - public function Pages($file) - { - $this->file = $file; - if(file_exists($file)) $this->read(); - } - -} -?> -- cgit v1.2.3