X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkin.php;h=15b7a1ffa6a7613b790c5622dcc564376aa59118;hb=3a813c06d4f0c25c0cdf2a4669a530e33f51312c;hp=3feb5835a0c303b232bb9827b36b2e32b1127bdd;hpb=757f4717d6a7d43139231415a5a5458023e10acb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Skin.php b/includes/Skin.php index 3feb5835a0..15b7a1ffa6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1,26 +1,26 @@ addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) ); } + if( false !== $wgAppleTouchIcon ) { + $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) ); + } + # OpenSearch description link - $out->addLink( array( - 'rel' => 'search', + $out->addLink( array( + 'rel' => 'search', 'type' => 'application/opensearchdescription+xml', - 'href' => "$wgScriptPath/opensearch_desc.php", - 'title' => "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})", + 'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}", + 'title' => wfMsgForContent( 'opensearch-desc' ), )); $this->addMetadataLinks($out); $this->mRevisionId = $out->mRevisionId; - + $this->preloadExistence(); - wfProfileOut( $fname ); + wfProfileOut( __METHOD__ ); } /** @@ -203,7 +207,7 @@ class Skin extends Linker { $lb = new LinkBatch( $titles ); $lb->execute(); } - + function addMetadataLinks( &$out ) { global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf; global $wgRightsPage, $wgRightsUrl; @@ -267,7 +271,7 @@ class Skin extends Linker { $out->out( $this->bottomScripts() ); - $out->out( $out->reportTime() ); + $out->out( wfReportTime() ); $out->out( "\n" ); wfProfileOut( __METHOD__ ); @@ -296,27 +300,30 @@ class Skin extends Linker { global $wgScript, $wgStylePath, $wgUser; global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang; global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle; - global $wgBreakFrames, $wgRequest; + global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths; global $wgUseAjax, $wgAjaxWatch; + global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI; + global $wgRestrictionTypes, $wgLivePreview; + global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest; $ns = $wgTitle->getNamespace(); $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText(); - $vars = array( + $vars = array( 'skin' => $data['skinname'], 'stylepath' => $wgStylePath, 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScript' => $wgScript, + 'wgVariantArticlePath' => $wgVariantArticlePath, + 'wgActionPaths' => $wgActionPaths, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, - 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBKey() ), + 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBkey() ), 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgAction' => $wgRequest->getText( 'action', 'view' ), - 'wgRestrictionEdit' => $wgTitle->getRestrictions( 'edit' ), - 'wgRestrictionMove' => $wgTitle->getRestrictions( 'move' ), 'wgArticleId' => $wgTitle->getArticleId(), 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(), @@ -325,9 +332,21 @@ class Skin extends Linker { 'wgContentLanguage' => $wgContLang->getCode(), 'wgBreakFrames' => $wgBreakFrames, 'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0, + 'wgVersion' => $wgVersion, + 'wgEnableAPI' => $wgEnableAPI, + 'wgEnableWriteAPI' => $wgEnableWriteAPI, ); + + if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){ + $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate(); + $vars['wgDBname'] = $wgDBname; + $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser ); + $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled')); + } + + foreach( $wgRestrictionTypes as $type ) + $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type ); - global $wgLivePreview; if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) { $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' ); $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' ); @@ -336,7 +355,6 @@ class Skin extends Linker { } if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) { - $msgNames = array( 'watch', 'unwatch', 'watching', 'unwatching' ); $msgs = (object)array(); foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) { $msgs->{$msgName . 'Msg'} = wfMsg( $msgName ); @@ -344,6 +362,8 @@ class Skin extends Linker { $vars['wgAjaxWatch'] = $msgs; } + wfRunHooks('ExtendJSGlobalVars', array(&$vars)); + return self::makeVariablesScript( $vars ); } @@ -355,11 +375,12 @@ class Skin extends Linker { $r .= "\n"; global $wgUseSiteJs; if ($wgUseSiteJs) { - if ($wgUser->isLoggedIn()) { - $r .= "\n"; - } else { - $r .= "\n"; - } + $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : ''; + $r .= "\n"; } if( $allowUserJs && $wgUser->isLoggedIn() ) { $userpage = $wgUser->getUserPage(); @@ -413,17 +434,23 @@ class Skin extends Linker { } /** - * This returns MediaWiki:Common.js. For some bizarre reason, it does - * *not* return any custom user JS from user subpages. Huh? + * This returns MediaWiki:Common.js, and derived classes may add other JS. + * Despite its name, it does *not* return any custom user JS from user + * subpages. The returned script is sitewide and publicly cacheable and + * therefore must not include anything that varies according to user, + * interface language, etc. (although it may vary by skin). See + * makeGlobalVariablesScript for things that can vary per page view and are + * not cacheable. * - * @return string + * @return string Raw JavaScript to be returned */ - function getUserJs() { + public function getUserJs() { wfProfileIn( __METHOD__ ); global $wgStylePath; $s = "/* generated javascript */\n"; - $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';"; + $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n"; + $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';"; $s .= "\n\n/* MediaWiki:Common.js */\n"; $commonJs = wfMsgForContent('common.js'); if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) { @@ -470,7 +497,7 @@ class Skin extends Linker { function reallyDoGetUserStyles() { global $wgUser; $s = ''; - if (($undopt = $wgUser->getOption("underline")) != 2) { + if (($undopt = $wgUser->getOption("underline")) < 2) { $underline = $undopt ? 'underline' : 'none'; $s .= "a { text-decoration: $underline; }\n"; } @@ -481,22 +508,19 @@ class Skin extends Linker { a.new, #quickbar a.new, a.stub, #quickbar a.stub { color: inherit; - text-decoration: inherit; } a.new:after, #quickbar a.new:after { content: "?"; color: #CC2200; - text-decoration: $underline; } a.stub:after, #quickbar a.stub:after { content: "!"; color: #772233; - text-decoration: $underline; } END; } if( $wgUser->getOption( 'justify' ) ) { - $s .= "#article, #bodyContent { text-align: justify; }\n"; + $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n"; } if( !$wgUser->getOption( 'showtoc' ) ) { $s .= "#toc { display: none; }\n"; @@ -524,14 +548,10 @@ END; } $a['onload'] = $wgOut->getOnloadHandler(); - if( $wgUser->getOption( 'editsectiononrightclick' ) ) { - if( $a['onload'] != '' ) { - $a['onload'] .= ';'; - } - $a['onload'] .= 'setupRightClickEdit()'; - } - $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ? "rtl" : "ltr"). - ' '.Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() ); + $a['class'] = + 'mediawiki ns-'.$wgTitle->getNamespace(). + ' '.($wgContLang->isRTL() ? "rtl" : "ltr"). + ' '.Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() ); return $a; } @@ -614,9 +634,9 @@ END; } - function getCategoryLinks () { + function getCategoryLinks() { global $wgOut, $wgTitle, $wgUseCategoryBrowser; - global $wgContLang; + global $wgContLang, $wgUser; if( count( $wgOut->mCategoryLinks ) == 0 ) return ''; @@ -628,11 +648,33 @@ END; $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; $embed = ""; $pop = ''; - $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks ) . $pop; - $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks ) ); - $s = $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg ) - . ': ' . $t; + $allCats = $wgOut->getCategoryLinks(); + $s = ''; + $colon = wfMsgExt( 'colon-separator', 'escapenoentities' ); + if ( !empty( $allCats['normal'] ) ) { + $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop; + + $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) ); + $s .= ''; + } + + # Hidden categories + if ( isset( $allCats['hidden'] ) ) { + if ( $wgUser->getBoolOption( 'showhiddencats' ) ) { + $class ='mw-hidden-cats-user-shown'; + } elseif ( $wgTitle->getNamespace() == NS_CATEGORY ) { + $class = 'mw-hidden-cats-ns-shown'; + } else { + $class = 'mw-hidden-cats-hidden'; + } + $s .= "
" . + wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) . + $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop . + "
"; + } # optional 'dmoz-like' category browser. Will be shown under the list # of categories an article belong to @@ -678,8 +720,16 @@ END; function getCategories() { $catlinks=$this->getCategoryLinks(); - if(!empty($catlinks)) { - return ""; + + $classes = 'catlinks'; + + if( strpos( $catlinks, '