Mercurial > SimpleWebPresenter
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 25:da86ec2814e2 | 26:d8c7b328899e |
|---|---|
| 16 $SCRIPT_FILENAME=$_SERVER['SCRIPT_FILENAME']; | 16 $SCRIPT_FILENAME=$_SERVER['SCRIPT_FILENAME']; |
| 17 $newest = filemtime($SCRIPT_FILENAME); | 17 $newest = filemtime($SCRIPT_FILENAME); |
| 18 $cacheable = true; | 18 $cacheable = true; |
| 19 | 19 |
| 20 include 'php/cache_check.inc'; | 20 include 'php/cache_check.inc'; |
| 21 include_with_mtime('php/Options.inc'); | |
| 21 include_with_mtime('php/accept-language.inc'); | 22 include_with_mtime('php/accept-language.inc'); |
| 23 include_with_mtime('php/common-functions.inc'); | |
| 22 include_with_mtime('php/filters.inc'); | 24 include_with_mtime('php/filters.inc'); |
| 23 include_with_mtime('php/common-functions.inc'); | |
| 24 include_with_mtime('php/inputParser.inc'); | 25 include_with_mtime('php/inputParser.inc'); |
| 25 | 26 |
| 26 $URL_PARAMS=array('name','lang'); | 27 $URL_PARAMS=array('name','lang'); |
| 27 | 28 |
| 28 #Globals | |
| 29 $name = $_GET['name']; | |
| 30 $lang = $_GET['lang']; | |
| 31 | |
| 32 $master = new DOMDocument(); | 29 $master = new DOMDocument(); |
| 33 $master->load("master.xml"); | 30 $master->load("master.xml"); |
| 34 | 31 |
| 35 $params = $master->getElementsByTagName("param"); | 32 $options = new Options($master); |
| 36 foreach ($params as $param) { | 33 |
| 37 if ($param->getAttribute("type") == "option") { | 34 $lang = $_GET['lang']; |
| 38 if ($param->getAttribute("id") == "lang") { | 35 if($lang) { |
| 39 $defaultLang = $param->getAttribute("default"); | 36 $options->setLang($lang); |
| 40 } | 37 } |
| 41 } | 38 else { |
| 39 $options->setLang($options->getDefaultLang()); | |
| 42 } | 40 } |
| 43 | 41 |
| 44 if (!$lang) { | 42 $name = $_GET['name']; |
| 45 $lang = preferLanguage($defaultLang); | 43 if($name) { |
| 44 $options->setName($name); | |
| 46 } | 45 } |
| 47 | 46 |
| 47 $params = $master->getElementsByTagName("param"); | |
| 48 | 48 |
| 49 foreach ($params as $param) { | 49 foreach ($params as $param) { |
| 50 if ($param->getAttribute("type") == "input") { | 50 if ($param->getAttribute("type") == "input") { |
| 51 $doc = getInput($master, $param); | 51 $doc = getInput($master, $param, $options); |
| 52 | 52 |
| 53 $parent = $param->parentNode; | 53 $parent = $param->parentNode; |
| 54 foreach ($doc->firstChild->childNodes as $child) { | 54 foreach ($doc->firstChild->childNodes as $child) { |
| 55 $clonedChild = $master->importNode($child, true); | 55 $clonedChild = $master->importNode($child, true); |
| 56 $parent->insertBefore($clonedChild, $param); | 56 $parent->insertBefore($clonedChild, $param); |
| 57 } | 57 } |
| 58 $parent->removeChild($param); | 58 $parent->removeChild($param); |
| 59 | |
| 60 } | 59 } |
| 61 } | 60 } |
| 62 | 61 |
| 63 if (CACHING && $cacheable) | 62 if (CACHING && $cacheable) |
| 64 print cache_check($newest); | 63 print cache_check($newest); |
