Mercurial > SimpleWebPresenter
comparison filters.inc @ 4:74196528fc64
Refac to use xml as input, and remove filters and helper-functions from
main script.
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Thu, 19 May 2011 18:04:33 +0200 |
| parents | |
| children | 18aafb1a8986 |
comparison
equal
deleted
inserted
replaced
| 3:238c5127b78c | 4:74196528fc64 |
|---|---|
| 1 <?php | |
| 2 function activeNav($input, $name, $lang) | |
| 3 { | |
| 4 $pattern = "/<li id=\"${name}\"\s?([^>]*)>/is"; | |
| 5 $replacement = "<li id=\"${name}\" class=\"active\" $1>"; | |
| 6 $output= preg_replace($pattern, $replacement, $input); | |
| 7 | |
| 8 $pattern = '/<li id="([^"]+)"\s?([^>]*)>(.*?)<\/li>/is'; | |
| 9 $replacement = "<li id=\"\$1\" \$2><a href=\"?name=$1&lang=${lang}\">\$3</a></li>"; | |
| 10 $output=preg_replace($pattern, $replacement, $output); | |
| 11 | |
| 12 return $output; | |
| 13 } | |
| 14 | |
| 15 function addLangBar($input, $lang) { | |
| 16 $languages = array("no","en"); | |
| 17 $langbar='<ul id="language-select">'; | |
| 18 | |
| 19 foreach($languages as $l) { | |
| 20 $active=($l == $lang)?1:0; | |
| 21 $langbar.= " | |
| 22 <li class=\"${l}\"> | |
| 23 <img src=\"http://dev.bfginvest.no/php/flag.php?lang=${l}&active=${active}\" width=\"20\" height=\"16\" alt=\"Norsk versjon - inaktiv\" title=\"Norsk\"/> | |
| 24 </li> | |
| 25 "; | |
| 26 | |
| 27 } | |
| 28 $langbar.='</ul>'; | |
| 29 $pattern = '/<ul id="language-select"\/>/'; | |
| 30 $replacement = $langbar; | |
| 31 $output=preg_replace($pattern, $replacement, $input); | |
| 32 | |
| 33 return $output; | |
| 34 } | |
| 35 ?> |
