Index: trunk/phase3/includes/Skin.php |
— | — | @@ -260,6 +260,29 @@ |
261 | 261 | $out->out( "\n</body></html>" ); |
262 | 262 | } |
263 | 263 | |
| 264 | + /*static*/ function makeGlobalVariablesScript( $data ) { |
| 265 | + $r = '<script type= "' . $data['jsmimetype'] . '"> |
| 266 | + var skin = "' . Xml::escapeJsString( $data['skinname'] ) . '"; |
| 267 | + var stylepath = "' . Xml::escapeJsString( $data['stylepath'] ) . '"; |
| 268 | + |
| 269 | + var wgArticlePath = "' . Xml::escapeJsString( $data['articlepath'] ) . '"; |
| 270 | + var wgScriptPath = "' . Xml::escapeJsString( $data['scriptpath'] ) . '"; |
| 271 | + var wgServer = "' . Xml::escapeJsString( $data['serverurl'] ) . '"; |
| 272 | + |
| 273 | + var wgCanonicalNamespace = "' . Xml::escapeJsString( $data['nscanonical'] ) . '"; |
| 274 | + var wgPageName = "' . Xml::escapeJsString( $data['titleprefixeddbkey'] ) . '"; |
| 275 | + var wgTitle = "' . Xml::escapeJsString( $data['titletext'] ) . '"; |
| 276 | + var wgArticleId = ' . (int)$data['articleid'] . '; |
| 277 | + |
| 278 | + var wgUserName = ' . ( $data['username'] == NULL ? 'null' : ( '"' . Xml::escapeJsString( $data['username'] ) . '"' ) ) . '; |
| 279 | + var wgUserLanguage = "' . Xml::escapeJsString( $data['userlang'] ) . '"; |
| 280 | + var wgContentLanguage = "' . Xml::escapeJsString( $data['lang'] ) . '"; |
| 281 | + </script> |
| 282 | + '; |
| 283 | + |
| 284 | + return $r; |
| 285 | + } |
| 286 | + |
264 | 287 | function getHeadScripts() { |
265 | 288 | global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType; |
266 | 289 | global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang; |
— | — | @@ -268,26 +291,24 @@ |
269 | 292 | $nsname = @$wgCanonicalNamespaceNames[ $wgTitle->getNamespace() ]; |
270 | 293 | if ( $nsname === NULL ) $nsname = $wgTitle->getNsText(); |
271 | 294 | |
272 | | - $r = '<script type= "'.$wgJsMimeType.'"> |
273 | | - var skin = "' . Xml::escapeJsString( $this->getSkinName() ) . '"; |
274 | | - var stylepath = "' . Xml::escapeJsString( $wgStylePath ) . '"; |
| 295 | + $vars = array( |
| 296 | + 'jsmimetype' => $wgJsMimeType, |
| 297 | + 'skinname' => $this->getSkinName(), |
| 298 | + 'stylepath' => $wgStylePath, |
| 299 | + 'articlepath' => $wgArticlePath, |
| 300 | + 'scriptpath' => $wgScriptPath, |
| 301 | + 'serverurl' => $wgServer, |
| 302 | + 'nscanonical' => $nsname, |
| 303 | + 'titleprefixeddbkey' => $wgTitle->getPrefixedDBKey(), |
| 304 | + 'titletext' => $wgTitle->getText(), |
| 305 | + 'articleid' => $wgTitle->getArticleId(), |
| 306 | + 'username' => $wgUser->isAnon() ? NULL : $wgUser->getName(), |
| 307 | + 'userlang' => $wgLang->getCode(), |
| 308 | + 'lang' => $wgContLang->getCode(), |
| 309 | + ); |
275 | 310 | |
276 | | - var wgArticlePath = "' . Xml::escapeJsString( $wgArticlePath ) . '"; |
277 | | - var wgScriptPath = "' . Xml::escapeJsString( $wgScriptPath ) . '"; |
278 | | - var wgServer = "' . Xml::escapeJsString( $wgServer ) . '"; |
279 | | - |
280 | | - var wgCanonicalNamespace = "' . Xml::escapeJsString( $nsname ) . '"; |
281 | | - var wgPageName = "' . Xml::escapeJsString( $wgTitle->getPrefixedDBKey() ) . '"; |
282 | | - var wgTitle = "' . Xml::escapeJsString( $wgTitle->getText() ) . '"; |
283 | | - var wgArticleId = ' . (int)$wgTitle->getArticleId() . '; |
284 | | - |
285 | | - var wgUserName = ' . ( $wgUser->isAnon() ? 'null' : ( '"' . Xml::escapeJsString( $wgUser->getName() ) . '"' ) ) . '; |
286 | | - var wgUserLanguage = "' . Xml::escapeJsString( $wgLang->getCode() ) . '"; |
287 | | - var wgContentLanguage = "' . Xml::escapeJsString( $wgContLang->getCode() ) . '"; |
288 | | - var wgSkinClass = "' . Xml::escapeJsString( get_class( $this ) ) . '"; |
289 | | - </script> |
290 | | - '; |
291 | | - |
| 311 | + $r = Skin::makeGlobalVariablesScript( $vars ); |
| 312 | + |
292 | 313 | $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n"; |
293 | 314 | if( $wgAllowUserJs && $wgUser->isLoggedIn() ) { |
294 | 315 | $userpage = $wgUser->getUserPage(); |
Index: trunk/phase3/skins/MonoBook.php |
— | — | @@ -65,29 +65,7 @@ |
66 | 66 | <!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script> |
67 | 67 | <meta http-equiv="imagetoolbar" content="no" /><![endif]--> |
68 | 68 | |
69 | | - <script type="<?php $this->text('jsmimetype') ?>"> |
70 | | - var skin = "<?php $this->jstext('skinname')?>"; |
71 | | - var stylepath = "<?php $this->jstext('stylepath')?>"; |
72 | | - |
73 | | - var wgArticlePath = "<?php $this->jstext( 'articlepath' ); ?>"; |
74 | | - var wgScriptPath = "<?php $this->jstext( 'scriptpath' ); ?>"; |
75 | | - var wgServer = "<?php $this->jstext( 'serverurl' ); ?>"; |
76 | | - |
77 | | - var wgCanonicalNamespace = "<?php $this->jstext( 'nscanonical' ); ?>"; |
78 | | - var wgPageName = "<?php $this->jstext( 'titleprefixeddbkey' ); ?>"; |
79 | | - var wgTitle = "<?php $this->jstext( 'titletext' ); ?>"; |
80 | | - var wgArticleId = <?php (int) $this->jstext( 'articleid' ); ?>; |
81 | | - |
82 | | -<?php if($this->data['username']) { ?> |
83 | | - var wgUserName = "<?php $this->jstext( 'username' ); ?>"; |
84 | | - var wgUserLanguage = "<?php $this->jstext( 'userlang' ); ?>"; |
85 | | -<?php } else { ?> |
86 | | - var wgUserName = null; |
87 | | - var wgUserLanguage = "<?php $this->jstext( 'userlang' ); ?>"; |
88 | | -<?php } ?> |
89 | | - var wgContentLanguage = "<?php $this->jstext( 'lang' ); ?>"; |
90 | | - var wgSkinClass = "<?php $this->jstext( 'skinclass' ); ?>"; |
91 | | - </script> |
| 69 | + <?php print Skin::makeGlobalVariablesScript( $this->data ); ?> |
92 | 70 | |
93 | 71 | <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?1"><!-- wikibits js --></script> |
94 | 72 | <?php if($this->data['jsvarurl' ]) { ?> |