(Also note -- using MWNamespace instead of Namespace for PHP 5.3 compat.)
* Returns the canonical (English Wikipedia) name for a given index
*
* @param $index Int: namespace index
- * @return string
+ * @return string or false if no canonical definition.
*/
public static function getCanonicalName( $index ) {
global $wgCanonicalNamespaceNames;
- return $wgCanonicalNamespaceNames[$index];
+ if( isset( $wgCanonicalNamespaceNames[$index] ) ) {
+ return $wgCanonicalNamespaceNames[$index];
+ } else {
+ return false;
+ }
}
/**
}
protected function appendNamespaces( $property ) {
- global $wgContLang, $wgCanonicalNamespaceNames;
+ global $wgContLang;
$data = array();
foreach( $wgContLang->getFormattedNamespaces() as $ns => $title )
{
'id' => $ns
);
ApiResult :: setContent( $data[$ns], $title );
- $canonical = isset($wgCanonicalNamespaceNames[$ns]) ? $wgCanonicalNamespaceNames[$ns] : false;
+ $canonical = MWNamespace::getCanonicalName( $ns );
if( MWNamespace::hasSubpages( $ns ) )
$data[$ns]['subpages'] = '';