MediaWiki  master
NaiveForeignTitleFactory.php
Go to the documentation of this file.
1 <?php
26 
29 
33  public function __construct( Language $contentLanguage ) {
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 }
NaiveForeignTitleFactory
A parser that translates page titles on a foreign wiki into ForeignTitle objects, with no knowledge o...
Definition: NaiveForeignTitleFactory.php:25
ForeignTitleFactory
A parser that translates page titles into ForeignTitle objects.
Definition: ForeignTitleFactory.php:24
$title
$title
Definition: testCompression.php:38
NaiveForeignTitleFactory\__construct
__construct(Language $contentLanguage)
Definition: NaiveForeignTitleFactory.php:33
NaiveForeignTitleFactory\$contentLanguage
Language $contentLanguage
Definition: NaiveForeignTitleFactory.php:28
NaiveForeignTitleFactory\createForeignTitle
createForeignTitle( $title, $ns=null)
Creates a ForeignTitle object based on the page title, and optionally the namespace ID,...
Definition: NaiveForeignTitleFactory.php:53
ForeignTitle
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Definition: ForeignTitle.php:28
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:42