comparison Page.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
children 88904282b888
comparison
equal deleted inserted replaced
76:fae4322d6c29 78:7c68015b211a
1 <?
2 include_once 'ScriptIncludeCache.inc';
3
4 /// @cond
5 $baseDir = dirname(__FILE__);
6 $cache = ScriptIncludeCache::instance(__FILE__);
7 $cache->includeOnce('Options.inc', dirname(__FILE__));
8 /// @endcond
9
10 /**
11 * Functionality for generating a page
12 */
13 class Page
14 {
15 private $cache;
16
17 function __construct($cache)
18 {
19 $this->setCache($cache);
20 }
21
22 protected function setCache($cache)
23 {
24 $this->cache = $cache;
25 }
26
27 protected function getCache()
28 {
29 return $this->cache;
30 }
31
32 function mayCompress()
33 {
34 return (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'));
35 }
36
37 function startCompression()
38 {
39 ob_start("ob_gzhandler");
40 }
41
42 function genPage()
43 {
44 if ($this->cacheCheck()) {
45 $this->cache->CheckHttpModified();
46 }
47 $res = $this->generateContent();
48 if ($this->mayCompress()) {
49 $this->startCompression();
50 }
51 print $res;
52 }
53
54
55 }
56 ?>