read() ) ) { // Skip non-PHP files, hidden files, and '.dep' includes $matches = array(); if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) { $aSkin = $matches[1]; $wgValidSkinNames[strtolower( $aSkin )] = $aSkin; } } $skinDir->close(); $skinsInitialised = true; wfProfileOut( __METHOD__ . '-init' ); } return $wgValidSkinNames; } /** * Fetch the list of usable skins in regards to $wgSkipSkins. * Useful for Special:Preferences and other places where you * only want to show skins users _can_ use. * @return array of strings */ public static function getUsableSkins() { global $wgSkipSkins; $usableSkins = self::getSkinNames(); foreach ( $wgSkipSkins as $skip ) { unset( $usableSkins[$skip] ); } return $usableSkins; } /** * Normalize a skin preference value to a form that can be loaded. * If a skin can't be found, it will fall back to the configured * default (or the old 'Classic' skin if that's broken). * @param $key String: 'monobook', 'standard', etc. * @return string */ static function normalizeKey( $key ) { global $wgDefaultSkin; $skinNames = Skin::getSkinNames(); if ( $key == '' ) { // Don't return the default immediately; // in a misconfiguration we need to fall back. $key = $wgDefaultSkin; } if ( isset( $skinNames[$key] ) ) { return $key; } // Older versions of the software used a numeric setting // in the user preferences. $fallback = array( 0 => $wgDefaultSkin, 1 => 'nostalgia', 2 => 'cologneblue' ); if ( isset( $fallback[$key] ) ) { $key = $fallback[$key]; } if ( isset( $skinNames[$key] ) ) { return $key; } else if ( isset( $skinNames[$wgDefaultSkin] ) ) { return $wgDefaultSkin; } else { return 'vector'; } } /** * Factory method for loading a skin of a given type * @param $key String: 'monobook', 'standard', etc. * @return Skin */ static function &newFromKey( $key ) { global $wgStyleDirectory; $key = Skin::normalizeKey( $key ); $skinNames = Skin::getSkinNames(); $skinName = $skinNames[$key]; $className = 'Skin' . ucfirst( $key ); # Grab the skin class and initialise it. if ( !class_exists( $className ) ) { // Preload base classes to work around APC/PHP5 bug $deps = "{$wgStyleDirectory}/{$skinName}.deps.php"; if ( file_exists( $deps ) ) { include_once( $deps ); } require_once( "{$wgStyleDirectory}/{$skinName}.php" ); # Check if we got if not failback to default skin if ( !class_exists( $className ) ) { # DO NOT die if the class isn't found. This breaks maintenance # scripts and can cause a user account to be unrecoverable # except by SQL manipulation if a previously valid skin name # is no longer valid. wfDebug( "Skin class does not exist: $className\n" ); $className = 'SkinVector'; require_once( "{$wgStyleDirectory}/Vector.php" ); } } $skin = new $className; return $skin; } /** @return string path to the skin stylesheet */ function getStylesheet() { return 'common/wikistandard.css'; } /** @return string skin name */ public function getSkinName() { return $this->skinname; } function qbSetting() { global $wgOut, $wgUser; if ( $wgOut->isQuickbarSuppressed() ) { return 0; } $q = $wgUser->getOption( 'quickbar', 0 ); return $q; } function initPage( OutputPage $out ) { global $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI; wfProfileIn( __METHOD__ ); # Generally the order of the favicon and apple-touch-icon links # should not matter, but Konqueror (3.5.9 at least) incorrectly # uses whichever one appears later in the HTML source. Make sure # apple-touch-icon is specified first to avoid this. if ( false !== $wgAppleTouchIcon ) { $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) ); } if ( false !== $wgFavicon ) { $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) ); } # OpenSearch description link $out->addLink( array( 'rel' => 'search', 'type' => 'application/opensearchdescription+xml', 'href' => wfScript( 'opensearch_desc' ), '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; $this->preloadExistence(); wfProfileOut( __METHOD__ ); } /** * Preload the existence of three commonly-requested pages in a single query */ function preloadExistence() { global $wgUser; // User/talk link $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() ); // Other tab link if ( $this->mTitle->getNamespace() == NS_SPECIAL ) { // nothing } elseif ( $this->mTitle->isTalkPage() ) { $titles[] = $this->mTitle->getSubjectPage(); } else { $titles[] = $this->mTitle->getTalkPage(); } $lb = new LinkBatch( $titles ); $lb->setCaller( __METHOD__ ); $lb->execute(); } /** * Adds metadata links below to the HTML output. *
    *
  1. Creative Commons *
    See http://wiki.creativecommons.org/Extend_Metadata. *
  2. *
  3. Dublin Core
  4. *
  5. Use hreflang to specify canonical and alternate links *
    See http://www.google.com/support/webmasters/bin/answer.py?answer=189077 *
  6. *
  7. Copyright
  8. *
      * * @param $out Object: instance of OutputPage */ function addMetadataLinks( OutputPage $out ) { global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf; global $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgContLang; global $wgRightsPage, $wgRightsUrl; if ( $out->isArticleRelated() ) { # note: buggy CC software only reads first "meta" link if ( $wgEnableCreativeCommonsRdf ) { $out->addMetadataLink( array( 'title' => 'Creative Commons', 'type' => 'application/rdf+xml', 'href' => $this->mTitle->getLocalURL( 'action=creativecommons' ) ) ); } if ( $wgEnableDublinCoreRdf ) { $out->addMetadataLink( array( 'title' => 'Dublin Core', 'type' => 'application/rdf+xml', 'href' => $this->mTitle->getLocalURL( 'action=dublincore' ) ) ); } } 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 ); if ( $copy ) { $copyright = $copy->getLocalURL(); } } if ( !$copyright && $wgRightsUrl ) { $copyright = $wgRightsUrl; } if ( $copyright ) { $out->addLink( array( 'rel' => 'copyright', 'href' => $copyright ) ); } } /** * Set some local variables */ protected function setMembers() { global $wgUser; $this->mUser = $wgUser; $this->userpage = $wgUser->getUserPage()->getPrefixedText(); $this->usercss = false; } /** * Set the title * @param $t Title object to use */ public function setTitle( $t ) { $this->mTitle = $t; } /** Get the title */ public function getTitle() { return $this->mTitle; } /** * Outputs the HTML generated by other functions. * @param $out Object: instance of OutputPage */ function outputPage( OutputPage $out ) { global $wgDebugComments; wfProfileIn( __METHOD__ ); $this->setMembers(); $this->initPage( $out ); // See self::afterContentHook() for documentation $afterContent = $this->afterContentHook(); $out->out( $out->headElement( $this ) ); if ( $wgDebugComments ) { $out->out( "\n" ); } $out->out( $this->beforeContent() ); $out->out( $out->mBodytext . "\n" ); $out->out( $this->afterContent() ); $out->out( $afterContent ); $out->out( $this->bottomScripts( $out ) ); $out->out( wfReportTime() ); $out->out( "\n" ); wfProfileOut( __METHOD__ ); } static function makeVariablesScript( $data ) { if ( $data ) { return Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( ResourceLoader::makeConfigSetScript( $data ) ) ); } else { return ''; } } /** * Make a