Mercurial > SimpleWebPresenter
diff index.php @ 26:d8c7b328899e
Removed globals, and introduced Options object for passing values
around.
Introduced <accepted_values> tag into master.xml
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Sun, 30 Sep 2012 00:16:58 +0200 |
| parents | da86ec2814e2 |
| children | ca75a735651e |
line wrap: on
line diff
--- a/index.php Wed Sep 19 21:50:20 2012 +0200 +++ b/index.php Sun Sep 30 00:16:58 2012 +0200 @@ -18,37 +18,37 @@ $cacheable = true; include 'php/cache_check.inc'; +include_with_mtime('php/Options.inc'); include_with_mtime('php/accept-language.inc'); +include_with_mtime('php/common-functions.inc'); include_with_mtime('php/filters.inc'); -include_with_mtime('php/common-functions.inc'); include_with_mtime('php/inputParser.inc'); $URL_PARAMS=array('name','lang'); -#Globals -$name = $_GET['name']; -$lang = $_GET['lang']; - $master = new DOMDocument(); $master->load("master.xml"); -$params = $master->getElementsByTagName("param"); -foreach ($params as $param) { - if ($param->getAttribute("type") == "option") { - if ($param->getAttribute("id") == "lang") { - $defaultLang = $param->getAttribute("default"); - } - } +$options = new Options($master); + +$lang = $_GET['lang']; +if($lang) { + $options->setLang($lang); +} +else { + $options->setLang($options->getDefaultLang()); } -if (!$lang) { - $lang = preferLanguage($defaultLang); +$name = $_GET['name']; +if($name) { + $options->setName($name); } +$params = $master->getElementsByTagName("param"); foreach ($params as $param) { if ($param->getAttribute("type") == "input") { - $doc = getInput($master, $param); + $doc = getInput($master, $param, $options); $parent = $param->parentNode; foreach ($doc->firstChild->childNodes as $child) { @@ -56,7 +56,6 @@ $parent->insertBefore($clonedChild, $param); } $parent->removeChild($param); - } }
