<?php
if ( ! defined( 'MEDIAWIKI' ) )
- die( -1 );
+ die( 1 );
/**
*
*/
# See skin.txt
-require_once( 'Linker.php' );
-require_once( 'Image.php' );
-
-# Get a list of all skins available in /skins/
-# Build using the regular expression '^(.*).php$'
-# Array keys are all lower case, array value keep the case used by filename
-#
-
-$skinDir = dir($IP.'/skins');
-
-# 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(
/**
* Some styles that are set by user through the user settings interface.
- * @todo undefined variables (bug #4940)
*/
function doGetUserStyles() {
global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
$s = '';
if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
- # FIXME: $action undefined, bug #4940
- if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
+ if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
$s .= $wgRequest->getText('wpTextbox1');
} else {
$userpage = $wgUser->getUserPage();
$pop = '</span>';
$t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks ) . $pop;
- $msg = count( $wgOut->mCategoryLinks ) === 1 ? 'categories1' : 'categories';
+ $msg = wfMsgExt('categories', array('parsemag', 'escape'), count( $wgOut->mCategoryLinks ));
$s = $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Categories' ),
- wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
+ $msg, 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
. ': ' . $t;
# optional 'dmoz-like' category browser. Will be shown under the list
return wfMsg( $msg,
$this->makeKnownLink(
$wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
- wfMsg( 'restorelink' . ($n == 1 ? '1' : ''), $n ) ) );
+ wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
}
return '';
}
. '<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();
}
}
$text = wfMsg('userpage');
break;
case NS_PROJECT:
- $text = wfMsg('wikipediapage');
+ $text = wfMsg('projectpage');
break;
case NS_IMAGE:
$text = wfMsg('imagepage');
*/
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 );