Index: trunk/phase3/includes/Parser.php |
— | — | @@ -1865,8 +1865,7 @@ |
1866 | 1866 | */ |
1867 | 1867 | function areSubpagesAllowed() { |
1868 | 1868 | # Some namespaces don't allow subpages |
1869 | | - global $wgNamespacesWithSubpages; |
1870 | | - return !empty($wgNamespacesWithSubpages[$this->mTitle->getNamespace()]); |
| 1869 | + return MWNamespace::hasSubpages( $this->mTitle->getNamespace() ); |
1871 | 1870 | } |
1872 | 1871 | |
1873 | 1872 | /** |
Index: trunk/phase3/includes/SpecialMovepage.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | } |
67 | 67 | |
68 | 68 | function showForm( $err, $hookErr = '' ) { |
69 | | - global $wgOut, $wgUser, $wgNamespacesWithSubpages; |
| 69 | + global $wgOut, $wgUser; |
70 | 70 | |
71 | 71 | $ot = Title::newFromURL( $this->oldTitle ); |
72 | 72 | if( is_null( $ot ) ) { |
— | — | @@ -237,8 +237,7 @@ |
238 | 238 | } |
239 | 239 | |
240 | 240 | function doSubmit() { |
241 | | - global $wgOut, $wgUser, $wgRequest, $wgMaximumMovedPages, $wgLang, |
242 | | - $wgNamespacesWithSubpages; |
| 241 | + global $wgOut, $wgUser, $wgRequest, $wgMaximumMovedPages, $wgLang; |
243 | 242 | |
244 | 243 | if ( $wgUser->pingLimiter( 'move' ) ) { |
245 | 244 | $wgOut->rateLimited(); |
— | — | @@ -317,9 +316,9 @@ |
318 | 317 | # case. |
319 | 318 | $dbr = wfGetDB( DB_SLAVE ); |
320 | 319 | if( $this->moveSubpages && ( |
321 | | - !empty($wgNamespacesWithSubpages[$nt->getNamespace()]) || ( |
| 320 | + MWNamespace::hasSubpages( $nt->getNamespace() ) || ( |
322 | 321 | $this->moveTalk && |
323 | | - !empty( $wgNamespacesWithSubpages[$nt->getTalkPage()->getNamespace()] ) |
| 322 | + MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) |
324 | 323 | ) |
325 | 324 | ) ) { |
326 | 325 | $conds = array( |
— | — | @@ -327,15 +326,15 @@ |
328 | 327 | .' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() ) |
329 | 328 | ); |
330 | 329 | $conds['page_namespace'] = array(); |
331 | | - if( !empty( $wgNamespacesWithSubpages[$nt->getNamespace()] ) ) { |
| 330 | + if( MWNamespace::hasSubpages( $nt->getNamespace() ) ) { |
332 | 331 | $conds['page_namespace'] []= $ot->getNamespace(); |
333 | 332 | } |
334 | | - if( $this->moveTalk && !empty( $wgNamespacesWithSubpages[$nt->getTalkPage()->getNamespace()] ) ) { |
| 333 | + if( $this->moveTalk && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) ) { |
335 | 334 | $conds['page_namespace'] []= $ot->getTalkPage()->getNamespace(); |
336 | 335 | } |
337 | 336 | } elseif( $this->moveTalk ) { |
338 | 337 | $conds = array( |
339 | | - 'page_namespace' => MWNamespace::getTalk($ot->getNamespace()), |
| 338 | + 'page_namespace' => $ot->getTalkPage()->getNamespace(), |
340 | 339 | 'page_title' => $ot->getDBKey() |
341 | 340 | ); |
342 | 341 | } else { |
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | } |
106 | 106 | |
107 | 107 | protected function appendNamespaces($property) { |
108 | | - global $wgContLang, $wgNamespacesWithSubpages; |
| 108 | + global $wgContLang; |
109 | 109 | |
110 | 110 | $data = array (); |
111 | 111 | foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) { |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | 'id' => $ns |
114 | 114 | ); |
115 | 115 | ApiResult :: setContent($data[$ns], $title); |
116 | | - if(!empty($wgNamespacesWithSubpages[$ns])) |
| 116 | + if( MWNamespace::hasSubpages( $ns ) ) |
117 | 117 | $data[$ns]['subpages'] = ''; |
118 | 118 | } |
119 | 119 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -697,16 +697,15 @@ |
698 | 698 | * @return string Base name |
699 | 699 | */ |
700 | 700 | public function getBaseText() { |
701 | | - global $wgNamespacesWithSubpages; |
702 | | - if( !empty( $wgNamespacesWithSubpages[$this->mNamespace] ) ) { |
703 | | - $parts = explode( '/', $this->getText() ); |
704 | | - # Don't discard the real title if there's no subpage involved |
705 | | - if( count( $parts ) > 1 ) |
706 | | - unset( $parts[ count( $parts ) - 1 ] ); |
707 | | - return implode( '/', $parts ); |
708 | | - } else { |
| 701 | + if( !MWNamespace::hasSubpages( $this->mNamespace ) ) { |
709 | 702 | return $this->getText(); |
710 | 703 | } |
| 704 | + |
| 705 | + $parts = explode( '/', $this->getText() ); |
| 706 | + # Don't discard the real title if there's no subpage involved |
| 707 | + if( count( $parts ) > 1 ) |
| 708 | + unset( $parts[ count( $parts ) - 1 ] ); |
| 709 | + return implode( '/', $parts ); |
711 | 710 | } |
712 | 711 | |
713 | 712 | /** |
— | — | @@ -714,13 +713,11 @@ |
715 | 714 | * @return string Subpage name |
716 | 715 | */ |
717 | 716 | public function getSubpageText() { |
718 | | - global $wgNamespacesWithSubpages; |
719 | | - if( !empty( $wgNamespacesWithSubpages[ $this->mNamespace ] ) ) { |
720 | | - $parts = explode( '/', $this->mTextform ); |
721 | | - return( $parts[ count( $parts ) - 1 ] ); |
722 | | - } else { |
| 717 | + if( !MWNamespace::hasSubpages( $this->mNamespace ) ) { |
723 | 718 | return( $this->mTextform ); |
724 | 719 | } |
| 720 | + $parts = explode( '/', $this->mTextform ); |
| 721 | + return( $parts[ count( $parts ) - 1 ] ); |
725 | 722 | } |
726 | 723 | |
727 | 724 | /** |
— | — | @@ -1494,13 +1491,9 @@ |
1495 | 1492 | * @return bool |
1496 | 1493 | */ |
1497 | 1494 | public function isSubpage() { |
1498 | | - global $wgNamespacesWithSubpages; |
1499 | | - |
1500 | | - if( !empty( $wgNamespacesWithSubpages[ $this->mNamespace ] ) ) { |
1501 | | - return strpos( $this->getText(), '/' ) !== false; |
1502 | | - } else { |
1503 | | - return false; |
1504 | | - } |
| 1495 | + return MWNamespace::hasSubpages( $this->mNamespace ) |
| 1496 | + ? strpos( $this->getText(), '/' ) !== false; |
| 1497 | + : false; |
1505 | 1498 | } |
1506 | 1499 | |
1507 | 1500 | /** |
— | — | @@ -1508,9 +1501,7 @@ |
1509 | 1502 | * @return bool |
1510 | 1503 | */ |
1511 | 1504 | public function hasSubpages() { |
1512 | | - global $wgNamespacesWithSubpages; |
1513 | | - |
1514 | | - if( empty( $wgNamespacesWithSubpages[$this->mNamespace] ) ) { |
| 1505 | + if( !MWNamespace::hasSubpages( $this->mNamespace ) ) { |
1515 | 1506 | # Duh |
1516 | 1507 | return false; |
1517 | 1508 | } |
Index: trunk/phase3/includes/Namespace.php |
— | — | @@ -146,8 +146,8 @@ |
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
150 | | - * Does this namespace contain content, for the purposes |
151 | | - * of calculating statistics, etc? |
| 150 | + * Does this namespace contain content, for the purposes of calculating |
| 151 | + * statistics, etc? |
152 | 152 | * |
153 | 153 | * @param $index Int: index to check |
154 | 154 | * @return bool |
— | — | @@ -167,4 +167,15 @@ |
168 | 168 | return $index >= NS_MAIN; |
169 | 169 | } |
170 | 170 | |
| 171 | + /** |
| 172 | + * Does the namespace allow subpages? |
| 173 | + * |
| 174 | + * @param $index int Index to check |
| 175 | + * @return bool |
| 176 | + */ |
| 177 | + public static function hasSubpages( $index ) { |
| 178 | + global $wgNamespacesWithSubpages; |
| 179 | + return !empty( $wgNamespacesWithSubpages[$index] ); |
| 180 | + } |
| 181 | + |
171 | 182 | } |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -882,8 +882,8 @@ |
883 | 883 | if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages))) |
884 | 884 | return $subpages; |
885 | 885 | |
886 | | - global $wgOut, $wgTitle, $wgNamespacesWithSubpages; |
887 | | - if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) { |
| 886 | + global $wgOut, $wgTitle; |
| 887 | + if($wgOut->isArticle() && MWNamespace::hasSubpages( $wgTitle->getNamespace() )) { |
888 | 888 | $ptext=$wgTitle->getPrefixedText(); |
889 | 889 | if(preg_match('/\//',$ptext)) { |
890 | 890 | $links = explode('/',$ptext); |