41 private $languageNameUtils;
44 private $redirectLookup;
54 parent::__construct(
'MyLanguage' );
55 $this->languageNameUtils = $languageNameUtils;
56 $this->redirectLookup = $redirectLookup;
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 ) {
126 if ( $provided && str_contains( $subpage,
'/' ) ) {
127 $pos = strrpos( $subpage,
'/' );
128 $basepage = substr( $subpage, 0, $pos );
129 $code = substr( $subpage, $pos + 1 );
130 if ( strlen( $code ) && $this->languageNameUtils->isKnownLanguageTag( $code ) ) {
142 if (
$base->isRedirect() ) {
143 $base = $this->redirectLookup->getRedirectTarget(
$base );
145 $fragment =
$base->getFragment();
149 $baseLang =
$base->getPageLanguage();
152 if ( !$forTransclusion && $baseLang->equals( $uiLang ) ) {
159 $proposed =
$base->getSubpage( $uiLang->getCode() );
160 if ( $proposed && $proposed->exists() ) {
161 if ( $fragment !==
'' ) {
162 $proposed->setFragment( $fragment );
168 if ( $provided !==
$base && $provided->exists() ) {
174 $possibilities = $uiLang->getFallbackLanguages();
175 foreach ( $possibilities as
$lang ) {
176 if ( $forTransclusion ||
$lang !== $baseLang->getCode() ) {
178 if ( $proposed && $proposed->exists() ) {
179 if ( $fragment !==
'' ) {
180 $proposed->setFragment( $fragment );
Superclass for any RedirectSpecialPage which redirects the user to a particular article (as opposed t...
Unlisted special page just to redirect the user to the translated version of a page,...
findTitle( $subpage)
Find a title.
__construct(LanguageNameUtils $languageNameUtils, RedirectLookup $redirectLookup)
getRedirect( $subpage)
If the special page is a redirect, then get the Title object it redirects to.
personallyIdentifiableTarget()
Target can identify a specific user's language preference.
findTitleForTransclusion( $subpage)
Find a title for transclusion.
getLanguage()
Shortcut to get user's language.
static newMainPage(MessageLocalizer $localizer=null)
Create a new Title for the Main Page.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Service for resolving a wiki page redirect.
if(!isset( $args[0])) $lang