*/
public function getLanguages() {
global $wgHideInterlanguageLinks;
- $out = $this->getOutput();
+ if ( $wgHideInterlanguageLinks ) {
+ return array();
+ }
+
$userLang = $this->getLanguage();
+ $languageLinks = array();
- # Language links
- $language_urls = array();
-
- if ( !$wgHideInterlanguageLinks ) {
- foreach ( $out->getLanguageLinks() as $languageLinkText ) {
- $languageLinkParts = explode( ':', $languageLinkText, 2 );
- $class = 'interwiki-' . $languageLinkParts[0];
- unset( $languageLinkParts );
- $languageLinkTitle = Title::newFromText( $languageLinkText );
- if ( $languageLinkTitle ) {
- $ilInterwikiCode = $languageLinkTitle->getInterwiki();
- $ilLangName = Language::fetchLanguageName( $ilInterwikiCode );
-
- if ( strval( $ilLangName ) === '' ) {
- $ilLangName = $languageLinkText;
- } else {
- $ilLangName = $this->formatLanguageName( $ilLangName );
- }
+ foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
+ $languageLinkParts = explode( ':', $languageLinkText, 2 );
+ $class = 'interlanguage-link interwiki-' . $languageLinkParts[0];
+ unset( $languageLinkParts );
- // CLDR extension or similar is required to localize the language name;
- // otherwise we'll end up with the autonym again.
- $ilLangLocalName = Language::fetchLanguageName( $ilInterwikiCode, $userLang->getCode() );
-
- $language_urls[] = array(
- 'href' => $languageLinkTitle->getFullURL(),
- 'text' => $ilLangName,
- 'title' => wfMessage( 'tooltip-iwiki', $languageLinkTitle->getText(), $ilLangLocalName )->escaped(),
- 'class' => $class,
- 'lang' => wfBCP47( $ilInterwikiCode ),
- 'hreflang' => wfBCP47( $ilInterwikiCode ),
- );
+ $languageLinkTitle = Title::newFromText( $languageLinkText );
+ if ( $languageLinkTitle ) {
+ $ilInterwikiCode = $languageLinkTitle->getInterwiki();
+ $ilLangName = Language::fetchLanguageName( $ilInterwikiCode );
+
+ if ( strval( $ilLangName ) === '' ) {
+ $ilLangName = $languageLinkText;
+ } else {
+ $ilLangName = $this->formatLanguageName( $ilLangName );
}
+
+ // CLDR extension or similar is required to localize the language name;
+ // otherwise we'll end up with the autonym again.
+ $ilLangLocalName = Language::fetchLanguageName(
+ $ilInterwikiCode,
+ $userLang->getCode()
+ );
+
+ $languageLinkTitleText = $languageLinkTitle->getText();
+ if ( $languageLinkTitleText === '' ) {
+ $ilTitle = wfMessage(
+ 'interlanguage-link-title-langonly',
+ $ilLangLocalName
+ )->text();
+ } else {
+ $ilTitle = wfMessage(
+ 'interlanguage-link-title',
+ $languageLinkTitleText,
+ $ilLangLocalName
+ )->text();
+ }
+
+ $ilInterwikiCodeBCP47 = wfBCP47( $ilInterwikiCode );
+ $languageLinks[] = array(
+ 'href' => $languageLinkTitle->getFullURL(),
+ 'text' => $ilLangName,
+ 'title' => $ilTitle,
+ 'class' => $class,
+ 'lang' => $ilInterwikiCodeBCP47,
+ 'hreflang' => $ilInterwikiCodeBCP47,
+ );
}
}
- return $language_urls;
+
+ return $languageLinks;
}
protected function setupTemplateForOutput() {
* @param $out OutputPage
*/
function outputPage( OutputPage $out = null ) {
- global $wgContLang;
- global $wgScript, $wgStylePath;
- global $wgMimeType, $wgJsMimeType;
- global $wgXhtmlNamespaces, $wgHtml5Version;
- global $wgDisableCounters, $wgSitename, $wgLogo;
- global $wgMaxCredits, $wgShowCreditsIfMax;
- global $wgPageShowWatchingUsers;
- global $wgArticlePath, $wgScriptPath, $wgServer;
-
wfProfileIn( __METHOD__ );
Profiler::instance()->setTemplated( true );
}
$out = $this->getOutput();
- $request = $this->getRequest();
- $user = $this->getUser();
- $title = $this->getTitle();
wfProfileIn( __METHOD__ . '-init' );
$this->initPage( $out );
wfProfileOut( __METHOD__ . '-init' );
+ $tpl = $this->prepareQuickTemplate( $out );
+ // execute template
+ wfProfileIn( __METHOD__ . '-execute' );
+ $res = $tpl->execute();
+ wfProfileOut( __METHOD__ . '-execute' );
+
+ // result may be an error
+ $this->printOrError( $res );
+
+ if ( $oldContext ) {
+ $this->setContext( $oldContext );
+ }
+
+ wfProfileOut( __METHOD__ );
+ }
+ /**
+ * initialize various variables and generate the template
+ *
+ * @since 1.23
+ * @return QuickTemplate the template to be executed by outputPage
+ */
+ protected function prepareQuickTemplate() {
+ global $wgContLang, $wgScript, $wgStylePath,
+ $wgMimeType, $wgJsMimeType, $wgXhtmlNamespaces, $wgHtml5Version,
+ $wgDisableCounters, $wgSitename, $wgLogo, $wgMaxCredits,
+ $wgShowCreditsIfMax, $wgPageShowWatchingUsers, $wgArticlePath,
+ $wgScriptPath, $wgServer;
+
+ wfProfileIn( __METHOD__ );
+
+ $title = $this->getTitle();
+ $request = $this->getRequest();
+ $out = $this->getOutput();
$tpl = $this->setupTemplateForOutput();
wfProfileIn( __METHOD__ . '-stuff-head' );
$tpl->set( 'dataAfterContent', $this->afterContentHook() );
wfProfileOut( __METHOD__ . '-stuff5' );
- // execute template
- wfProfileIn( __METHOD__ . '-execute' );
- $res = $tpl->execute();
- wfProfileOut( __METHOD__ . '-execute' );
-
- // result may be an error
- $this->printOrError( $res );
-
- if ( $oldContext ) {
- $this->setContext( $oldContext );
- }
wfProfileOut( __METHOD__ );
+ return $tpl;
}
/**
$personal_urls[$login_id] = $login_url;
}
- wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title ) );
+ wfRunHooks( 'PersonalUrls', array( &$personal_urls, &$title, $this ) );
wfProfileOut( __METHOD__ );
return $personal_urls;
}
}
}
- if ( $title->getNamespace() !== NS_MEDIAWIKI && $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() ) {
+ if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
+ MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== array( '' )
+ ) {
$mode = $title->isProtected() ? 'unprotect' : 'protect';
$content_navigation['actions'][$mode] = array(
'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
echo htmlspecialchars( $this->data[$str] );
}
- /**
- * @private
- * @deprecated since 1.21; use Xml::encodeJsVar() or Xml::encodeJsCall() instead
- */
- function jstext( $str ) {
- wfDeprecated( __METHOD__, '1.21' );
- echo Xml::escapeJsString( $this->data[$str] );
- }
-
/**
* @private
*/
public function getSkin() {
return $this->data['skin'];
}
+
+ /**
+ * Fetch the output of a QuickTemplate and return it
+ *
+ * @since 1.23
+ * @return String
+ */
+ public function getHTML() {
+ ob_start();
+ $this->execute();
+ $html = ob_get_contents();
+ ob_end_clean();
+ return $html;
+ }
}
/**