Index: trunk/extensions/LabeledSectionTransclusion/lst.php |
— | — | @@ -42,8 +42,24 @@ |
43 | 43 | |
44 | 44 | /// Add the magic words - possibly with more readable aliases |
45 | 45 | function wfLabeledSectionTransclusionMagic( &$magicWords, $langCode ) { |
46 | | - $magicWords['lst'] = array( 0, 'lst', 'section' ); |
47 | | - $magicWords['lstx'] = array( 0, 'lstx', 'section-x' ); |
| 46 | + global $wgParser, $wgLstLocal; |
| 47 | + |
| 48 | + switch ($langCode) { |
| 49 | + case 'de': |
| 50 | + $include = 'steil'; |
| 51 | + $exclude = 'steil-x'; |
| 52 | + $wgLstLocal=array('section'=>'steil', 'begin'=>'anfang', 'end'=>'ende'); |
| 53 | + } |
| 54 | + |
| 55 | + if (isset($include)) { |
| 56 | + $magicWords['lst'] = array( 0, 'lst', 'section', $include ); |
| 57 | + $magicWords['lstx'] = array( 0, 'lstx', 'section-x', $exclude ); |
| 58 | + $wgParser->setHook( $include, 'wfLstNoop' ); |
| 59 | + } else { |
| 60 | + $magicWords['lst'] = array( 0, 'lst', 'section' ); |
| 61 | + $magicWords['lstx'] = array( 0, 'lstx', 'section-x' ); |
| 62 | + } |
| 63 | + |
48 | 64 | return true; |
49 | 65 | } |
50 | 66 | |
— | — | @@ -141,13 +157,25 @@ |
142 | 158 | */ |
143 | 159 | function wfLst_pat_($sec, $to) |
144 | 160 | { |
| 161 | + global $wgLstLocal; |
| 162 | + |
145 | 163 | $to_sec = ($to == '')?$sec : $to; |
146 | 164 | $sec = preg_quote($sec, '/'); |
147 | 165 | $to_sec = preg_quote($to_sec, '/'); |
148 | 166 | $ws="(?:\s+[^>]+)?"; //was like $ws="\s*" |
149 | | - return "/<section$ws\s+(?i:begin)=". |
| 167 | + if (isset($wgLstLocal)){ |
| 168 | + $begin="(?i:begin|$wgLstLocal[begin])"; |
| 169 | + $end="(?i:end|$wgLstLocal[end])"; |
| 170 | + $section_re = "(?:section|$wgLstLocal[section])"; |
| 171 | + } else { |
| 172 | + $begin="(?i:begin)"; |
| 173 | + $end="(?i:end)"; |
| 174 | + $section_re = "section"; |
| 175 | + } |
| 176 | + |
| 177 | + return "/<$section_re$ws\s+$begin=". |
150 | 178 | "(?:$sec|\"$sec\"|'$sec')". |
151 | | - "$ws\/?>(.*?)\n?<section$ws\s+(?:[^>]+\s+)?(?i:end)=". |
| 179 | + "$ws\/?>(.*?)\n?<$section_re$ws\s+(?:[^>]+\s+)?$end=". |
152 | 180 | "(?:$to_sec|\"$to_sec\"|'$to_sec')". |
153 | 181 | "$ws\/?>/s"; |
154 | 182 | } |