r51877 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51876‎ | r51877 | r51878 >
Date:10:32, 15 June 2009
Author:jojo
Status:ok
Tags:
Comment:
fix escaping/quoting. shorten code by using Xml::encodeJsVar() and Skin::makeVariablesScript()
Modified paths:
  • /trunk/extensions/Collection/Collection.hooks.php (modified) (history)
  • /trunk/extensions/Collection/collection/popup.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.hooks.php
@@ -263,7 +263,7 @@
264264 array( 'known', 'noclasses' )
265265 )
266266 );
267 - $msg = htmlspecialchars( wfMsg( 'coll-clear_collection_confirm' ) );
 267+ $msg = Xml::encodeJsVar( wfMsg( 'coll-clear_collection_confirm' ) );
268268 $out .= Xml::tags(
269269 'li',
270270 array( 'id' => 'coll-clear_collection' ),
@@ -271,7 +271,7 @@
272272 SpecialPage::getTitleFor( 'Book', 'clear_collection/' ),
273273 wfMsgHtml( "coll-clear_collection" ),
274274 array(
275 - 'onclick' => "if (confirm('$msg')) return true; else return false;",
 275+ 'onclick' => "if (confirm($msg)) return true; else return false;",
276276 'rel' => 'nofollow',
277277 'title' => wfMsg( "coll-clear_collection_tooltip" )
278278 ),
@@ -293,10 +293,8 @@
294294 )
295295 );
296296 $out .= '</ul>';
297 - $out .= Xml::element(
298 - 'script',
299 - array( 'type' => $wgJsMimeType ),
300 - "wgCollectionAddRemoveState = '$addRemoveState';"
 297+ $out .= Skin::makeVariablesScript(
 298+ array( 'wgCollectionAddRemoveSate' => $addRemoveSate )
301299 );
302300 $out .= Xml::element(
303301 'script',
@@ -310,24 +308,16 @@
311309
312310 // activate popup check:
313311 if ( $wgCollectionNavPopups ) {
314 - $addPageText = htmlspecialchars( wfMsg( 'coll-add_page_popup' ), $quote_style=ENT_QUOTES );
315 - $addCategoryText = htmlspecialchars( wfMsg( 'coll-add_category_popup', $quote_style=ENT_QUOTES ) );
316 - $removePageText = htmlspecialchars( wfMsg( 'coll-remove_page_popup', $quote_style=ENT_QUOTES ) );
317 - $popupHelpText = htmlspecialchars( wfMsg( 'coll-popup_help_text', $quote_style=ENT_QUOTES ) );
318 -
319 - $out .= Xml::element( 'script',
 312+ $out .= Skin::makeVariablesScript(
320313 array(
321 - 'type' => $wgJsMimeType,
322 - ),
323 - "wgCollectionNavPopupJSURL = '$wgScriptPath/extensions/Collection/collection/Gadget-popups.js?$wgCollectionStyleVersion';
324 - wgCollectionNavPopupCSSURL = '$wgScriptPath/extensions/Collection/collection/Gadget-navpop.css?$wgCollectionStyleVersion';
325 - wgCollectionAddPageText = '$addPageText';
326 - wgCollectionAddCategoryText = '$addCategoryText';
327 - wgCollectionRemovePageText = '$removePageText';
328 - wgCollectionPopupHelpText = '$popupHelpText';
329 - wgCollectionArticleNamespaces = [ "
330 - . implode( ', ', $wgCollectionArticleNamespaces )
331 - . "];"
 314+ 'wgCollectionNavPopupJSURL' => "$wgScriptPath/extensions/Collection/collection/Gadget-popups.js?$wgCollectionStyleVersion",
 315+ 'wgCollectionNavPopupCSSURL' => "$wgScriptPath/extensions/Collection/collection/Gadget-navpop.css?$wgCollectionStyleVersion",
 316+ 'wgCollectionAddPageText' => wfMsg( 'coll-add_page_popup' ),
 317+ 'wgCollectionAddCategoryText' => wfMsg( 'coll-add_category_popup' ),
 318+ 'wgCollectionRemovePageText' => wfMsg( 'coll-remove_page_popup' ),
 319+ 'wgCollectionPopupHelpText' => wfMsg( 'coll-popup_help_text' ),
 320+ 'wgCollectionArticleNamespaces' => $wgCollectionArticleNamespaces,
 321+ )
332322 );
333323 $out .= Xml::element(
334324 'script',
Index: trunk/extensions/Collection/collection/popup.js
@@ -168,8 +168,8 @@
169169 // replace two methods from the Navpopup object
170170 Navpopup.prototype.unhide = collectionPopupUnhide;
171171 Navpopup.prototype.setInnerHTML = collectionPopupSetInnerHTML;
172 - // disable article fetching:
173 - pg.option.simplePopups = true;
 172+ // disable article fetching:
 173+ pg.option.simplePopups = true;
174174 refreshCollectionArticleList();
175175 });
176176

Status & tagging log