From edb2c0eea5e905877d5c75e113b95b0b23275178 Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Fri, 28 Jul 2006 22:52:46 +0000 Subject: [PATCH] Factored code for global JS variables into a function --- includes/Skin.php | 59 +++++++++++++++++++++++++++++++--------------- skins/MonoBook.php | 24 +------------------ 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index d15fca1e3b..d8dbc16ac0 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -260,6 +260,29 @@ class Skin extends Linker { $out->out( "\n" ); } + /*static*/ function makeGlobalVariablesScript( $data ) { + $r = ' + '; + + return $r; + } + function getHeadScripts() { global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType; global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang; @@ -268,26 +291,24 @@ class Skin extends Linker { $nsname = @$wgCanonicalNamespaceNames[ $wgTitle->getNamespace() ]; if ( $nsname === NULL ) $nsname = $wgTitle->getNsText(); - $r = ' - '; + $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 .= "\n"; if( $wgAllowUserJs && $wgUser->isLoggedIn() ) { $userpage = $wgUser->getUserPage(); diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 0890be9781..9532eabede 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -65,29 +65,7 @@ class MonoBookTemplate extends QuickTemplate { - + data ); ?> data['jsvarurl' ]) { ?> -- 2.20.1