Index: trunk/extensions/Collection/Collection.php |
— | — | @@ -269,12 +269,23 @@ |
270 | 270 | |
271 | 271 | $wgAjaxExportList[] = 'wfAjaxCollectionAddCategory'; |
272 | 272 | |
273 | | -function wfAjaxCollectionGetBookCreatorBoxContent( $ajaxHint = '', $oldid = null ) { |
| 273 | +function wfAjaxCollectionGetBookCreatorBoxContent( $ajaxHint = '', $oldid = null, $pageName = null ) { |
| 274 | + global $wgUser; |
| 275 | + |
274 | 276 | if ( !is_null( $oldid ) ) { |
275 | 277 | $oldid = intval( $oldid ); |
276 | 278 | } |
277 | | - $html = CollectionHooks::getBookCreatorBoxContent( $ajaxHint, $oldid ); |
278 | 279 | |
| 280 | + $title = null; |
| 281 | + if ( !is_null( $pageName ) ) { |
| 282 | + $title = Title::newFromText( $pageName ); |
| 283 | + } |
| 284 | + if ( is_null( $title ) ) { |
| 285 | + $title = Title::newMainPage(); |
| 286 | + } |
| 287 | + |
| 288 | + $html = CollectionHooks::getBookCreatorBoxContent( $wgUser->getSkin(), $title, $ajaxHint, $oldid ); |
| 289 | + |
279 | 290 | $json = new Services_JSON(); |
280 | 291 | $result = array(); |
281 | 292 | $result['html'] = $html; |
Index: trunk/extensions/Collection/Collection.hooks.php |
— | — | @@ -73,8 +73,8 @@ |
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | |
77 | | - $action = $wgRequest->getVal( 'action' ); |
78 | | - if ( $action != '' && $action != 'view' && $action != 'purge' ) { |
| 77 | + $action = $wgRequest->getVal( 'action', 'view' ); |
| 78 | + if ( $action != 'view' && $action != 'purge' ) { |
79 | 79 | return false; |
80 | 80 | } |
81 | 81 | |
— | — | @@ -144,7 +144,7 @@ |
145 | 145 | global $wgOut; |
146 | 146 | if ( !$wgOut->isPrintable() ) { |
147 | 147 | $attribs = array( |
148 | | - 'href' => $wgRequest->appendQuery( 'printable=yes' ), |
| 148 | + 'href' => $sk->getTitle()->getLocalUrl( $wgRequest->appendQueryValue( 'printable', 'yes', true ) ), |
149 | 149 | 'title' => $sk->titleAttrib( 't-print', 'withaccess' ), |
150 | 150 | 'accesskey' => $sk->accesskey( 't-print' ), |
151 | 151 | ); |
— | — | @@ -168,10 +168,9 @@ |
169 | 169 | /** |
170 | 170 | * Callback for hook SiteNoticeAfter |
171 | 171 | */ |
172 | | - static function siteNoticeAfter( &$siteNotice ) { |
| 172 | + static function siteNoticeAfter( &$siteNotice, $skin = null ) { |
173 | 173 | global $wgCollectionArticleNamespaces; |
174 | 174 | global $wgRequest; |
175 | | - global $wgTitle; |
176 | 175 | |
177 | 176 | $action = $wgRequest->getVal( 'action' ); |
178 | 177 | if ( $action != '' && $action != 'view' && $action != 'purge' ) { |
— | — | @@ -184,46 +183,50 @@ |
185 | 184 | return true; |
186 | 185 | } |
187 | 186 | |
188 | | - $myTitle = SpecialPage::getTitleFor( 'Book' ); |
189 | | - if ( $myTitle->equals( $wgTitle ) ) { |
| 187 | + if ( $skin ) { |
| 188 | + $title = $skin->getTitle(); |
| 189 | + } else { |
| 190 | + global $wgTitle, $wgUser; |
| 191 | + $title = $wgTitle; |
| 192 | + $skin = $wgUser->getSkin(); |
| 193 | + } |
| 194 | + |
| 195 | + if ( $title->isSpecial( 'Book' ) ) { |
190 | 196 | $cmd = $wgRequest->getVal( 'bookcmd', '' ); |
191 | 197 | if ( $cmd == 'suggest' ) { |
192 | | - $siteNotice .= self::renderBookCreatorBox( 'suggest' ); |
| 198 | + $siteNotice .= self::renderBookCreatorBox( $title, $skin, 'suggest' ); |
193 | 199 | } else if ( $cmd == '' ) { |
194 | | - $siteNotice .= self::renderBookCreatorBox( 'showbook' ); |
| 200 | + $siteNotice .= self::renderBookCreatorBox( $title, $skin, 'showbook' ); |
195 | 201 | } |
196 | 202 | return true; |
197 | 203 | } |
198 | 204 | |
199 | | - if ( is_null( $wgTitle ) || !$wgTitle->exists() ) { |
| 205 | + if ( !$title->exists() ) { |
200 | 206 | return true; |
201 | 207 | } |
202 | 208 | |
203 | | - $namespace = $wgTitle->getNamespace(); |
| 209 | + $namespace = $title->getNamespace(); |
204 | 210 | if ( !in_array( $namespace, $wgCollectionArticleNamespaces ) |
205 | 211 | && $namespace != NS_CATEGORY ) { |
206 | 212 | return true; |
207 | 213 | } |
208 | 214 | |
209 | | - $siteNotice .= self::renderBookCreatorBox(); |
| 215 | + $siteNotice .= self::renderBookCreatorBox( $title, $skin ); |
210 | 216 | return true; |
211 | 217 | } |
212 | 218 | |
213 | | - static function renderBookCreatorBox( $mode = '' ) { |
| 219 | + static function renderBookCreatorBox( $title, $skin, $mode = '' ) { |
214 | 220 | global $wgCollectionStyleVersion; |
215 | 221 | global $wgJsMimeType; |
216 | 222 | global $wgOut; |
217 | 223 | global $wgScriptPath; |
218 | | - global $wgTitle; |
219 | | - global $wgUser; |
220 | 224 | global $wgRequest; |
221 | 225 | |
222 | | - $sk = $wgUser->getSkin(); |
223 | 226 | $jsPath = "$wgScriptPath/extensions/Collection/js"; |
224 | 227 | $imagePath = "$wgScriptPath/extensions/Collection/images"; |
225 | | - $ptext = $wgTitle->getPrefixedText(); |
| 228 | + $ptext = $title->getPrefixedText(); |
226 | 229 | $oldid = $wgRequest->getVal( 'oldid', 0 ); |
227 | | - if ( $oldid == $wgTitle->getLatestRevID() ) { |
| 230 | + if ( $oldid == $title->getLatestRevID() ) { |
228 | 231 | $oldid = 0; |
229 | 232 | } |
230 | 233 | |
— | — | @@ -252,7 +255,7 @@ |
253 | 256 | array( 'style' => 'margin-left: 90px;' ), |
254 | 257 | Xml::tags( 'div', |
255 | 258 | array( 'style' => 'float: right' ), |
256 | | - $sk->link( |
| 259 | + $skin->link( |
257 | 260 | Title::newFromText( wfMsg( 'coll-helppage' ) ), |
258 | 261 | Xml::element( 'img', |
259 | 262 | array( |
— | — | @@ -277,7 +280,7 @@ |
278 | 281 | wfMsgHtml( 'coll-book_creator' ) |
279 | 282 | ) |
280 | 283 | . ' (' |
281 | | - . $sk->link( |
| 284 | + . $skin->link( |
282 | 285 | SpecialPage::getTitleFor( 'Book' ), |
283 | 286 | wfMsgHtml( 'coll-disable' ), |
284 | 287 | array( |
— | — | @@ -295,31 +298,27 @@ |
296 | 299 | 'id' => 'coll-book_creator_box', |
297 | 300 | 'style' => 'margin-left: 90px; margin-bottom: 0;', |
298 | 301 | ), |
299 | | - self::getBookCreatorBoxContent( $addRemoveState, $oldid ) |
| 302 | + self::getBookCreatorBoxContent( $skin, $title, $addRemoveState, $oldid ) |
300 | 303 | ); |
301 | 304 | |
302 | 305 | $html .= Xml::closeElement( 'div' ); |
303 | 306 | return $html; |
304 | 307 | } |
305 | 308 | |
306 | | - static function getBookCreatorBoxContent( $ajaxHint = null, $oldid = null ) { |
307 | | - global $wgUser; |
| 309 | + static function getBookCreatorBoxContent( $skin, $title, $ajaxHint = null, $oldid = null ) { |
308 | 310 | global $wgScriptPath; |
309 | 311 | |
310 | | - $sk = $wgUser->getSkin(); |
311 | 312 | $imagePath = "$wgScriptPath/extensions/Collection/images"; |
312 | 313 | |
313 | | - return self::getBookCreatorBoxAddRemoveLink( $sk, $imagePath, $ajaxHint, $oldid ) |
314 | | - . self::getBookCreatorBoxShowBookLink( $sk, $imagePath, $ajaxHint ) |
315 | | - . self::getBookCreatorBoxSuggestLink( $sk, $imagePath, $ajaxHint ); |
| 314 | + return self::getBookCreatorBoxAddRemoveLink( $skin, $imagePath, $ajaxHint, $title, $oldid ) |
| 315 | + . self::getBookCreatorBoxShowBookLink( $skin, $imagePath, $ajaxHint ) |
| 316 | + . self::getBookCreatorBoxSuggestLink( $skin, $imagePath, $ajaxHint ); |
316 | 317 | } |
317 | 318 | |
318 | | - static function getBookCreatorBoxAddRemoveLink( $sk, $imagePath, $ajaxHint, $oldid ) { |
319 | | - global $wgTitle; |
| 319 | + static function getBookCreatorBoxAddRemoveLink( $sk, $imagePath, $ajaxHint, $title, $oldid ) { |
| 320 | + $namespace = $title->getNamespace(); |
| 321 | + $ptext = $title->getPrefixedText(); |
320 | 322 | |
321 | | - $namespace = $wgTitle->getNamespace(); |
322 | | - $ptext = $wgTitle->getPrefixedText(); |
323 | | - |
324 | 323 | if ( $ajaxHint == 'suggest' || $ajaxHint == 'showbook' ) { |
325 | 324 | return Xml::tags( 'span', |
326 | 325 | array( 'style' => 'color: #777;' ), |
— | — | @@ -341,7 +340,7 @@ |
342 | 341 | $icon = 'silk-add.png'; |
343 | 342 | $captionMsg = 'coll-add_category'; |
344 | 343 | $tooltipMsg = 'coll-add_category_tooltip'; |
345 | | - $query = array( 'bookcmd' => 'add_category', 'cattitle' => $wgTitle->getText() ); |
| 344 | + $query = array( 'bookcmd' => 'add_category', 'cattitle' => $title->getText() ); |
346 | 345 | $onclick = "collectionCall('AddCategory', ['addcategory', wgTitle]); return false;"; |
347 | 346 | } else { |
348 | 347 | if ( $ajaxHint == 'addarticle' |
Index: trunk/extensions/Collection/js/bookcreator.js |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | $.getJSON(script_url, { |
37 | 37 | 'action': 'ajax', |
38 | 38 | 'rs': 'wfAjaxCollectionGetBookCreatorBoxContent', |
39 | | - 'rsargs[]': [hint, oldid] |
| 39 | + 'rsargs[]': [hint, oldid, wgPageName] |
40 | 40 | }, function(result) { |
41 | 41 | $('#coll-book_creator_box').html(result.html); |
42 | 42 | }); |
Index: trunk/extensions/Collection/js/collection.js |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | $('#titleInput').val(''); |
96 | 96 | $('#subtitleInput').val(''); |
97 | 97 | refresh_list(result); |
98 | | - req('GetBookCreatorBoxContent', ['showbook', null], function(result2) { |
| 98 | + req('GetBookCreatorBoxContent', ['showbook', null, wgPageName], function(result2) { |
99 | 99 | $('#coll-book_creator_box').html(result2.html); |
100 | 100 | }); |
101 | 101 | }); |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | [index], |
127 | 127 | function(result) { |
128 | 128 | refresh_list(result); |
129 | | - req('GetBookCreatorBoxContent', ['showbook', null], function(result2) { |
| 129 | + req('GetBookCreatorBoxContent', ['showbook', null, wgPageName], function(result2) { |
130 | 130 | $('#coll-book_creator_box').html(result2.html); |
131 | 131 | }); |
132 | 132 | }); |
Index: trunk/extensions/Collection/js/suggest.js |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | $.getJSON(script_url, { |
32 | 32 | 'action': 'ajax', |
33 | 33 | 'rs': 'wfAjaxCollectionGetBookCreatorBoxContent', |
34 | | - 'rsargs[]': ['suggest', null] |
| 34 | + 'rsargs[]': ['suggest', null, wgPageName] |
35 | 35 | }, function(result) { |
36 | 36 | $('#coll-book_creator_box').html(result.html); |
37 | 37 | }); |
Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -44,7 +44,6 @@ |
45 | 45 | global $wgUser; |
46 | 46 | global $wgContLang; |
47 | 47 | global $wgCollectionMaxArticles; |
48 | | - global $wgTitle; |
49 | 48 | |
50 | 49 | // support previous URLs (e.g. used in templates) which used the "$par" part |
51 | 50 | // (i.e. subpages of the Special page) |
— | — | @@ -61,7 +60,7 @@ |
62 | 61 | |
63 | 62 | switch ( $wgRequest->getVal( 'bookcmd', '' ) ) { |
64 | 63 | case 'book_creator': |
65 | | - $this->renderBookCreatorPage( $wgRequest->getVal( 'referer', '' ) ); |
| 64 | + $this->renderBookCreatorPage( $wgRequest->getVal( 'referer', '' ), $par ); |
66 | 65 | return; |
67 | 66 | |
68 | 67 | case 'start_book_creator': |
— | — | @@ -74,7 +73,7 @@ |
75 | 74 | return; |
76 | 75 | case 'stop_book_creator': |
77 | 76 | $title = Title::newFromText( $wgRequest->getVal( 'referer', '' ) ); |
78 | | - if ( is_null( $title ) || $title->equals( $wgTitle ) ) { |
| 77 | + if ( is_null( $title ) || $title->equals( $this->getTitle( $par ) ) ) { |
79 | 78 | $title = Title::newMainPage(); |
80 | 79 | } |
81 | 80 | if ( $wgRequest->getVal( 'disable' ) ) { |
— | — | @@ -305,11 +304,10 @@ |
306 | 305 | return; |
307 | 306 | } |
308 | 307 | |
309 | | - function renderBookCreatorPage( $referer ) { |
| 308 | + function renderBookCreatorPage( $referer, $par ) { |
310 | 309 | global $wgCollectionStyleVersion; |
311 | 310 | global $wgOut; |
312 | 311 | global $wgScriptPath; |
313 | | - global $wgTitle; |
314 | 312 | global $wgUser; |
315 | 313 | global $wgJsMimeType; |
316 | 314 | |
— | — | @@ -332,7 +330,7 @@ |
333 | 331 | "</script>" ); |
334 | 332 | |
335 | 333 | $title = Title::newFromText( $referer ); |
336 | | - if ( is_null( $title ) || $title->equals( $wgTitle ) ) { |
| 334 | + if ( is_null( $title ) || $title->equals( $this->getTitle( $par ) ) ) { |
337 | 335 | $title = Title::newMainPage(); |
338 | 336 | } |
339 | 337 | $sk = $wgUser->getSkin(); |
Index: trunk/extensions/Collection/Collection.templates.php |
— | — | @@ -84,11 +84,7 @@ |
85 | 85 | if ( $t && $t->exists() ) { ?> |
86 | 86 | <div id="coll-order_info" style="display:none; margin-top: 2em;"> |
87 | 87 | <?php |
88 | | -echo $GLOBALS['wgParser']->parse( '{{:' . $t . '}}', |
89 | | - $GLOBALS['wgTitle'], |
90 | | - $GLOBALS['wgOut']->parserOptions(), |
91 | | - true |
92 | | -)->getText(); |
| 88 | +echo $GLOBALS['wgOut']->parse( '{{:' . $t . '}}' ); |
93 | 89 | ?> |
94 | 90 | </div> |
95 | 91 | <?php } ?> |
— | — | @@ -98,12 +94,7 @@ |
99 | 95 | <h2><span class="mw-headline"><?php $this->msg( 'coll-download_title' ) ?></span></h2> |
100 | 96 | <?php if ( count( $this->data['formats'] ) == 1 ) { |
101 | 97 | $writer = array_rand( $this->data['formats'] ); |
102 | | - echo $GLOBALS['wgParser']->parse( |
103 | | - wfMsgNoTrans( 'coll-download_as_text', $this->data['formats'][$writer] ), |
104 | | - $GLOBALS['wgTitle'], |
105 | | - $GLOBALS['wgOut']->parserOptions(), |
106 | | - true |
107 | | - )->getText(); |
| 98 | + echo wfMsgExt( 'coll-download_as_text', 'parse', $this->data['formats'][$writer] ); |
108 | 99 | $buttonLabel = wfMsgHtml( 'coll-download_as', htmlspecialchars( $this->data['formats'][$writer] ) ); |
109 | 100 | } else { |
110 | 101 | $this->msgWiki( 'coll-download_text' ); |
— | — | @@ -322,7 +313,7 @@ |
323 | 314 | |
324 | 315 | <h2><span class="mw-headline"><?php $this->msg( 'coll-overwrite_title' ) ?></span></h2> |
325 | 316 | |
326 | | -<p><?php echo $GLOBALS['wgParser']->parse( wfMsgNoTrans( 'coll-overwrite_text', $this->data['title']->getPrefixedText() ), $GLOBALS['wgTitle'], $GLOBALS['wgOut']->parserOptions(), true )->getText() ?></p> |
| 317 | +<p><?php echo wfMsgExt( 'coll-overwrite_text', 'parse', $this->data['title']->getPrefixedText() ); ?></p> |
327 | 318 | |
328 | 319 | <form action="<?php echo htmlspecialchars( SkinTemplate::makeSpecialUrl( 'Book' ) ) ?>" method="post"> |
329 | 320 | <input name="overwrite" type="submit" value="<?php $this->msg( 'coll-yes' ) ?>" /> |
— | — | @@ -361,11 +352,7 @@ |
362 | 353 | } |
363 | 354 | $t = Title::newFromText( $title_string ); |
364 | 355 | if ( $t && $t->exists() ) { |
365 | | - echo $GLOBALS['wgParser']->parse( '{{:' . $t . '}}', |
366 | | - $GLOBALS['wgTitle'], |
367 | | - $GLOBALS['wgOut']->parserOptions(), |
368 | | - true |
369 | | - )->getText(); |
| 356 | + echo $GLOBALS['wgOut']->parse( '{{:' . $t . '}}' ); |
370 | 357 | } |
371 | 358 | } |
372 | 359 | } |
— | — | @@ -377,32 +364,17 @@ |
378 | 365 | class CollectionFinishedTemplate extends QuickTemplate { |
379 | 366 | function execute() { |
380 | 367 | |
381 | | -echo $GLOBALS['wgParser']->parse( |
382 | | - wfMsgNoTrans( 'coll-rendering_finished_text', $this->data['download_url'] ), |
383 | | - $GLOBALS['wgTitle'], |
384 | | - $GLOBALS['wgOut']->parserOptions(), |
385 | | - true |
386 | | -)->getText(); |
| 368 | +echo wfMsgExt( 'coll-rendering_finished_text', 'parse', $this->data['download_url'] ); |
387 | 369 | |
388 | 370 | if ( $this->data['is_cached'] ) { |
389 | 371 | $forceRenderURL = SkinTemplate::makeSpecialUrl( 'Book', 'bookcmd=forcerender&' . $this->data['query'] ); |
390 | 372 | echo wfMsg( 'coll-is_cached', htmlspecialchars( $forceRenderURL ) ); |
391 | 373 | } |
392 | | -echo $GLOBALS['wgParser']->parse( |
393 | | - wfMsgNoTrans( 'coll-excluded-templates', wfMsgForContent( 'coll-exclusion_category_title' ) ), |
394 | | - $GLOBALS['wgTitle'], |
395 | | - $GLOBALS['wgOut']->parserOptions(), |
396 | | - true |
397 | | -)->getText(); |
| 374 | +echo wfMsgExt( 'coll-excluded-templates', 'parse', wfMsgForContent( 'coll-exclusion_category_title' ) ); |
398 | 375 | $title_string = wfMsgForContent( 'coll-template_blacklist_title' ); |
399 | 376 | $t = Title::newFromText( $title_string ); |
400 | 377 | if ( $t && $t->exists() ) { |
401 | | - echo $GLOBALS['wgParser']->parse( |
402 | | - wfMsgNoTrans( 'coll-blacklisted-templates', $title_string ), |
403 | | - $GLOBALS['wgTitle'], |
404 | | - $GLOBALS['wgOut']->parserOptions(), |
405 | | - true |
406 | | - )->getText(); |
| 378 | + echo wfMsgExt( 'coll-blacklisted-templates', 'parse', $title_string ); |
407 | 379 | } |
408 | 380 | if ( $this->data['return_to'] ) { |
409 | 381 | // We are doing this the hard way (i.e. via the HTML detour), to prevent |
— | — | @@ -422,11 +394,7 @@ |
423 | 395 | } |
424 | 396 | $t = Title::newFromText( $title_string ); |
425 | 397 | if ( $t && $t->exists() ) { |
426 | | - echo $GLOBALS['wgParser']->parse( '{{:' . $t . '}}', |
427 | | - $GLOBALS['wgTitle'], |
428 | | - $GLOBALS['wgOut']->parserOptions(), |
429 | | - true |
430 | | - )->getText(); |
| 398 | + echo $GLOBALS['wgOut']->parse( '{{:' . $t . '}}' ); |
431 | 399 | } |
432 | 400 | ?> |
433 | 401 | |