r50479 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50478‎ | r50479 | r50480 >
Date:12:39, 11 May 2009
Author:jojo
Status:ok
Tags:
Comment:
fixed JS bugs introduced w/ 50472
Modified paths:
  • /trunk/extensions/Collection/Collection.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.hooks.php
@@ -142,12 +142,13 @@
143143 static function getPortlet( $ajaxHint='' ) {
144144 global $wgArticle;
145145 global $wgTitle;
146 - global $wgOut, $wgUser;
 146+ global $wgUser;
147147 global $wgRequest;
148148 global $wgCollectionArticleNamespaces;
149149 global $wgScriptPath;
150150 global $wgCollectionStyleVersion;
151151 global $wgCollectionNavPopups;
 152+ global $wgJsMimeType;
152153
153154 $sk = $wgUser->getSkin();
154155
@@ -168,6 +169,7 @@
169170
170171 $numArticles = CollectionSession::countArticles();
171172 $showShowAndClearLinks = true;
 173+ $addRemoveState = '';
172174
173175 $out = Xml::element( 'ul', array( 'id' => 'collectionPortletList' ), NULL );
174176
@@ -184,6 +186,7 @@
185187 $showShowAndClearLinks = false;
186188
187189 } else if( $ajaxHint == 'addcategory' || $namespace == NS_CATEGORY ) {
 190+ $addRemoveState = 'addcategory';
188191
189192 $out .= Xml::tags( 'li', array( 'id' => 'coll-add_category' ),
190193 $sk->link( SpecialPage::getTitleFor( 'Book', 'add_category/' ),
@@ -203,11 +206,13 @@
204207 $params['oldid'] = $oldid;
205208 }
206209
207 - if ( $ajaxHint == 'addpage' || CollectionSession::findArticle( $wgTitle->getPrefixedText(), $oldid ) == -1 ) {
 210+ if ( $ajaxHint == 'addpage' || ($ajaxHint != 'removepage' && CollectionSession::findArticle( $wgTitle->getPrefixedText(), $oldid ) == -1 ) ) {
 211+ $addRemoveState = 'addpage';
208212 $action = 'add';
209213 $uaction = 'Add';
210214 $other_action = 'remove';
211215 } else {
 216+ $addRemoveState = 'removepage';
212217 $action = 'remove';
213218 $uaction = 'Remove';
214219 $other_action = 'add';
@@ -261,8 +266,19 @@
262267 );
263268
264269 $out .= '</ul>';
265 - $wgOut->addScript( "/* <![CDATA[ */ wgCollectionAddRemoveState = '$addRemoveState'; /* ]]> */" );
266 - $wgOut->addScriptFile( "/extensions/Collection/collection/portlet.js?$wgCollectionStyleVersion" );
 270+ $out .= Xml::element( 'script',
 271+ array(
 272+ 'type' => $wgJsMimeType,
 273+ ),
 274+ "wgCollectionAddRemoveState = '$addRemoveState';"
 275+ );
 276+ $out .= Xml::element( 'script',
 277+ array(
 278+ 'type' => $wgJsMimeType,
 279+ 'src' => "$wgScriptPath/extensions/Collection/collection/portlet.js?$wgCollectionStyleVersion",
 280+ ),
 281+ '', false
 282+ );
267283
268284 // activate popup check:
269285 if ( $wgCollectionNavPopups ) {
@@ -271,8 +287,11 @@
272288 $removePageText = wfMsg( 'coll-remove_page_popup' );
273289 $popupHelpText = wfMsg( 'coll-popup_help_text' );
274290
275 - $wgOut->addScript( "/* <![CDATA[ */
276 - wgCollectionNavPopupJSURL = '$wgScriptPath/extensions/Collection/collection/Gadget-popups.js?$wgCollectionStyleVersion';
 291+ $out .= Xml::element( 'script',
 292+ array(
 293+ 'type' => $wgJsMimeType,
 294+ ),
 295+ "wgCollectionNavPopupJSURL = '$wgScriptPath/extensions/Collection/collection/Gadget-popups.js?$wgCollectionStyleVersion';
277296 wgCollectionNavPopupCSSURL = '$wgScriptPath/extensions/Collection/collection/Gadget-navpop.css?$wgCollectionStyleVersion';
278297 wgCollectionAddPageText = '$addPageText';
279298 wgCollectionAddCategoryText = '$addCategoryText';
@@ -280,10 +299,22 @@
281300 wgCollectionPopupHelpText = '$popupHelpText';
282301 wgCollectionArticleNamespaces = [ "
283302 . implode( ', ', $wgCollectionArticleNamespaces )
284 - . "]; /* ]]> */ " );
285 - $wgOut->addScriptFile( "/extensions/Collection/collection/json2.js?$wgCollectionStyleVersion" );
286 - $wgOut->addScriptFile( "/extensions/Collection/collection/popupcheck.js?$wgCollectionStyleVersion" );
287 -
 303+ . "];"
 304+ );
 305+ $out .= Xml::element( 'script',
 306+ array(
 307+ 'type' => $wgJsMimeType,
 308+ 'src' => "$wgScriptPath/extensions/Collection/collection/json2.js?$wgCollectionStyleVersion"
 309+ ),
 310+ '', false
 311+ );
 312+ $out .= Xml::element( 'script',
 313+ array(
 314+ 'type' => $wgJsMimeType,
 315+ 'src' => "$wgScriptPath/extensions/Collection/collection/popupcheck.js?$wgCollectionStyleVersion"
 316+ ),
 317+ '', false
 318+ );
288319 }
289320
290321 return $out;

Status & tagging log