Mercurial > SimpleWebPresenter
changeset 35:aec57ed6f5f6
Remove globals from activeNav function.
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Thu, 04 Oct 2012 21:18:40 +0200 |
| parents | ca76d31b7d48 |
| children | c3a61615a39c |
| files | Options.inc filters.inc |
| diffstat | 2 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Options.inc Thu Oct 04 21:05:49 2012 +0200 +++ b/Options.inc Thu Oct 04 21:18:40 2012 +0200 @@ -7,7 +7,7 @@ private $acceptedLanguages = array(); private $inputDefaults = array(); private $cache; - private $urlParams; + private $urlParams = array(); function getDefaultLang() { @@ -26,7 +26,12 @@ function setUrlParams($urlParams) { - $this->urlParams = $urlParams; + foreach($urlParams as $key) { + $value = $_GET[$key]; + if (!$value) + $value = ''; + $this->urlParams[$key] = $value; + } } function getUrlParams()
--- a/filters.inc Thu Oct 04 21:05:49 2012 +0200 +++ b/filters.inc Thu Oct 04 21:18:40 2012 +0200 @@ -1,8 +1,8 @@ <?php function activeNav($input, $options) { - $name = $GLOBALS['name']; - $lang = $GLOBALS['lang']; + $name = $options->getName(); + $lang = $options->getLang(); $pattern = "/<li id=\"${name}\"\s?([^>]*)>/is"; $replacement = "<li id=\"${name}\" class=\"active\" $1>"; $output = preg_replace($pattern, $replacement, $input); @@ -13,8 +13,7 @@ $opt = 'array('; $start = True; - foreach($options->getUrlParams() as $param) { - $value = $GLOBALS[$param]; + foreach($options->getUrlParams() as $param => $value) { if ($start) { $start = False; $opt .= "\"${param}\" => \"${value}\"";
