41 private $languageNameUtils;
44 private $redirectLookup;
54 parent::__construct(
'MyLanguage' );
55 $this->languageNameUtils = $languageNameUtils;
56 $this->redirectLookup = $redirectLookup;
70 $title = Title::newMainPage();
89 return $this->findTitleInternal( $subpage,
false );
107 return $this->findTitleInternal( $subpage,
true );
118 private function findTitleInternal( $subpage, $forTransclusion ) {
121 $base = $provided =
null;
122 if ( $subpage !==
null ) {
123 $provided = Title::newFromText( $subpage );
126 if ( $provided && strpos( $subpage,
'/' ) !==
false ) {
127 $pos = strrpos( $subpage,
'/' );
128 $basepage = substr( $subpage, 0, $pos );
129 $code = substr( $subpage, $pos + 1 );
130 if ( strlen( $code ) && $this->languageNameUtils->isKnownLanguageTag( $code ) ) {
131 $base = Title::newFromText( $basepage );
141 if (
$base->isRedirect() ) {
142 $base = $this->redirectLookup->getRedirectTarget(
$base );
148 if ( $uiLang->equals( $contLang ) && !$forTransclusion ) {
155 $proposed =
$base->getSubpage( $uiLang->getCode() );
156 if ( $proposed && $proposed->exists() ) {
160 if ( $provided !==
$base && $provided->exists() ) {
166 $possibilities = $uiLang->getFallbackLanguages();
167 foreach ( $possibilities as
$lang ) {
168 if ( $forTransclusion ||
$lang !== $contLang->getCode() ) {
170 if ( $proposed && $proposed->exists() ) {
Superclass for any RedirectSpecialPage which redirects the user to a particular article (as opposed t...
getLanguage()
Shortcut to get user's language.
getContentLanguage()
Shortcut to get content language.