Index: trunk/extensions/Collection/Collection.hooks.php |
— | — | @@ -142,12 +142,13 @@ |
143 | 143 | static function getPortlet( $ajaxHint='' ) { |
144 | 144 | global $wgArticle; |
145 | 145 | global $wgTitle; |
146 | | - global $wgOut, $wgUser; |
| 146 | + global $wgUser; |
147 | 147 | global $wgRequest; |
148 | 148 | global $wgCollectionArticleNamespaces; |
149 | 149 | global $wgScriptPath; |
150 | 150 | global $wgCollectionStyleVersion; |
151 | 151 | global $wgCollectionNavPopups; |
| 152 | + global $wgJsMimeType; |
152 | 153 | |
153 | 154 | $sk = $wgUser->getSkin(); |
154 | 155 | |
— | — | @@ -168,6 +169,7 @@ |
169 | 170 | |
170 | 171 | $numArticles = CollectionSession::countArticles(); |
171 | 172 | $showShowAndClearLinks = true; |
| 173 | + $addRemoveState = ''; |
172 | 174 | |
173 | 175 | $out = Xml::element( 'ul', array( 'id' => 'collectionPortletList' ), NULL ); |
174 | 176 | |
— | — | @@ -184,6 +186,7 @@ |
185 | 187 | $showShowAndClearLinks = false; |
186 | 188 | |
187 | 189 | } else if( $ajaxHint == 'addcategory' || $namespace == NS_CATEGORY ) { |
| 190 | + $addRemoveState = 'addcategory'; |
188 | 191 | |
189 | 192 | $out .= Xml::tags( 'li', array( 'id' => 'coll-add_category' ), |
190 | 193 | $sk->link( SpecialPage::getTitleFor( 'Book', 'add_category/' ), |
— | — | @@ -203,11 +206,13 @@ |
204 | 207 | $params['oldid'] = $oldid; |
205 | 208 | } |
206 | 209 | |
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'; |
208 | 212 | $action = 'add'; |
209 | 213 | $uaction = 'Add'; |
210 | 214 | $other_action = 'remove'; |
211 | 215 | } else { |
| 216 | + $addRemoveState = 'removepage'; |
212 | 217 | $action = 'remove'; |
213 | 218 | $uaction = 'Remove'; |
214 | 219 | $other_action = 'add'; |
— | — | @@ -261,8 +266,19 @@ |
262 | 267 | ); |
263 | 268 | |
264 | 269 | $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 | + ); |
267 | 283 | |
268 | 284 | // activate popup check: |
269 | 285 | if ( $wgCollectionNavPopups ) { |
— | — | @@ -271,8 +287,11 @@ |
272 | 288 | $removePageText = wfMsg( 'coll-remove_page_popup' ); |
273 | 289 | $popupHelpText = wfMsg( 'coll-popup_help_text' ); |
274 | 290 | |
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'; |
277 | 296 | wgCollectionNavPopupCSSURL = '$wgScriptPath/extensions/Collection/collection/Gadget-navpop.css?$wgCollectionStyleVersion'; |
278 | 297 | wgCollectionAddPageText = '$addPageText'; |
279 | 298 | wgCollectionAddCategoryText = '$addCategoryText'; |
— | — | @@ -280,10 +299,22 @@ |
281 | 300 | wgCollectionPopupHelpText = '$popupHelpText'; |
282 | 301 | wgCollectionArticleNamespaces = [ " |
283 | 302 | . 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 | + ); |
288 | 319 | } |
289 | 320 | |
290 | 321 | return $out; |