X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2FSkin.php;h=17da161abe3bfbeba3798e057238d34cb6c5c1ef;hb=9e638dbef402377fb1c02f7228ec2fa611ee7aa0;hp=345ae09c113d02c4f39b50ca1d47c7698b782fa9;hpb=e4dbb583f24ee8ee1c74747164b28f2082fe9fe6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 345ae09c11..17da161abe 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -178,17 +178,15 @@ class Skin extends Linker { wfProfileIn( __METHOD__ ); - # Add favicons and Apple touch icons, if they're not the defaults - # # Generally the order of the favicon and apple-touch-icon links # 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 && wfExpandUrl('/apple-touch-icon.png') != wfExpandUrl($wgAppleTouchIcon) ) { + if( false !== $wgAppleTouchIcon ) { $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) ); } - if( false !== $wgFavicon && wfExpandUrl('/favicon.ico') != wfExpandUrl($wgFavicon) ) { + if( false !== $wgFavicon ) { $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) ); } @@ -333,13 +331,17 @@ class Skin extends Linker { } static function makeVariablesScript( $data ) { - $r = array(); - foreach ( $data as $name => $value ) { - $encValue = Xml::encodeJsVar( $value ); - $r[] = "var $name = $encValue;"; + if( $data ) { + $r = array(); + foreach ( $data as $name => $value ) { + $encValue = Xml::encodeJsVar( $value ); + $r[] = "$name=$encValue"; + } + $js = 'var ' . implode( ",\n", $r ) . ';'; + return Html::inlineScript( "\n$js\n" ); + } else { + return ''; } - return Html::inlineScript( "\n\t\t" . implode( "\n\t\t", $r ) . - "\n\t\t" ); } /** @@ -353,17 +355,18 @@ class Skin extends Linker { # Weird back-compat stuff. $skinName = $skinName['skinname']; } - global $wgScript, $wgTitle, $wgStylePath, $wgUser; - global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant; - global $wgCanonicalNamespaceNames, $wgOut, $wgArticle; + global $wgScript, $wgTitle, $wgStylePath, $wgUser, $wgScriptExtension; + global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang; + global $wgOut, $wgArticle; global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths; global $wgUseAjax, $wgAjaxWatch; global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI; global $wgRestrictionTypes, $wgLivePreview; global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest; + global $wgSitename, $wgEnableIframeApiProxy, $wgEnableJS2system; $ns = $wgTitle->getNamespace(); - $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText(); + $nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $wgTitle->getNsText(); $separatorTransTable = $wgContLang->separatorTransformTable(); $separatorTransTable = $separatorTransTable ? $separatorTransTable : array(); $compactSeparatorTransTable = array( @@ -381,14 +384,17 @@ class Skin extends Linker { $vars = array( 'skin' => $skinName, 'stylepath' => $wgStylePath, + 'urlprotocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, + 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object)$wgActionPaths, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, - 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBkey() ), + 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ? + SpecialPage::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), @@ -397,7 +403,6 @@ class Skin extends Linker { 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(), 'wgUserGroups' => $wgUser->isAnon() ? NULL : $wgUser->getEffectiveGroups(), - 'wgUserVariant' => $wgVariant->getCode(), 'wgUserLanguage' => $wgLang->getCode(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgBreakFrames' => $wgBreakFrames, @@ -408,15 +413,18 @@ class Skin extends Linker { 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, + 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), + 'wgNamespaceIds' => $wgContLang->getNamespaceIds(), + 'wgSiteName' => $wgSitename, ); - if ( !( $wgContLang->hasVariants() ) ) { - unset( $vars['wgUserVariant'] ); + if ( $wgContLang->hasVariants() ) { + $vars['wgUserVariant'] = $wgContLang->getPreferredVariant(); } //if on upload page output the extension list & js_upload - if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ){ + if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ) { global $wgFileExtensions, $wgAjaxUploadInterface; - $vars['wgFileExtensions'] = $wgFileExtensions; + $vars['wgFileExtensions'] = $wgFileExtensions; $vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface; } @@ -437,6 +445,17 @@ class Skin extends Linker { $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' ); } + //add api proxy var and script link if on the special proxy page: + if( $wgEnableJS2system && + $wgTitle->getNamespace() == NS_MEDIAWIKI && + $wgTitle->getDBKey() == 'ApiProxy' ) + { + $vars['wgEnableIframeApiProxy'] = $wgEnableIframeApiProxy; + //also add the apiProxy Page script if we are on that page + if( $wgEnableIframeApiProxy ) + $wgOut->addScriptClass( 'apiProxyPage' ); + } + if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) { $msgs = (object)array(); foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) { @@ -450,42 +469,6 @@ class Skin extends Linker { return self::makeVariablesScript( $vars ); } - /** - * Return a random selection of the scripts we want in the header, - * according to no particular rhyme or reason. Various other scripts are - * returned from a haphazard assortment of other functions scattered over - * various files. This entire hackish system needs to be burned to the - * ground and rebuilt. - * - * @param $out OutputPage object, should be $wgOut - * - * @return string Raw HTML to output to - */ - function getHeadScripts( OutputPage $out ) { - global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion, $wgOut; - global $wgUseSiteJs; - - $vars = self::makeGlobalVariablesScript( $this->getSkinName() ); - - //moved wikibits to be called earlier on - //$out->addScriptFile( "{$wgStylePath}/common/wikibits.js" ); - if( $wgUseSiteJs ) { - $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : ''; - $wgOut->addScriptFile( self::makeUrl( '-', - "action=raw$jsCache&gen=js&useskin=" . - urlencode( $this->getSkinName() ) - ) - ); - } - if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) { - $userpage = $wgUser->getUserPage(); - $userjs = self::makeUrl( - $userpage->getPrefixedText().'/'.$this->getSkinName().'.js', - 'action=raw&ctype='.$wgJsMimeType ); - $wgOut->addScriptFile( $userjs ); - } - return "\t" . $vars . "\t" . $out->mScripts; - } /** * To make it harder for someone to slip a user a fake @@ -496,9 +479,8 @@ class Skin extends Linker { * * @param string $action * @return bool - * @private */ - function userCanPreview( $action ) { + public function userCanPreview( $action ) { global $wgRequest, $wgUser; if( $action != 'submit' ) @@ -524,15 +506,15 @@ class Skin extends Linker { * top. For now Monobook.js will be maintained, but it should be consi- * dered deprecated. * - * @param force_skin lets you override the skin name + * @param $force_skin string If set, overrides the skin name * * @return string */ - public function generateUserJs( $skinName = null) { + public function generateUserJs( $skinName = null ) { global $wgStylePath; wfProfileIn( __METHOD__ ); - if(!$skinName){ + if( !$skinName ) { $skinName = $this->getSkinName(); } @@ -548,7 +530,7 @@ class Skin extends Linker { $s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n"; // avoid inclusion of non defined user JavaScript (with custom skins only) // by checking for default message content - $msgKey = ucfirst( $skinName ).'.js'; + $msgKey = ucfirst( $skinName ) . '.js'; $userJS = wfMsgForContent( $msgKey ); if ( !wfEmptyMsg( $msgKey, $userJS ) ) { $s .= $userJS; @@ -670,9 +652,8 @@ END; $action = $wgRequest->getVal( 'action' ); # If we're previewing the CSS page, use it if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) { - $previewCss = $wgRequest->getText( 'wpTextbox1' ); // @FIXME: properly escape the cdata! - $this->usercss = "/**/"; + $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) ); } else { $out->addStyle( self::makeUrl( $this->userpage . '/' . $this->getSkinName() .'.css', 'action=raw&ctype=text/css' ) ); @@ -711,7 +692,7 @@ END; $a['onload'] = $wgOut->getOnloadHandler(); $a['class'] = 'mediawiki' . - ' '.( $wgContLang->isRTL() ? 'rtl' : 'ltr' ). + ' '.( $wgContLang->getDir() ). ' '.$this->getPageClasses( $this->mTitle ) . ' skin-'. Sanitizer::escapeClass( $this->getSkinName() ); return $a; @@ -775,13 +756,13 @@ END; } elseif( $left ) { $s .= $this->getQuickbarCompensator( $rows ); } - $l = $wgContLang->isRTL() ? 'right' : 'left'; + $l = $wgContLang->alignStart(); $s .= "\n"; $s .= $this->topLinks(); $s .= "

" . $this->pageTitleLinks() . "

\n"; - $r = $wgContLang->isRTL() ? 'left' : 'right'; + $r = $wgContLang->alignEnd(); $s .= "\n"; $s .= $this->nameAndLogin(); $s .= "\n
" . $this->searchForm() . ""; @@ -819,7 +800,7 @@ END; // Use Unicode bidi embedding override characters, // to make sure links don't smash each other up in ugly ways. - $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; + $dir = $wgContLang->getDir(); $embed = ""; $pop = ''; @@ -894,18 +875,21 @@ END; } function getCategories() { - $catlinks=$this->getCategoryLinks(); + $catlinks = $this->getCategoryLinks(); $classes = 'catlinks'; - if( strpos( $catlinks, '