42 private $languageNameUtils;
45 private $redirectLookup;
55 parent::__construct(
'MyLanguage' );
56 $this->languageNameUtils = $languageNameUtils;
57 $this->redirectLookup = $redirectLookup;
71 $title = Title::newMainPage();
90 return $this->findTitleInternal( $subpage,
false );
108 return $this->findTitleInternal( $subpage,
true );
119 private function findTitleInternal( $subpage, $forTransclusion ) {
122 $base = $provided =
null;
123 if ( $subpage !==
null ) {
124 $provided = Title::newFromText( $subpage );
127 if ( $provided && str_contains( $subpage,
'/' ) ) {
128 $pos = strrpos( $subpage,
'/' );
129 $basepage = substr( $subpage, 0, $pos );
130 $code = substr( $subpage, $pos + 1 );
131 if ( strlen( $code ) && $this->languageNameUtils->isKnownLanguageTag( $code ) ) {
132 $base = Title::newFromText( $basepage );
143 if (
$base->isRedirect() ) {
144 $base = $this->redirectLookup->getRedirectTarget(
$base );
146 $fragment =
$base->getFragment();
150 $baseLang =
$base->getPageLanguage();
153 if ( !$forTransclusion && $baseLang->equals( $uiLang ) ) {
160 $proposed =
$base->getSubpage( $uiLang->getCode() );
161 if ( $proposed && $proposed->exists() ) {
162 if ( $fragment !==
'' ) {
163 $proposed->setFragment( $fragment );
169 if ( $provided !==
$base && $provided->exists() ) {
175 $possibilities = $uiLang->getFallbackLanguages();
176 foreach ( $possibilities as
$lang ) {
177 if ( $forTransclusion ||
$lang !== $baseLang->getCode() ) {
179 if ( $proposed && $proposed->exists() ) {
180 if ( $fragment !==
'' ) {
181 $proposed->setFragment( $fragment );
Superclass for any RedirectSpecialPage which redirects the user to a particular article (as opposed t...
getLanguage()
Shortcut to get user's language.