*/
# See skin.txt
-require_once( 'Linker.php' );
-require_once( 'Image.php' );
-
-# 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
-#
-
-$skinDir = dir( $wgStyleDirectory );
-
-# while code from www.php.net
-while (false !== ($file = $skinDir->read())) {
- // Skip non-PHP files, hidden files, and '.dep' includes
- if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
- $aSkin = $matches[1];
- $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
- }
-}
-$skinDir->close();
-unset($matches);
/**
* The main skin class that provide methods and properties for all other skins.
* @return array of strings
* @static
*/
- function getSkinNames() {
+ 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())) {
+ // Skip non-PHP files, hidden files, and '.dep' includes
+ if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
+ $aSkin = $matches[1];
+ $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
+ }
+ }
+ $skinDir->close();
+ $skinsInitialised = true;
+ wfProfileOut( __METHOD__ . '-init' );
+ }
return $wgValidSkinNames;
}
* @return string
* @static
*/
- function normalizeKey( $key ) {
+ static function normalizeKey( $key ) {
global $wgDefaultSkin;
$skinNames = Skin::getSkinNames();
* @return Skin
* @static
*/
- function &newFromKey( $key ) {
+ static function &newFromKey( $key ) {
+ global $wgStyleDirectory;
+
$key = Skin::normalizeKey( $key );
$skinNames = Skin::getSkinNames();
$skinName = $skinNames[$key];
- global $IP;
-
# Grab the skin class and initialise it.
wfSuppressWarnings();
// Preload base classes to work around APC/PHP5 bug
- include_once( $IP.'/skins/'.$skinName.'.deps.php' );
+ include_once( "{$wgStyleDirectory}/{$skinName}.deps.php" );
wfRestoreWarnings();
- require_once( $IP.'/skins/'.$skinName.'.php' );
+ require_once( "{$wgStyleDirectory}/{$skinName}.php" );
# Check if we got if not failback to default skin
$className = 'Skin'.$skinName;
# is no longer valid.
wfDebug( "Skin class does not exist: $className\n" );
$className = 'SkinStandard';
- require_once( $IP.'/skins/Standard.php' );
+ require_once( "{$wgStyleDirectory}/Standard.php" );
}
- $skin =& new $className;
+ $skin = new $className;
return $skin;
}
$out->out( "\n</body></html>" );
}
+ /*static*/ function makeGlobalVariablesScript( $data ) {
+ $r = '<script type= "' . $data['jsmimetype'] . '">
+ var skin = "' . Xml::escapeJsString( $data['skinname'] ) . '";
+ var stylepath = "' . Xml::escapeJsString( $data['stylepath'] ) . '";
+
+ var wgArticlePath = "' . Xml::escapeJsString( $data['articlepath'] ) . '";
+ var wgScriptPath = "' . Xml::escapeJsString( $data['scriptpath'] ) . '";
+ var wgServer = "' . Xml::escapeJsString( $data['serverurl'] ) . '";
+
+ var wgCanonicalNamespace = "' . Xml::escapeJsString( $data['nscanonical'] ) . '";
+ var wgPageName = "' . Xml::escapeJsString( $data['titleprefixeddbkey'] ) . '";
+ var wgTitle = "' . Xml::escapeJsString( $data['titletext'] ) . '";
+ var wgArticleId = ' . (int)$data['articleid'] . ';
+
+ var wgUserName = ' . ( $data['username'] == NULL ? 'null' : ( '"' . Xml::escapeJsString( $data['username'] ) . '"' ) ) . ';
+ var wgUserLanguage = "' . Xml::escapeJsString( $data['userlang'] ) . '";
+ var wgContentLanguage = "' . Xml::escapeJsString( $data['lang'] ) . '";
+ </script>
+ ';
+
+ return $r;
+ }
+
function getHeadScripts() {
global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType;
- $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
+ global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
+ global $wgTitle, $wgCanonicalNamespaceNames;
+
+ $nsname = @$wgCanonicalNamespaceNames[ $wgTitle->getNamespace() ];
+ if ( $nsname === NULL ) $nsname = $wgTitle->getNsText();
+
+ $vars = array(
+ 'jsmimetype' => $wgJsMimeType,
+ 'skinname' => $this->getSkinName(),
+ 'stylepath' => $wgStylePath,
+ 'articlepath' => $wgArticlePath,
+ 'scriptpath' => $wgScriptPath,
+ 'serverurl' => $wgServer,
+ 'nscanonical' => $nsname,
+ 'titleprefixeddbkey' => $wgTitle->getPrefixedDBKey(),
+ 'titletext' => $wgTitle->getText(),
+ 'articleid' => $wgTitle->getArticleId(),
+ 'username' => $wgUser->isAnon() ? NULL : $wgUser->getName(),
+ 'userlang' => $wgLang->getCode(),
+ 'lang' => $wgContLang->getCode(),
+ );
+
+ $r = Skin::makeGlobalVariablesScript( $vars );
+
+ $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
$userpage = $wgUser->getUserPage();
$userjs = htmlspecialchars( $this->makeUrl(
. '<input type="text" name="search" size="19" value="'
. htmlspecialchars(substr($search,0,256)) . "\" />\n"
. '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
- . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
+ . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
return $s;
}
* @TODO crash bug913. Need to be rewrote completly.
*/
function specialPagesList() {
- global $wgUser, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
+ global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
require_once('SpecialPage.php');
$a = array();
$pages = SpecialPage::getPages();
}
// Other special pages that are restricted.
- // Copied from SpecialSpecialpages.php
- foreach($wgAvailableRights as $right) {
- if( $wgUser->isAllowed($right) ) {
- /** Add all pages for this right */
- if(isset($pages[$right])) {
- foreach($pages[$right] as $name => $page) {
- $a[$name] = $page->getDescription();
- }
- }
+ foreach ( $pages['restricted'] as $name => $page ) {
+ if( $wgUser->isAllowed( $page->getRestriction() ) ) {
+ $a[$name] = $page->getDescription();
}
}
*/
function buildSidebar() {
global $wgDBname, $parserMemc, $wgEnableSidebarCache;
- global $wgLanguageCode, $wgContLanguageCode;
+ global $wgLang, $wgContLang;
$fname = 'SkinTemplate::buildSidebar';
$key = "{$wgDBname}:sidebar";
$cacheSidebar = $wgEnableSidebarCache &&
- ($wgLanguageCode == $wgContLanguageCode);
+ ($wgLang->getCode() == $wgContLang->getCode());
if ($cacheSidebar) {
$cachedsidebar = $parserMemc->get( $key );