Index: trunk/wap/hawiki/hawiki_parser_hawpedia.inc |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | /* |
4 | 4 | * hawiki parser for hawpedia |
5 | | - * $Date: 2007/04/01 23:20:25 $ |
| 5 | + * $Date$ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | function namespace_regex1($namespace_name /* english string */ , $separator='/') |
— | — | @@ -90,19 +90,29 @@ |
91 | 91 | } |
92 | 92 | |
93 | 93 | #if (preg_match("/^\[\[([^\[\]]+)\]\]/", $input, $matches)) |
94 | | - // this breaks the parser and creates "invalid wiki syntax" errors! |
95 | | - // reactivated old HawPedia regex: |
96 | | - if (preg_match("/^\[\[(([^\[\]]+)|(\[[^\[\]]*\])*|(\[\[[^\[\]]*\]\])*)+\]\]/", $input, $matches)) |
| 94 | + // this MediaWiki regex breaks the parser and creates "invalid wiki syntax" errors! |
| 95 | + #if (preg_match("/^\[\[(([^\[\]]+)|(\[[^\[\]]*\])*|(\[\[[^\[\]]*\]\])*)+\]\]/", $input, $matches)) |
| 96 | + // this old HawPedia regex does not work from php 5.2 onward! |
| 97 | + if (preg_match("/^\[\[/", $input)) |
97 | 98 | { |
98 | 99 | // Forced WikiName ((a_page_with_any_name)) |
99 | 100 | |
100 | 101 | // images can be nested like this: [[Image:...|[[link]]...]] |
101 | 102 | // or this: [[Image:...|[link]...]] |
102 | | - # echo('<blockquote>'); print_r($matches); echo('</blockquote>'); |
103 | | - $input = substr($input, strlen($matches[0])); |
| 103 | + |
| 104 | + // find closing brackets ... |
| 105 | + $bracket_level = 2; |
| 106 | + for ($pos = 2; $bracket_level > 0; $pos++) { |
| 107 | + if (substr($input, $pos, 1) == '[') |
| 108 | + $bracket_level++; |
104 | 109 | |
105 | | - $wikipage = substr($matches[0], 2, -2); |
106 | | - |
| 110 | + if (substr($input, $pos, 1) == ']') |
| 111 | + $bracket_level--; |
| 112 | + } |
| 113 | + |
| 114 | + $wikipage = substr($input, 2, $pos-4); |
| 115 | + $input = substr($input, $pos); |
| 116 | + |
107 | 117 | $po["extwiki"] = ""; // hawpedia supports no external wikis |
108 | 118 | |
109 | 119 | $link = explode("|", $wikipage); // test for alternative link label |
Property changes on: trunk/wap/hawiki/hawiki_parser_hawpedia.inc |
___________________________________________________________________ |
Added: svn:keywords |
110 | 120 | + LastChangedDate |