Mercurial > SimpleWebPresenter
changeset 46:15879e2aab65
Function for converting a stringmap to EVALable function.
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Mon, 08 Oct 2012 15:49:28 +0200 |
| parents | 6c2c6acba30c |
| children | 66382989353f |
| files | common-functions.inc filters.inc |
| diffstat | 2 files changed, 19 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/common-functions.inc Mon Oct 08 02:02:09 2012 +0200 +++ b/common-functions.inc Mon Oct 08 15:49:28 2012 +0200 @@ -4,6 +4,24 @@ $cache = CacheTimeCheck::instance(__FILE__); $cache->includeOnce('http-response-status-codes.inc', dirname(__FILE__)); +function repMapString($map) +{ + $opt = 'array('; + $start = True; + + foreach($map as $param => $value) { + if ($start) { + $start = False; + $opt .= "\"${param}\" => \"${value}\""; + } + else { + $opt .= ", \"${param}\" => \"${value}\""; + } + } + $opt .= ')'; + return $opt; +} + function basePath() { $l = strrpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['SCRIPT_NAME']);
--- a/filters.inc Mon Oct 08 02:02:09 2012 +0200 +++ b/filters.inc Mon Oct 08 15:49:28 2012 +0200 @@ -12,19 +12,7 @@ $pattern = '/<li id="([^"]+)"\s?([^>]*)>(.*?)<\/li>/is'; $replacement = "<li id=\"\$1\" \$2><a href=\"%URL-$1%\">\$3</a></li>"; - $opt = 'array('; - $start = True; - - foreach($options->getUrlParams() as $param => $value) { - if ($start) { - $start = False; - $opt .= "\"${param}\" => \"${value}\""; - } - else { - $opt .= ", \"${param}\" => \"${value}\""; - } - } - $opt .= ')'; + $opt = repMapString($options->getUrlParams()); $output = preg_replace_callback($pattern, create_function(
