Index: branches/wikidata/phase3/includes/SpecialNamespaces.php |
— | — | @@ -1,103 +1,102 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * |
5 | | - * @package MediaWiki |
6 | | - * @subpackage SpecialPage |
7 | | - */ |
| 4 | +* |
| 5 | +* @package MediaWiki |
| 6 | +* @subpackage SpecialPage |
| 7 | +*/ |
8 | 8 | |
9 | 9 | /** |
10 | | - * Constructor |
11 | | - */ |
| 10 | +* Constructor |
| 11 | +*/ |
12 | 12 | function wfSpecialNamespaces() |
13 | 13 | { |
14 | | - global $wgUser, $wgOut, $wgRequest; |
| 14 | +global $wgUser, $wgOut, $wgRequest; |
15 | 15 | |
16 | | - $action = $wgRequest->getVal( 'action' ); |
17 | | - $f = new NamespaceForm(); |
| 16 | +$action = $wgRequest->getVal( 'action' ); |
| 17 | +$f = new NamespaceForm(); |
18 | 18 | |
19 | | - if ( $action == 'submit' && $wgRequest->wasPosted() && |
20 | | - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
21 | | - if($wgRequest->getText('nsAction')=='addnamespaces') { |
22 | | - $f->addNamespaces(); |
23 | | - } elseif($wgRequest->getText('nsAction')=='changenamespaces') { |
24 | | - $f->changeNamespaces(); |
25 | | - } |
26 | | - } elseif($action == 'delete') { |
27 | | - |
28 | | - $f->deleteNamespace(); |
| 19 | +if ( $action == 'submit' && $wgRequest->wasPosted() && |
| 20 | + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 21 | + if($wgRequest->getText('nsAction')=='addnamespaces') { |
| 22 | + $f->addNamespaces(); |
| 23 | + } elseif($wgRequest->getText('nsAction')=='changenamespaces') { |
| 24 | + $f->changeNamespaces(); |
29 | 25 | } |
30 | | - else { |
31 | | - $f->showForm(); |
32 | | - } |
| 26 | +} elseif($action == 'delete') { |
| 27 | + |
| 28 | + $f->deleteNamespace(); |
33 | 29 | } |
| 30 | +else { |
| 31 | + $f->showForm(); |
| 32 | +} |
| 33 | +} |
34 | 34 | |
35 | 35 | /** |
36 | | - * |
37 | | - * @package MediaWiki |
38 | | - * @subpackage SpecialPage |
39 | | - */ |
| 36 | +* |
| 37 | +* @package MediaWiki |
| 38 | +* @subpackage SpecialPage |
| 39 | +*/ |
40 | 40 | class NamespaceForm { |
| 41 | + |
| 42 | +function showForm( $errorHeader='', $errorBody='' ) |
| 43 | +{ |
| 44 | + global $wgOut, $wgUser, $wgLang, $wgNamespaces,$wgTitle; |
41 | 45 | |
42 | | - function showForm( $errorHeader='', $errorBody='' ) |
43 | | - { |
44 | | - global $wgOut, $wgUser, $wgLang, $wgNamespaces,$wgTitle; |
45 | | - |
46 | | - $wgOut->setPagetitle( wfMsg( "namespaces" ) ); |
| 46 | + $wgOut->setPagetitle( wfMsg( "namespaces" ) ); |
47 | 47 | |
48 | | - /* In case of an error, we generally just show what went wrong |
49 | | - and continue displaying the main form */ |
50 | | - if ( '' != $errorHeader ) { |
51 | | - $wgOut->setSubtitle( wfMsg( "transactionerror" ) ); |
52 | | - $wgOut->addHTML( "<p class='error'>".htmlspecialchars($errorHeader)."</P>"); |
53 | | - if($errorBody) { |
54 | | - $wgOut->addWikiText($errorBody); |
55 | | - } |
| 48 | + /* In case of an error, we generally just show what went wrong |
| 49 | + and continue displaying the main form */ |
| 50 | + if ( '' != $errorHeader ) { |
| 51 | + $wgOut->setSubtitle( wfMsg( "transactionerror" ) ); |
| 52 | + $wgOut->addHTML( "<p class='error'>".htmlspecialchars($errorHeader)."</P>"); |
| 53 | + if($errorBody) { |
| 54 | + $wgOut->addWikiText($errorBody); |
56 | 55 | } |
57 | | - |
58 | | - # Standard token to avoid remote form submission exploits |
59 | | - $token = $wgUser->editToken(); |
60 | | - $action = $wgTitle->escapeLocalURL( "action=submit" ); |
61 | | - $talksuffix = wfEscapeJsString(wfMsgForContent("talkpagesuffix")); |
62 | | - |
63 | | - # For the namespace selection box |
64 | | - $name_array= Namespace::getFormattedDefaultNamespaces(); |
65 | | - $noparent=wfMsg('no_parent_namespace'); |
66 | | - $name_array[key($name_array)-1]=$noparent; |
67 | | - # Sort for foreach loops |
68 | | - ksort($name_array); |
| 56 | + } |
| 57 | + |
| 58 | + # Standard token to avoid remote form submission exploits |
| 59 | + $token = $wgUser->editToken(); |
| 60 | + $action = $wgTitle->escapeLocalURL( "action=submit" ); |
| 61 | + $talksuffix = wfEscapeJsString(wfMsgForContent("talkpagesuffix")); |
| 62 | + |
| 63 | + # For the namespace selection box |
| 64 | + $name_array= Namespace::getFormattedDefaultNamespaces(); |
| 65 | + $noparent=wfMsg('no_parent_namespace'); |
| 66 | + $name_array[key($name_array)-1]=$noparent; |
| 67 | + # Sort for foreach loops |
| 68 | + ksort($name_array); |
69 | 69 | |
70 | | - $wgOut->addWikiText( wfMsg( "add_namespaces_header" ) ); |
71 | | - # Prefill talk namespace field, but only for languages |
72 | | - # where it's not disabled |
73 | | - if($talksuffix != '-') { |
74 | | - $talkpagejs= |
| 70 | + $wgOut->addWikiText( wfMsg( "add_namespaces_header" ) ); |
| 71 | + # Prefill talk namespace field, but only for languages |
| 72 | + # where it's not disabled |
| 73 | + if($talksuffix != '-') { |
| 74 | + $talkpagejs= |
75 | 75 | ' onchange="if(!window.document.addnamespaces.nsTalkName.value && window.document.addnamespaces.nsName.value && window.document.addnamespaces.nsCreateTalk.checked) { window.document.addnamespaces.nsTalkName.value=window.document.addnamespaces.nsName.value+\''.$talksuffix.'\'; }"'; |
76 | 76 | |
77 | | - } else { |
78 | | - $talkpagejs=''; |
79 | | - } |
| 77 | + } else { |
| 78 | + $talkpagejs=''; |
| 79 | + } |
80 | 80 | |
81 | | - $addnshtmlform=' |
82 | | -<form name="addnamespaces" method="POST" action="'.$action.'"> |
| 81 | + $addnshtmlform=' |
| 82 | +<form name="addnamespaces" method="post" action="'.$action.'"> |
83 | 83 | <table border="0"> |
84 | 84 | <tr valign="top"><td> |
85 | 85 | '.wfMsg('add_namespace_default_name').'</td> |
86 | 86 | <td> |
87 | | -<input type="hidden" name="nsAction" value="addnamespaces"> |
88 | | -<input type="text" name="nsName" size="20"'.$talkpagejs.'> |
| 87 | +<input type="hidden" name="nsAction" value="addnamespaces" /> |
| 88 | +<input type="text" name="nsName" size="20"'.$talkpagejs.' /> |
89 | 89 | </td> |
90 | 90 | </tr> |
91 | 91 | <tr valign="top"> |
92 | 92 | <td> |
93 | | -'.wfMsg('add_namespace_default_talk').'<br> |
| 93 | +'.wfMsg('add_namespace_default_talk').'<br /> |
94 | 94 | </td> |
95 | | -<td> |
96 | | -<input type="text" name="nsTalkName" size="20"> |
| 95 | +<td><input type="text" name="nsTalkName" size="20" /> |
97 | 96 | </td> |
98 | 97 | </tr> |
99 | 98 | <tr> |
100 | 99 | <td colspan="2"> |
101 | | -<label><input type="checkbox" name="nsCreateTalk" checked> |
| 100 | +<label><input type="checkbox" name="nsCreateTalk" checked /> |
102 | 101 | '.wfMsg('add_namespace_talk_confirm').' |
103 | 102 | </label> |
104 | 103 | </td> |
— | — | @@ -126,8 +125,8 @@ |
127 | 126 | $namespace_save_changes=wfMsg('namespace_save_changes'); |
128 | 127 | |
129 | 128 | $htmlform=<<<END |
130 | | -<form name="changenamespaces" method="POST" action="{$action}"> |
131 | | -<input type="hidden" name="nsAction" value="changenamespaces"> |
| 129 | +<form name="changenamespaces" method="post" action="{$action}"> |
| 130 | +<input type="hidden" name="nsAction" value="changenamespaces" /> |
132 | 131 | <input type="hidden" name="wpEditToken" value="{$token}" /> |
133 | 132 | END; |
134 | 133 | foreach ($wgNamespaces as $ns) { |
— | — | @@ -158,7 +157,7 @@ |
159 | 158 | } |
160 | 159 | $namespaceselect_html=<<<END |
161 | 160 | <tr valign="top"><td colspan="2"> |
162 | | -{$namespace_child_of}<br> |
| 161 | +{$namespace_child_of}<br /> |
163 | 162 | <select name="ns{$index}Parent" size="1"> |
164 | 163 | {$namespaceselect} |
165 | 164 | </select> |
— | — | @@ -170,7 +169,7 @@ |
171 | 170 | {$namespace_support_subpages} |
172 | 171 | </td> |
173 | 172 | <td align="right"> |
174 | | -<input type="checkbox" name="ns{$index}Subpages" {$subpages}> |
| 173 | +<input type="checkbox" name="ns{$index}Subpages" {$subpages} /> |
175 | 174 | </td> |
176 | 175 | </tr> |
177 | 176 | END; |
— | — | @@ -179,7 +178,7 @@ |
180 | 179 | {$namespace_search_by_default} |
181 | 180 | </td> |
182 | 181 | <td align="right"> |
183 | | -<input type="checkbox" name="ns{$index}Search" {$searchdefault}> |
| 182 | +<input type="checkbox" name="ns{$index}Search" {$searchdefault} /> |
184 | 183 | </td> |
185 | 184 | </tr> |
186 | 185 | END; |
— | — | @@ -188,7 +187,7 @@ |
189 | 188 | {$namespace_hide_in_lists} |
190 | 189 | </td> |
191 | 190 | <td align="right"> |
192 | | -<input type="checkbox" name="ns{$index}Hidden" {$hidden}> |
| 191 | +<input type="checkbox" name="ns{$index}Hidden" {$hidden} /> |
193 | 192 | </td> |
194 | 193 | </tr> |
195 | 194 | END; |
— | — | @@ -197,7 +196,7 @@ |
198 | 197 | {$namespace_default_link_prefix} |
199 | 198 | </td> |
200 | 199 | <td align="right"> |
201 | | -<input type="text" size="10" name="ns{$index}Linkprefix" value="{$linkprefix}"> |
| 200 | +<input type="text" size="10" name="ns{$index}Linkprefix" value="{$linkprefix}" /> |
202 | 201 | </td> |
203 | 202 | </tr> |
204 | 203 | END; |
— | — | @@ -296,13 +295,13 @@ |
297 | 296 | } else { |
298 | 297 | $dc=""; |
299 | 298 | } |
300 | | - $default = "<input type=\"radio\" name=\"ns{$index}Default\" value=\"{$nsi}\"{$dc}>"; |
| 299 | + $default = "<input type=\"radio\" name=\"ns{$index}Default\" value=\"{$nsi}\"{$dc} />"; |
301 | 300 | if (!is_null($ns->getCanonicalNameIndex()) &&$ns->getCanonicalNameIndex()== $nsi) { |
302 | 301 | $nameinput = $nsname . '<br/><small>'.wfMsg('canonicalname').'</small>'; |
303 | 302 | $delete = 'N/A'; |
304 | 303 | } else { |
305 | | - $nameinput = "<input name=\"ns{$index}Name{$nsi}\" size=\"20\" value=\"{$nsname}\">"; |
306 | | - $delete = "<input name=\"ns{$index}Delete{$nsi}\" type=\"checkbox\" value=\"1\">"; |
| 304 | + $nameinput = "<input name=\"ns{$index}Name{$nsi}\" size=\"20\" value=\"{$nsname}\" />"; |
| 305 | + $delete = "<input name=\"ns{$index}Delete{$nsi}\" type=\"checkbox\" value=\"1\" />"; |
307 | 306 | } |
308 | 307 | $htmlform.= |
309 | 308 | <<<END |
— | — | @@ -333,10 +332,10 @@ |
334 | 333 | <<<END |
335 | 334 | <tr valign="top"> |
336 | 335 | <td width="300"> |
337 | | -<input name="ns{$index}NewName{$i}" size="20" value=""> |
| 336 | +<input name="ns{$index}NewName{$i}" size="20" value="" /> |
338 | 337 | </td> |
339 | 338 | <td align="center"> |
340 | | -<input type="radio" name="ns{$index}Default" value="{$i}"> |
| 339 | +<input type="radio" name="ns{$index}Default" value="{$i}" /> |
341 | 340 | </td> |
342 | 341 | <td align="center"> |
343 | 342 | |
— | — | @@ -345,12 +344,12 @@ |
346 | 345 | END; |
347 | 346 | } |
348 | 347 | $htmlform .= '</table></td></tr>'; |
349 | | - $htmlform .= '<tr><td colspan="2"><hr noshade></td></tr>'; |
| 348 | + $htmlform .= '<tr><td colspan="2"><hr noshade /></td></tr>'; |
350 | 349 | } |
351 | 350 | $htmlform.= |
352 | 351 | <<<END |
353 | 352 | <tr><td> |
354 | | -<input type="submit" value="{$namespace_save_changes}"> |
| 353 | +<input type="submit" value="{$namespace_save_changes}" /> |
355 | 354 | </td></tr> |
356 | 355 | </table> |
357 | 356 | </form> |