Mercurial > SimpleWebPresenter
view 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 |
line wrap: on
line source
<?php /** * @file * Displays a flag, in an active or disabled state, depending on parameters */ define(DEBUG,0); include_once 'CacheTimeCheck.inc'; $scriptCache = ScriptIncludeCache::instance(__FILE__); $scriptCache->includeOnce('Language.inc'); $scriptCache->includeOnce('common-functions.inc'); $scriptCache->includeOnce('Page.inc'); class Flag extends Page { private $active; private $lang; function __construct($masterCache) { $this->active = $_GET['active']; $lang = $_GET['lang']; if(!$lang) { $lang = "no"; $langs = Language::accepted(); foreach ($langs as $l => $val) { if (file_exists($l)) { $lang = $l; break; } } } $this->lang = $lang; $this->name = "../img/flag-${lang}"; if ($this->active) $this->name .= "-active"; $this->name .= ".png"; $cache = new CacheTimeCheck($this->name); $cache->addParent($masterCache); $this->setCache($cache); } function cacheCheck() { $this->getCache()->cache_time($this->name); return $true; } function mayCompress() { return false; } function generateContent() { $flag = loadFile($this->name); if (floatval($flag) < 0) { errorPage('Resource not found', 404); } else { header("Content-Type: image/png"); return $flag; } } }
