X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSkinTemplate.php;h=09457ffc1899cd4ba42bd2575016a298f162a039;hb=08aec83eb97be75b0fc9bdff67f3652c33ef1cbc;hp=cddd21954638f8aeb8e6209ed90b9da2b328e0c4;hpb=bd23ec29c6f3d34b4ef45a8a70921660de2282aa;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index cddd219546..09457ffc18 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -179,7 +179,7 @@ class SkinTemplate extends Skin { $this->usercss = $this->userjs = $this->userjsprev = false; $this->setupUserCss(); - $this->setupUserJs(); + $this->setupUserJs( $out->isUserJsAllowed() ); $this->titletxt = $this->mTitle->getPrefixedText(); wfProfileOut( "$fname-stuff" ); @@ -226,9 +226,14 @@ class SkinTemplate extends Skin { } else if ( $format == "rss" ) { $linktext = wfMsg( 'feed-rss' ); } + if( is_string( $wgOut->getFeedAppendQuery() ) ) { + $appendQuery = "&" . $wgOut->getFeedAppendQuery(); + } else { + $appendQuery = ""; + } $feeds[$format] = array( 'text' => $linktext, - 'href' => $wgRequest->appendQuery( "feed=$format" ) + 'href' => $wgRequest->appendQuery( "feed={$format}{$appendQuery}" ) ); } $tpl->setRef( 'feeds', $feeds ); @@ -285,11 +290,11 @@ class SkinTemplate extends Skin { $tpl->setRef( 'userjsprev', $this->userjsprev); global $wgUseSiteJs; if ($wgUseSiteJs) { - if($this->loggedin) { - $tpl->set( 'jsvarurl', self::makeUrl('-','action=raw&smaxage=0&gen=js') ); - } else { - $tpl->set( 'jsvarurl', self::makeUrl('-','action=raw&gen=js') ); - } + $jsCache = $this->loggedin ? '&smaxage=0' : ''; + $tpl->set( 'jsvarurl', + self::makeUrl('-', + "action=raw$jsCache&gen=js&useskin=" . + urlencode( $this->getSkinName() ) ) ); } else { $tpl->set('jsvarurl', false); } @@ -357,7 +362,10 @@ class SkinTemplate extends Skin { $x = $dbr->fetchObject( $res ); $numberofwatchingusers = $x->n; if ($numberofwatchingusers > 0) { - $tpl->set('numberofwatchingusers', wfMsg('number_of_watching_users_pageview', $numberofwatchingusers)); + $tpl->set('numberofwatchingusers', + wfMsgExt('number_of_watching_users_pageview', array('parseinline'), + $wgLang->formatNum($numberofwatchingusers)) + ); } else { $tpl->set('numberofwatchingusers', false); } @@ -440,7 +448,8 @@ class SkinTemplate extends Skin { // XXX: attach this from javascript, same with section editing if($this->iseditable && $wgUser->getOption("editondblclick") ) { - $tpl->set('body_ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";'); + $encEditUrl = wfEscapeJsString( $this->mTitle->getLocalUrl( $this->editUrlOptions() ) ); + $tpl->set('body_ondblclick', 'document.location = "' . $encEditUrl . '";'); } else { $tpl->set('body_ondblclick', false); } @@ -591,7 +600,7 @@ class SkinTemplate extends Skin { if( $selected ) { $classes[] = 'selected'; } - if( $checkEdit && $title->getArticleId() == 0 ) { + if( $checkEdit && !$title->isAlwaysKnown() && $title->getArticleId() == 0 ) { $classes[] = 'new'; $query = 'action=edit'; } @@ -601,6 +610,13 @@ class SkinTemplate extends Skin { global $wgContLang; $text = $wgContLang->getFormattedNsText( Namespace::getSubject( $title->getNamespace() ) ); } + + $result = array(); + if( !wfRunHooks('SkinTemplateTabAction', array(&$this, + $title, $message, $selected, $checkEdit, + &$classes, &$query, &$text, &$result)) ) { + return $result; + } return array( 'class' => implode( ' ', $classes ), @@ -637,7 +653,7 @@ class SkinTemplate extends Skin { * @private */ function buildContentActionUrls () { - global $wgContLang, $wgOut; + global $wgContLang, $wgLang, $wgOut; $fname = 'SkinTemplate::buildContentActionUrls'; wfProfileIn( $fname ); @@ -684,7 +700,7 @@ class SkinTemplate extends Skin { 'href' => $this->mTitle->getLocalUrl( 'action=edit§ion=new' ) ); } - } else { + } elseif ( $this->mTitle->exists() || $this->mTitle->isAlwaysKnown() ) { $content_actions['viewsource'] = array( 'class' => ($action == 'edit') ? 'selected' : false, 'text' => wfMsg('viewsource'), @@ -702,6 +718,22 @@ class SkinTemplate extends Skin { 'href' => $this->mTitle->getLocalUrl( 'action=history') ); + if($wgUser->isAllowed('delete')){ + $content_actions['delete'] = array( + 'class' => ($action == 'delete') ? 'selected' : false, + 'text' => wfMsg('delete'), + 'href' => $this->mTitle->getLocalUrl( 'action=delete' ) + ); + } + if ( $this->mTitle->quickUserCan( 'move' ) ) { + $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage ); + $content_actions['move'] = array( + 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false, + 'text' => wfMsg('move'), + 'href' => $moveTitle->getLocalUrl() + ); + } + if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { if(!$this->mTitle->isProtected()){ $content_actions['protect'] = array( @@ -718,35 +750,38 @@ class SkinTemplate extends Skin { ); } } - if($wgUser->isAllowed('delete')){ - $content_actions['delete'] = array( - 'class' => ($action == 'delete') ? 'selected' : false, - 'text' => wfMsg('delete'), - 'href' => $this->mTitle->getLocalUrl( 'action=delete' ) - ); - } - if ( $this->mTitle->quickUserCan( 'move' ) ) { - $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage ); - $content_actions['move'] = array( - 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false, - 'text' => wfMsg('move'), - 'href' => $moveTitle->getLocalUrl() - ); - } } else { //article doesn't exist or is deleted - if( $wgUser->isAllowed( 'delete' ) ) { + if( $wgUser->isAllowed( 'deletedhistory' ) && $wgUser->isAllowed( 'undelete' ) ) { if( $n = $this->mTitle->isDeleted() ) { $undelTitle = SpecialPage::getTitleFor( 'Undelete' ); $content_actions['undelete'] = array( 'class' => false, - 'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $n ), + 'text' => wfMsgExt( 'undelete_short', array( 'parsemag' ), $wgLang->formatNum($n) ), 'href' => $undelTitle->getLocalUrl( 'target=' . urlencode( $this->thispage ) ) #'href' => self::makeSpecialUrl( "Undelete/$this->thispage" ) ); } } + + if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { + if(!is_array($this->mTitle->getTitleProtection())){ + $content_actions['protect'] = array( + 'class' => ($action == 'protect') ? 'selected' : false, + 'text' => wfMsg('protect'), + 'href' => $this->mTitle->getLocalUrl( 'action=protect' ) + ); + + } else { + $content_actions['unprotect'] = array( + 'class' => ($action == 'unprotect') ? 'selected' : false, + 'text' => wfMsg('unprotect'), + 'href' => $this->mTitle->getLocalUrl( 'action=unprotect' ) + ); + } + } } + wfProfileOut( "$fname-live" ); if( $this->loggedin ) { @@ -822,7 +857,6 @@ class SkinTemplate extends Skin { global $wgEnableUploads, $wgUploadNavigationUrl; $action = $wgRequest->getText( 'action' ); - $oldid = $wgRequest->getVal( 'oldid' ); $nav_urls = array(); $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() ); @@ -852,21 +886,16 @@ class SkinTemplate extends Skin { ); // Also add a "permalink" while we're at it - if ( (int)$oldid ) { + if ( $this->mRevisionId ) { $nav_urls['permalink'] = array( 'text' => wfMsg( 'permalink' ), - 'href' => '' + 'href' => $wgTitle->getLocalURL( "oldid=$this->mRevisionId" ) ); - } else { - $revid = $wgArticle ? $wgArticle->getLatest() : 0; - if ( !( $revid == 0 ) ) - $nav_urls['permalink'] = array( - 'text' => wfMsg( 'permalink' ), - 'href' => $wgTitle->getLocalURL( "oldid=$revid" ) - ); } - - wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$oldid, &$revid ) ); + + // Copy in case this undocumented, shady hook tries to mess with internals + $revid = $this->mRevisionId; + wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$revid, &$revid ) ); } if( $this->mTitle->getNamespace() != NS_SPECIAL ) { @@ -896,10 +925,19 @@ class SkinTemplate extends Skin { $ip = false; } - if($id || $ip) { # both anons and non-anons have contri list + if($id || $ip) { # both anons and non-anons have contribs list $nav_urls['contributions'] = array( 'href' => self::makeSpecialUrlSubpage( 'Contributions', $this->mTitle->getText() ) ); + + if( $id ) { + $logPage = SpecialPage::getTitleFor( 'Log' ); + $nav_urls['log'] = array( 'href' => $logPage->getLocalUrl( 'user=' + . $this->mTitle->getPartialUrl() ) ); + } else { + $nav_urls['log'] = false; + } + if ( $wgUser->isAllowed( 'block' ) ) { $nav_urls['blockip'] = array( 'href' => self::makeSpecialUrlSubpage( 'Blockip', $this->mTitle->getText() ) @@ -909,6 +947,7 @@ class SkinTemplate extends Skin { } } else { $nav_urls['contributions'] = false; + $nav_urls['log'] = false; $nav_urls['blockip'] = false; } $nav_urls['emailuser'] = false; @@ -974,9 +1013,12 @@ class SkinTemplate extends Skin { # If we use the site's dynamic CSS, throw that in, too if ( $wgUseSiteCss ) { $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage"; + $skinquery = ''; + if (($us = $wgRequest->getVal('useskin', '')) !== '') + $skinquery = "&useskin=$us"; $sitecss .= '@import "' . self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI) . '";' . "\n"; $sitecss .= '@import "' . self::makeNSUrl( ucfirst( $this->skinname ) . '.css', $query, NS_MEDIAWIKI ) . '";' . "\n"; - $sitecss .= '@import "' . self::makeUrl( '-', 'action=raw&gen=css' . $siteargs ) . '";' . "\n"; + $sitecss .= '@import "' . self::makeUrl( '-', "action=raw&gen=css$siteargs$skinquery" ) . '";' . "\n"; } # If we use any dynamic CSS, make a little CDATA block out of it. @@ -990,14 +1032,14 @@ class SkinTemplate extends Skin { /** * @private */ - function setupUserJs() { + function setupUserJs( $allowUserJs ) { $fname = 'SkinTemplate::setupUserJs'; wfProfileIn( $fname ); - global $wgRequest, $wgAllowUserJs, $wgJsMimeType; + global $wgRequest, $wgJsMimeType; $action = $wgRequest->getText('action'); - if( $wgAllowUserJs && $this->loggedin ) { + if( $allowUserJs && $this->loggedin ) { if( $this->mTitle->isJsSubpage() and $this->userCanPreview( $action ) ) { # XXX: additional security check/prompt? $this->userjsprev = '/*getText('wpTextbox1') . ' /*]]>*/'; @@ -1177,4 +1219,7 @@ class QuickTemplate { return ($msg != '-') && ($msg != ''); # ???? } } -?> + + + +