X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=59c89bb03c65afeb46a0090b731fa05b0f507df4;hb=f3710b35e5a7d013ad7117f7405cc6f40942699e;hp=4dabb9b82feb21aebc8f64a9eab1953d80d86c93;hpb=837ee9245632a7ec82861d9be29720905f5a4dd9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 4dabb9b82f..59c89bb03c 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -40,20 +40,24 @@ class Skin extends Linker { static function getSkinNames() { global $wgValidSkinNames; static $skinsInitialised = false; + if ( !$skinsInitialised ) { # Get a list of available skins # Build using the regular expression '^(.*).php$' # Array keys are all lower case, array value keep the case used by filename # wfProfileIn( __METHOD__ . '-init' ); + global $wgStyleDirectory; + $skinDir = dir( $wgStyleDirectory ); # while code from www.php.net - while( false !== ( $file = $skinDir->read() ) ) { + while ( false !== ( $file = $skinDir->read() ) ) { // Skip non-PHP files, hidden files, and '.dep' includes $matches = array(); - if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) { + + if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) { $aSkin = $matches[1]; $wgValidSkinNames[strtolower( $aSkin )] = $aSkin; } @@ -73,10 +77,13 @@ class Skin extends Linker { */ public static function getUsableSkins() { global $wgSkipSkins; + $usableSkins = self::getSkinNames(); + foreach ( $wgSkipSkins as $skip ) { unset( $usableSkins[$skip] ); } + return $usableSkins; } @@ -89,15 +96,16 @@ class Skin extends Linker { */ static function normalizeKey( $key ) { global $wgDefaultSkin; + $skinNames = Skin::getSkinNames(); - if( $key == '' ) { + if ( $key == '' ) { // Don't return the default immediately; // in a misconfiguration we need to fall back. $key = $wgDefaultSkin; } - if( isset( $skinNames[$key] ) ) { + if ( isset( $skinNames[$key] ) ) { return $key; } @@ -109,13 +117,13 @@ class Skin extends Linker { 2 => 'cologneblue' ); - if( isset( $fallback[$key] ) ) { + if ( isset( $fallback[$key] ) ) { $key = $fallback[$key]; } - if( isset( $skinNames[$key] ) ) { + if ( isset( $skinNames[$key] ) ) { return $key; - } else if( isset( $skinNames[$wgDefaultSkin] ) ) { + } else if ( isset( $skinNames[$wgDefaultSkin] ) ) { return $wgDefaultSkin; } else { return 'vector'; @@ -140,13 +148,14 @@ class Skin extends Linker { if ( !class_exists( $className ) ) { // Preload base classes to work around APC/PHP5 bug $deps = "{$wgStyleDirectory}/{$skinName}.deps.php"; - if( file_exists( $deps ) ) { + + 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 ) ) { + 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 @@ -176,12 +185,14 @@ class Skin extends Linker { if ( $wgOut->isQuickbarSuppressed() ) { return 0; } + $q = $wgUser->getOption( 'quickbar', 0 ); + return $q; } function initPage( OutputPage $out ) { - global $wgFavicon, $wgAppleTouchIcon; + global $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI; wfProfileIn( __METHOD__ ); @@ -189,11 +200,11 @@ class Skin extends Linker { # 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 ) { + if ( false !== $wgAppleTouchIcon ) { $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) ); } - if( false !== $wgFavicon ) { + if ( false !== $wgFavicon ) { $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) ); } @@ -203,7 +214,19 @@ class Skin extends Linker { '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 ); @@ -233,28 +256,41 @@ class Skin extends Linker { } $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. + *