mode = $mode; } /** * Set the page's MIME type */ public function set_type($type) { $this->type = $type; } //@} // ============================================== /** @name "data" mode */ //@{ /** @private */ var $data = ""; /** @private */ var $filename = null; /** * Set the raw data to be sent */ public function set_data($data) { $this->data = $data; } /** * Set the recommended download filename */ public function set_filename($filename) { $this->filename = $filename; } //@} // ============================================== /** @name "redirect" mode */ //@{ /** @private */ var $redirect = ""; /** * Set the URL to redirect to (remember to use make_link() if linking * to a page in the same site) */ public function set_redirect($redirect) { $this->redirect = $redirect; } //@} // ============================================== /** @name "page" mode */ //@{ /** @privatesection */ var $title = ""; var $heading = ""; var $subheading = ""; var $quicknav = ""; var $headers = array(); var $blocks = array(); /** @publicsection */ /** * Set the window title */ public function set_title($title) { $this->title = $title; } /** * Set the main heading */ public function set_heading($heading) { $this->heading = $heading; } /** * Set the sub heading */ public function set_subheading($subheading) { $this->subheading = $subheading; } /** * Add a line to the HTML head section */ public function add_header($line, $position=50) { while(isset($this->headers[$position])) $position++; $this->headers[$position] = $line; } /** * Add a Block of data */ public function add_block(Block $block) { $this->blocks[] = $block; } //@} // ============================================== /** * Display the page according to the mode and data given */ public function display() { global $page; header("Content-type: {$this->type}"); header("X-Powered-By: SCore-".SCORE_VERSION); switch($this->mode) { case "page": header("Cache-control: no-cache"); usort($this->blocks, "blockcmp"); $this->add_auto_headers(); $layout = new Layout(); $layout->display_page($page); break; case "data": header("Content-Length: ".strlen($this->data)); if(!is_null($this->filename)) { header('Content-Disposition: attachment; filename='.$this->filename); } print $this->data; break; case "redirect": header("Location: {$this->redirect}"); print "You should be redirected to {$this->redirect}"; break; default: print "Invalid page mode"; break; } } protected function add_auto_headers() { $data_href = get_base_href(); foreach(glob("lib/*.js") as $js) { $this->add_header(""); } $css_files = glob("ext/*/style.css"); if($css_files) { foreach($css_files as $css_file) { $this->add_header(""); } } $js_files = glob("ext/*/script.js"); if($js_files) { foreach($js_files as $js_file) { $this->add_header(""); } } } } ?>