MediaWiki REL1_39
NaiveForeignTitleFactory.php
Go to the documentation of this file.
1<?php
26
28 private $contentLanguage;
29
33 public function __construct( Language $contentLanguage ) {
34 $this->contentLanguage = $contentLanguage;
35 }
36
55 public function createForeignTitle( $title, $ns = null ) {
56 $pieces = explode( ':', $title, 2 );
57
70 $isNamespacePartValid = $ns === null
71 ? $this->contentLanguage->getNsIndex( $pieces[0] ) !== false
72 : $ns != 0;
73
74 if ( count( $pieces ) === 2 && $isNamespacePartValid ) {
75 list( $namespaceName, $pageName ) = $pieces;
76 } else {
77 $namespaceName = '';
78 $pageName = $title;
79 }
80
81 return new ForeignTitle( $ns, $namespaceName, $pageName );
82 }
83}
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Base class for language-specific code.
Definition Language.php:53
A parser that translates page titles on a foreign wiki into ForeignTitle objects, with no knowledge o...
createForeignTitle( $title, $ns=null)
Create a ForeignTitle object.
__construct(Language $contentLanguage)
A parser that translates page titles into ForeignTitle objects.