Mercurial > SimpleWebPresenter
comparison Flag.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 | fae4322d6c29 |
| children | 9b490aa11124 |
comparison
equal
deleted
inserted
replaced
| 76:fae4322d6c29 | 78:7c68015b211a |
|---|---|
| 8 include_once 'CacheTimeCheck.inc'; | 8 include_once 'CacheTimeCheck.inc'; |
| 9 | 9 |
| 10 $scriptCache = ScriptIncludeCache::instance(__FILE__); | 10 $scriptCache = ScriptIncludeCache::instance(__FILE__); |
| 11 $scriptCache->includeOnce('Language.inc'); | 11 $scriptCache->includeOnce('Language.inc'); |
| 12 $scriptCache->includeOnce('common-functions.inc'); | 12 $scriptCache->includeOnce('common-functions.inc'); |
| 13 $scriptCache->includeOnce('Page.inc'); | |
| 13 | 14 |
| 14 class Flag { | 15 class Flag extends Page |
| 16 { | |
| 15 private $active; | 17 private $active; |
| 16 private $lang; | 18 private $lang; |
| 17 private $cache; | |
| 18 | 19 |
| 19 function __construct($masterCache) | 20 function __construct($masterCache) |
| 20 { | 21 { |
| 21 $this->active = $_GET['active']; | 22 $this->active = $_GET['active']; |
| 22 $lang = $_GET['lang']; | 23 $lang = $_GET['lang']; |
| 37 $this->name = "../img/flag-${lang}"; | 38 $this->name = "../img/flag-${lang}"; |
| 38 if ($this->active) | 39 if ($this->active) |
| 39 $this->name .= "-active"; | 40 $this->name .= "-active"; |
| 40 $this->name .= ".png"; | 41 $this->name .= ".png"; |
| 41 | 42 |
| 42 $this->cache = new CacheTimeCheck($this->name); | 43 $cache = new CacheTimeCheck($this->name); |
| 43 $this->cache->addParent($masterCache); | 44 $cache->addParent($masterCache); |
| 44 $this->cache->cache_time($this->name); | 45 $this->setCache($cache); |
| 45 } | 46 } |
| 46 | 47 |
| 47 function getPage() | 48 function cacheCheck() |
| 48 { | 49 { |
| 49 $this->cache->CheckHttpModified(); | 50 $this->getCache()->cache_time($this->name); |
| 51 return $true; | |
| 52 } | |
| 53 | |
| 54 function mayCompress() | |
| 55 { | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 function generateContent() | |
| 60 { | |
| 50 | 61 |
| 51 $flag = loadFile($this->name); | 62 $flag = loadFile($this->name); |
| 52 | 63 |
| 53 if (floatval($flag) < 0) { | 64 if (floatval($flag) < 0) { |
| 54 errorPage('Resource not found', 404); | 65 errorPage('Resource not found', 404); |
