68 $services = MediaWikiServices::getInstance();
71 $base = $provided =
null;
72 if ( $subpage !==
null ) {
73 $provided = Title::newFromText( $subpage );
76 if ( $provided && strpos( $subpage,
'/' ) !==
false ) {
77 $pos = strrpos( $subpage,
'/' );
78 $basepage = substr( $subpage, 0, $pos );
79 $code = substr( $subpage, $pos + 1 );
80 if ( strlen( $code ) && $services->getLanguageNameUtils()->isKnownLanguageTag( $code ) ) {
81 $base = Title::newFromText( $basepage );
91 if (
$base->isRedirect() ) {
93 $base = $page->getRedirectTarget();
97 $contLang = $services->getContentLanguage();
99 if ( $uiLang->equals( $contLang ) ) {
106 $proposed =
$base->getSubpage( $uiLang->getCode() );
107 if ( $proposed && $proposed->exists() ) {
111 if ( $provided !==
$base && $provided->exists() ) {
117 $possibilities = $uiLang->getFallbackLanguages();
118 foreach ( $possibilities as
$lang ) {
119 if (
$lang !== $contLang->getCode() ) {
121 if ( $proposed && $proposed->exists() ) {