comparison InputParser.inc @ 78:7c68015b211a

Common source for all page generators. Support for compressed output.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Fri, 12 Oct 2012 16:43:26 +0200
parents dd4ddedca4c5
children f468365813c9
comparison
equal deleted inserted replaced
76:fae4322d6c29 78:7c68015b211a
1 <?php 1 <?php
2 /// @cond
3 $baseDir = dirname(__FILE__);
4 $cache = ScriptIncludeCache::instance(__FILE__);
5 $cache->includeOnce('Page.inc', dirname(__FILE__));
6 /// @endcond
7
2 /** 8 /**
3 * Functionality for translating an XML configuration document into a webpage 9 * Functionality for translating an XML configuration document into a webpage
4 */ 10 */
5 class InputParser { 11 class InputParser extends Page
12 {
6 private $options; 13 private $options;
7 private $master; 14 private $master;
8 15
9 /** 16 /**
10 * Constructs a new InputParser object 17 * Constructs a new InputParser object
16 */ 23 */
17 function __construct($name, $masterCache) { 24 function __construct($name, $masterCache) {
18 $this->master = new DOMDocument(); 25 $this->master = new DOMDocument();
19 $cache = new CacheTimeCheck($name); 26 $cache = new CacheTimeCheck($name);
20 $cache->addParent($masterCache); 27 $cache->addParent($masterCache);
28 parent::setCache($cache);
21 $this->master->load($name); 29 $this->master->load($name);
22 30
23 $this->options = new Options($this->master); 31 $this->options = new Options($this->master);
24 $this->options->setCache($cache); 32 $this->options->setCache($cache);
25 $this->options->setBasePath(basePath()); 33 $this->options->setBasePath(basePath());
54 } 62 }
55 $this->master = self::getFiles($this->master, $this->options); 63 $this->master = self::getFiles($this->master, $this->options);
56 64
57 } 65 }
58 66
67 function cacheCheck()
68 {
69 return $this->options->getCacheable();
70 }
71
59 /** 72 /**
60 * Generate an appropriate response for this page, eg. 302 NOT 73 * Generate an appropriate response for this page, eg. 302 NOT
61 * MODIFIED or the actual page 74 * MODIFIED or the actual page
62 */ 75 */
63 function genPage() 76 function generateContent()
64 { 77 {
65 //print_r($this->options->getCache()->cacheSet(1)); 78 //print_r($this->options->getCache()->cacheSet(1));
66 //exit; 79 //exit;
67 if (CACHING && $this->options->getCacheable()) 80 return $this->master->saveXml($this->master);
68 $this->options->getCache()->CheckHttpModified();
69 print $this->master->saveXml($this->master);
70 } 81 }
71 82
72 /** 83 /**
73 * Extracts data from a @<param@> tag. 84 * Extracts data from a @<param@> tag.
74 * 85 *