MediaWiki REL1_32
NaiveImportTitleFactory.php
Go to the documentation of this file.
1<?php
22
43 public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) {
44 if ( $foreignTitle->isNamespaceIdKnown() ) {
45 $foreignNs = $foreignTitle->getNamespaceId();
46
47 // For built-in namespaces (0 <= ID < 100), we try to find a local NS with
48 // the same namespace ID
49 if ( $foreignNs < 100 && MWNamespace::exists( $foreignNs ) ) {
50 return Title::makeTitleSafe( $foreignNs, $foreignTitle->getText() );
51 }
52 }
53
54 // Do we have a local namespace by the same name as the foreign
55 // namespace?
56 $targetNs = MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex(
57 $foreignTitle->getNamespaceName() );
58 if ( $targetNs !== false ) {
59 return Title::makeTitleSafe( $targetNs, $foreignTitle->getText() );
60 }
61
62 // Otherwise, just fall back to main namespace
63 return Title::makeTitleSafe( 0, $foreignTitle->getFullText() );
64 }
65}
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
MediaWikiServices is the service locator for the application scope of MediaWiki.
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
createTitleFromForeignTitle(ForeignTitle $foreignTitle)
Determines which local title best corresponds to the given foreign title.
Represents an object that can convert page titles on a foreign wiki (ForeignTitle objects) into page ...