Mercurial > SimpleWebPresenter
comparison filters.inc @ 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 |
comparison
equal
deleted
inserted
replaced
| 45:6c2c6acba30c | 46:15879e2aab65 |
|---|---|
| 10 $output = preg_replace($pattern, $replacement, $input); | 10 $output = preg_replace($pattern, $replacement, $input); |
| 11 | 11 |
| 12 $pattern = '/<li id="([^"]+)"\s?([^>]*)>(.*?)<\/li>/is'; | 12 $pattern = '/<li id="([^"]+)"\s?([^>]*)>(.*?)<\/li>/is'; |
| 13 $replacement = "<li id=\"\$1\" \$2><a href=\"%URL-$1%\">\$3</a></li>"; | 13 $replacement = "<li id=\"\$1\" \$2><a href=\"%URL-$1%\">\$3</a></li>"; |
| 14 | 14 |
| 15 $opt = 'array('; | 15 $opt = repMapString($options->getUrlParams()); |
| 16 $start = True; | |
| 17 | |
| 18 foreach($options->getUrlParams() as $param => $value) { | |
| 19 if ($start) { | |
| 20 $start = False; | |
| 21 $opt .= "\"${param}\" => \"${value}\""; | |
| 22 } | |
| 23 else { | |
| 24 $opt .= ", \"${param}\" => \"${value}\""; | |
| 25 } | |
| 26 } | |
| 27 $opt .= ')'; | |
| 28 | 16 |
| 29 $output = preg_replace_callback($pattern, | 17 $output = preg_replace_callback($pattern, |
| 30 create_function( | 18 create_function( |
| 31 '$matches', | 19 '$matches', |
| 32 'return "<li id=\"$matches[1]\" $matches[2]><a href=\"" . genUrl(' . $opt . ', array("name" => $matches[1]), array("lang") ) . "\">$matches[3]</a></li>";' | 20 'return "<li id=\"$matches[1]\" $matches[2]><a href=\"" . genUrl(' . $opt . ', array("name" => $matches[1]), array("lang") ) . "\">$matches[3]</a></li>";' |
