MediaWiki REL1_37
NaiveForeignTitleFactory.php
Go to the documentation of this file.
1<?php
26
29
34 $this->contentLanguage = $contentLanguage;
35 }
36
53 public function createForeignTitle( $title, $ns = null ) {
54 $pieces = explode( ':', $title, 2 );
55
68 $isNamespacePartValid = $ns === null
69 ? $this->contentLanguage->getNsIndex( $pieces[0] ) !== false
70 : $ns != 0;
71
72 if ( count( $pieces ) === 2 && $isNamespacePartValid ) {
73 list( $namespaceName, $pageName ) = $pieces;
74 } else {
75 $namespaceName = '';
76 $pageName = $title;
77 }
78
79 return new ForeignTitle( $ns, $namespaceName, $pageName );
80 }
81}
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition Language.php:42
A parser that translates page titles on a foreign wiki into ForeignTitle objects, with no knowledge o...
createForeignTitle( $title, $ns=null)
Creates a ForeignTitle object based on the page title, and optionally the namespace ID,...
__construct(Language $contentLanguage)
A parser that translates page titles into ForeignTitle objects.