}
function initPage( OutputPage $out ) {
- global $wgFavicon, $wgAppleTouchIcon;
+ global $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI;
wfProfileIn( __METHOD__ );
'title' => wfMsgForContent( 'opensearch-desc' ),
) );
+ if ( $wgEnableAPI ) {
+ # Real Simple Discovery link, provides auto-discovery information
+ # for the MediaWiki API (and potentially additional custom API
+ # support such as WordPress or Twitter-compatible APIs for a
+ # blogging extension, etc)
+ $out->addLink( array(
+ 'rel' => 'EditURI',
+ 'type' => 'application/rsd+xml',
+ 'href' => wfExpandUrl( wfAppendQuery( wfScript( 'api' ), array( 'action' => 'rsd' ) ) ),
+ ) );
+ }
+
$this->addMetadataLinks( $out );
$this->mRevisionId = $out->mRevisionId;
}
$lb = new LinkBatch( $titles );
+ $lb->setCaller( __METHOD__ );
$lb->execute();
}
/**
- * Adds metadata links (Creative Commons/Dublin Core/copyright) to the HTML
- * output.
+ * Adds metadata links below to the HTML output.
+ * <ol>
+ * <li>Creative Commons
+ * <br />See http://wiki.creativecommons.org/Extend_Metadata.
+ * </li>
+ * <li>Dublin Core</li>
+ * <li>Use hreflang to specify canonical and alternate links
+ * <br />See http://www.google.com/support/webmasters/bin/answer.py?answer=189077
+ * </li>
+ * <li>Copyright</li>
+ * <ol>
+ *
* @param $out Object: instance of OutputPage
*/
function addMetadataLinks( OutputPage $out ) {
global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
+ global $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang;
global $wgRightsPage, $wgRightsUrl;
if ( $out->isArticleRelated() ) {
);
}
}
+
+ if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks
+ && $wgContLang->hasVariants() ) {
+
+ $urlvar = $wgContLang->getURLVariant();
+
+ if ( !$urlvar ) {
+ $variants = $wgContLang->getVariants();
+ foreach ( $variants as $_v ) {
+ $out->addLink( array(
+ 'rel' => 'alternate',
+ 'hreflang' => $_v,
+ 'href' => $this->mTitle->getLocalURL( '', $_v ) )
+ );
+ }
+ } else {
+ $out->addLink( array(
+ 'rel' => 'canonical',
+ 'href' => $this->mTitle->getFullURL() )
+ );
+ }
+ }
+
$copyright = '';
if ( $wgRightsPage ) {
$copy = Title::newFromText( $wgRightsPage );
static function makeVariablesScript( $data ) {
if ( $data ) {
- return Html::inlineScript( 'mediaWiki.config.set(' . FormatJson::encode( $data ) . ');' );
+ return Html::inlineScript(
+ ResourceLoader::makeLoaderConditionalScript( ResourceLoader::makeConfigSetScript( $data ) )
+ );
} else {
return '';
}
* You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
*/
static function makeGlobalVariablesScript( $skinName ) {
- global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes;
+ global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
$ns = $wgTitle->getNamespace();
$nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $wgTitle->getNsText();
foreach ( $wgRestrictionTypes as $type ) {
$vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
}
+ if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
+ $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
+ }
// Allow extensions to add their custom variables to the global JS variables
wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
* @private
*/
function setupUserCss( OutputPage $out ) {
- global $wgRequest, $wgUser;
- global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs, $wgSquidMaxage;
+ global $wgRequest;
+ global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
wfProfileIn( __METHOD__ );
$this->setupSkinUserCss( $out );
-
- $siteargs = array(
- 'action' => 'raw',
- 'maxage' => $wgSquidMaxage,
- );
-
// Add any extension CSS
foreach ( $out->getExtStyle() as $url ) {
$out->addStyle( $url );
// Per-user preference styles
if ( $wgAllowUserCssPrefs ) {
- $out->addModuleStyles( 'user.preferences' );
+ $out->addModuleStyles( 'user.options' );
}
wfProfileOut( __METHOD__ );
return "$numeric $type $name";
}
+ /**
+ * This will be called by OutputPage::headElement when it is creating the
+ * <body> tag, skins can override it if they have a need to add in any
+ * body attributes or classes of their own.
+ */
+ function addToBodyAttributes( $out, &$bodyAttrs ) {
+ // does nothing by default
+ }
+
/**
* URL to the logo
*/
$ret = '<li>';
foreach ( $lines as $line ) {
- $m = array();
$display = ltrim( $line );
$ident = strlen( $line ) - strlen( $display );
$diff = $ident - $curIdent;
function subPageSubtitle() {
$subpages = '';
- if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) {
+ if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this ) ) ) {
return $subpages;
}
SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
array(), array( 'returnto' => $returnTo )
),
- $this->specialLink( 'preferences' ),
+ $this->specialLink( 'Preferences' ),
) );
}
$s = array(
$this->mainPageLink(),
- $this->specialLink( 'recentchanges' )
+ $this->specialLink( 'Recentchanges' )
);
if ( $wgOut->isArticleRelated() ) {
global $wgStylePath;
$url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
- $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
-
- return $img;
+ $text = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
+ wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
+ return $text;
}
function lastModified() {
return $s;
}
+ /**
+ * Renders a $wgFooterIcons icon acording to the method's arguments
+ * @param $icon Array: The icon to build the html for, see $wgFooterIcons for the format of this array
+ * @param $withImage Boolean: Whether to use the icon's image or output a text-only footericon
+ */
+ function makeFooterIcon( $icon, $withImage = 'withImage' ) {
+ if ( is_string( $icon ) ) {
+ $html = $icon;
+ } else { // Assuming array
+ $url = $icon["url"];
+ unset( $icon["url"] );
+ if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
+ $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
+ } else {
+ $html = htmlspecialchars( $icon["alt"] );
+ }
+ if ( $url ) {
+ $html = Html::rawElement( 'a', array( "href" => $url ), $html );
+ }
+ }
+ return $html;
+ }
+
/**
* Gets the link to the wiki's main page.
* @return string
return $s;
}
- private function footerLink( $desc, $page ) {
+ public function footerLink( $desc, $page ) {
// if the link description has been set to "-" in the default language,
if ( wfMsgForContent( $desc ) == '-' ) {
// then it is disabled, for all languages.
}
}
+ /**
+ * Return a fully resolved style path url to images or styles stored in the common folder.
+ * This method returns a url resolved using the configured skin style path
+ * and includes the style version inside of the url.
+ * @param $name String: The name or path of a skin resource file
+ * @return String The fully resolved style path url including styleversion
+ */
+ function getCommonStylePath( $name ) {
+ global $wgStylePath, $wgStyleVersion;
+ return "$wgStylePath/common/$name?$wgStyleVersion";
+ }
+
+ /**
+ * Return a fully resolved style path url to images or styles stored in the curent skins's folder.
+ * This method returns a url resolved using the configured skin style path
+ * and includes the style version inside of the url.
+ * @param $name String: The name or path of a skin resource file
+ * @return String The fully resolved style path url including styleversion
+ */
+ function getSkinStylePath( $name ) {
+ global $wgStylePath, $wgStyleVersion;
+ return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
+ }
+
/* these are used extensively in SkinTemplate, but also some other places */
static function makeMainPageUrl( $urlaction = '' ) {
$title = Title::newMainPage();
return array(
'href' => $title->getLocalURL( $urlaction ),
- 'exists' => $title->getArticleID() != 0 ? true : false
+ 'exists' => $title->getArticleID() != 0,
);
}
$line = substr( $line, 2, strlen( $line ) - 4 );
- if ( is_null( $wgParser->mOptions ) ) {
- $wgParser->mOptions = new ParserOptions();
- }
-
- $wgParser->mOptions->setEditSection( false );
- $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions )->getText();
+ $options = new ParserOptions();
+ $options->setEditSection( false );
+ $options->setInterfaceMessage( true );
+ $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $options )->getText();
} else {
continue;
}