Mercurial > SimpleWebPresenter
view Options.inc @ 39:bd82b719a0de
Make CacheTimeCheck a singleton.
Robustify if_modified_since check.
Quiet warnings.
Set debug levels.
Fix basepath references.
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Fri, 05 Oct 2012 00:21:27 +0200 |
| parents | aec57ed6f5f6 |
| children | 66382989353f |
line wrap: on
line source
<?php class Options { private $defaultLang; private $lang; private $name; private $acceptedLanguages = array(); private $inputDefaults = array(); private $cache; private $urlParams = array(); private $basePath; function getDefaultLang() { return $this->defaultLang; } function getLang() { return $this->lang; } function setLang($lang) { $this->lang = $lang; } function getBasePath() { return $this->basePath; } function setBasePath($basePath) { $this->basePath = $basePath; } function setUrlParams($urlParams) { foreach($urlParams as $key) { $value = array_key_exists($key, $_GET) ? $_GET[$key] : ''; $this->urlParams[$key] = $value; } } function getUrlParams() { return $this->urlParams; } function setName($name) { $this->name = $name; } function getName() { return $this->name; } function setCache($cache) { $this->cache = $cache; } function getCache() { return $this->cache; } function getAcceptedLanguages() { return $this->acceptedLanguages; } function getInputDefault($key) { return $this->inputDefaults[$key]; } function __construct($baseDocument) { $params = $baseDocument->getElementsByTagName("param"); foreach ($params as $param) { if ($param->getAttribute("type") == "option") { $id = $param->getAttribute("id"); if ($id == "lang") { $this->defaultLang = $param->getAttribute("default"); $accepts = $param->getElementsByTagName("accept_value"); foreach($accepts as $accept) { foreach($accept->childNodes as $child) { array_push($this->acceptedLanguages, $child->nodeValue); } } } else { die("Invalid option : $id"); } $parent = $param->parentNode; $parent->removeChild($param); } elseif ($param->getAttribute("type") == "input") { $id = $param->getAttribute("id"); $default = $param->getAttribute("default"); $this->inputDefaults[$id] = $default; } } } } ?>
