Index: trunk/extensions/SelectCategory/SelectCategory_body.php |
— | — | @@ -26,30 +26,18 @@ |
27 | 27 | # check if we should do anything or sleep |
28 | 28 | if ( self::checkConditions( $isUpload, $pageObj ) ) { |
29 | 29 | # Register CSS file for our select box |
30 | | - global $wgOut, $wgScriptPath, $wgUser, $wgTitle; |
| 30 | + global $wgOut, $wgUser, $wgExtensionAssetsPath; |
31 | 31 | global $wgSelectCategoryMaxLevel; |
32 | 32 | |
33 | | - $wgOut->addLink( |
34 | | - array( |
35 | | - 'rel' => 'stylesheet', |
36 | | - 'type' => 'text/css', |
37 | | - 'href' => $wgScriptPath.'/extensions/SelectCategory/SelectCategory.css' |
38 | | - ) |
39 | | - ); |
40 | | - $wgOut->addLink( |
41 | | - array( |
42 | | - 'rel' => 'stylesheet', |
43 | | - 'type' => 'text/css', |
44 | | - 'href' => $wgScriptPath.'/extensions/SelectCategory/jquery.treeview.css' |
45 | | - ) |
46 | | - ); |
47 | | - $wgOut->addScript( '<script src="'.$wgScriptPath.'/extensions/SelectCategory/jquery.treeview.js" type="text/javascript"></script>' ); |
48 | | - $wgOut->addScript( '<script src="'.$wgScriptPath.'/extensions/SelectCategory/SelectCategory.js" type="text/javascript"></script>' ); |
| 33 | + $wgOut->addExtensionStyle( "{$wgExtensionAssetsPath}/SelectCategory/SelectCategory.css" ); |
| 34 | + $wgOut->addExtensionStyle( "{$wgExtensionAssetsPath}/SelectCategory/jquery.treeview.css" ); |
| 35 | + $wgOut->addScriptFile( "{$wgExtensionAssetsPath}/SelectCategory/jquery.treeview.js" ); |
| 36 | + $wgOut->addScriptFile( "{$wgExtensionAssetsPath}/SelectCategory/SelectCategory.js" ); |
49 | 37 | |
50 | 38 | $skin = $wgUser->getSkin(); |
51 | 39 | |
52 | 40 | # Get all categories from wiki |
53 | | - $allCats = self::getAllCategories(); |
| 41 | + $allCats = self::getAllCategories( $isUpload ? NS_SPECIAL : $pageObj->mTitle->getNamespace() ); |
54 | 42 | # Load system messages |
55 | 43 | |
56 | 44 | # Get the right member variables, depending on if we're on an upload form or not |
— | — | @@ -115,7 +103,7 @@ |
116 | 104 | } |
117 | 105 | # Clean names for text output |
118 | 106 | $catName = str_replace( '_', ' ', $category ); |
119 | | - $title = $wgTitle->newFromText( $category, NS_CATEGORY ); |
| 107 | + $title = Title::newFromText( $category, NS_CATEGORY ); |
120 | 108 | # Output the actual checkboxes, indented |
121 | 109 | $pageObj->$place .= '<li' . $open . '><input type="checkbox" name="SelectCategoryList[]" value="'.$category.'" class="checkbox" '.$checked.' />'.$skin->link( $title, $catName )."\n"; |
122 | 110 | # set id for next level |
— | — | @@ -138,7 +126,6 @@ |
139 | 127 | ## Entry point for the hook and main function for saving the page |
140 | 128 | public static function saveHook( $isUpload, $pageObj ) { |
141 | 129 | global $wgContLang; |
142 | | - global $wgTitle; |
143 | 130 | |
144 | 131 | # check if we should do anything or sleep |
145 | 132 | if ( self::checkConditions( $isUpload, $pageObj ) ) { |
— | — | @@ -148,7 +135,7 @@ |
149 | 136 | |
150 | 137 | # default sort key is page name with stripped namespace name, |
151 | 138 | # otherwise sorting is ugly. |
152 | | - if( $wgTitle->getNamespace() == NS_MAIN ) { |
| 139 | + if( !$isUpload && $pageObj->mTitle->getNamespace() == NS_MAIN ) { |
153 | 140 | $default_sortkey = ""; |
154 | 141 | } else { |
155 | 142 | $default_sortkey = "|{{PAGENAME}}"; |
— | — | @@ -181,12 +168,10 @@ |
182 | 169 | ## 'Name' => (int) Depth, |
183 | 170 | ## ... |
184 | 171 | ## ) |
185 | | - public static function getAllCategories() { |
186 | | - global $wgTitle; |
| 172 | + public static function getAllCategories( $namespace ) { |
187 | 173 | global $wgSelectCategoryRoot; |
188 | 174 | |
189 | 175 | # Get current namespace (save duplicate call of method) |
190 | | - $namespace = $wgTitle->getNamespace(); |
191 | 176 | if( $namespace >= 0 && array_key_exists( $namespace, $wgSelectCategoryRoot ) && $wgSelectCategoryRoot[$namespace] ) { |
192 | 177 | # Include root and step into the recursion |
193 | 178 | $allCats = array_merge( array( $wgSelectCategoryRoot[$namespace] => 0 ), |
— | — | @@ -307,7 +292,6 @@ |
308 | 293 | public static function checkConditions ($isUpload, $pageObj ) { |
309 | 294 | global $wgSelectCategoryNamespaces; |
310 | 295 | global $wgSelectCategoryEnableSubpages; |
311 | | - global $wgTitle; |
312 | 296 | |
313 | 297 | |
314 | 298 | # Run only if we are in an upload, an activated namespace or if page is |
— | — | @@ -318,7 +302,7 @@ |
319 | 303 | return true; |
320 | 304 | } |
321 | 305 | |
322 | | - $ns = $wgTitle->getNamespace(); |
| 306 | + $ns = $pageObj->mTitle->getNamespace(); |
323 | 307 | if( array_key_exists( $ns, $wgSelectCategoryNamespaces ) ) { |
324 | 308 | $enabledForNamespace = $wgSelectCategoryNamespaces[$ns]; |
325 | 309 | } else { |
— | — | @@ -326,7 +310,7 @@ |
327 | 311 | } |
328 | 312 | |
329 | 313 | # Check if page is subpage once to save method calls below |
330 | | - $isSubpage = $wgTitle->isSubpage(); |
| 314 | + $isSubpage = $pageObj->mTitle->isSubpage(); |
331 | 315 | |
332 | 316 | if ($enabledForNamespace |
333 | 317 | && (!$isSubpage |