Show contribs link only if it applies
[mediawiki.git] / skins / Standard.php
blob9b65de718efe2e8d6ffc0232626cd1c58a3ee932
1 <?php
2 /**
3 * See docs/skin.txt
5 * @todo document
6 * @file
7 * @ingroup Skins
8 */
10 if( !defined( 'MEDIAWIKI' ) )
11 die( -1 );
13 /**
14 * @todo document
15 * @ingroup Skins
17 class SkinStandard extends Skin {
19 /**
22 function getHeadScripts( $allowUserJs ) {
23 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
25 $s = parent::getHeadScripts( $allowUserJs );
26 if ( 3 == $this->qbSetting() ) { # Floating left
27 $s .= "<script language='javascript' type='$wgJsMimeType' " .
28 "src='{$wgStylePath}/common/sticky.js?$wgStyleVersion'></script>\n";
30 return $s;
33 /**
36 function setupSkinUserCss( OutputPage $out ){
37 if ( 3 == $this->qbSetting() ) { # Floating left
38 $out->addStyle( 'common/quickbar.css' );
39 } else if ( 4 == $this->qbSetting() ) { # Floating right
40 $out->addStyle( 'common/quickbar-right.css' );
42 parent::setupSkinUserCss( $out );
45 /**
48 function reallyGenerateUserStylesheet() {
49 $s = parent::reallyGenerateUserStylesheet();
50 $qb = $this->qbSetting();
52 if ( 2 == $qb ) { # Right
53 $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
54 "border-left: 2px solid #000000; }\n" .
55 "#article { margin-left: 4px; margin-right: 152px; }\n";
56 } else if ( 1 == $qb || 3 == $qb ) {
57 $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
58 "border-right: 1px solid gray; }\n" .
59 "#article { margin-left: 152px; margin-right: 4px; }\n";
60 } else if ( 4 == $qb) {
61 $s .= "#quickbar { border-right: 1px solid gray; }\n" .
62 "#article { margin-right: 152px; margin-left: 4px; }\n";
64 return $s;
67 /**
70 function getBodyOptions() {
71 $a = parent::getBodyOptions();
73 if ( 3 == $this->qbSetting() ) { # Floating left
74 $qb = "setup(\"quickbar\")";
75 if($a["onload"]) {
76 $a["onload"] .= ";$qb";
77 } else {
78 $a["onload"] = $qb;
81 return $a;
84 function doAfterContent() {
85 global $wgContLang;
86 $fname = 'SkinStandard::doAfterContent';
87 wfProfileIn( $fname );
88 wfProfileIn( $fname.'-1' );
90 $s = "\n</div><br style=\"clear:both\" />\n";
91 $s .= "\n<div id='footer'>";
92 $s .= '<table border="0" cellspacing="0"><tr>';
94 wfProfileOut( $fname.'-1' );
95 wfProfileIn( $fname.'-2' );
97 $qb = $this->qbSetting();
98 $shove = ($qb != 0);
99 $left = ($qb == 1 || $qb == 3);
100 if($wgContLang->isRTL()) $left = !$left;
102 if ( $shove && $left ) { # Left
103 $s .= $this->getQuickbarCompensator();
105 wfProfileOut( $fname.'-2' );
106 wfProfileIn( $fname.'-3' );
107 $l = $wgContLang->isRTL() ? 'right' : 'left';
108 $s .= "<td class='bottom' align='$l' valign='top'>";
110 $s .= $this->bottomLinks();
111 $s .= "\n<br />" . $this->mainPageLink()
112 . ' | ' . $this->aboutLink()
113 . ' | ' . $this->specialLink( 'recentchanges' )
114 . ' | ' . $this->searchForm()
115 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
117 $s .= "</td>";
118 if ( $shove && !$left ) { # Right
119 $s .= $this->getQuickbarCompensator();
121 $s .= "</tr></table>\n</div>\n</div>\n";
123 wfProfileOut( $fname.'-3' );
124 wfProfileIn( $fname.'-4' );
125 if ( 0 != $qb ) { $s .= $this->quickBar(); }
126 wfProfileOut( $fname.'-4' );
127 wfProfileOut( $fname );
128 return $s;
131 function quickBar() {
132 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
133 global $wgEnableUploads, $wgRemoteUploads;
135 $fname = 'Skin::quickBar';
136 wfProfileIn( $fname );
138 $action = $wgRequest->getText( 'action' );
139 $wpPreview = $wgRequest->getBool( 'wpPreview' );
140 $tns=$wgTitle->getNamespace();
142 $s = "\n<div id='quickbar'>";
143 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
145 $sep = "\n<br />";
147 # Use the first heading from the Monobook sidebar as the "browse" section
148 $bar = $this->buildSidebar();
149 unset( $bar['SEARCH'] );
150 unset( $bar['LANGUAGES'] );
151 unset( $bar['TOOLBOX'] );
152 $browseLinks = reset( $bar );
154 foreach ( $browseLinks as $link ) {
155 if ( $link['text'] != '-' ) {
156 $s .= "<a href=\"{$link['href']}\">" .
157 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
161 if( $wgUser->isLoggedIn() ) {
162 $s.= $this->specialLink( 'watchlist' ) ;
163 $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
164 wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
166 // only show watchlist link if logged in
167 $s .= "\n<hr class='sep' />";
168 $articleExists = $wgTitle->getArticleId();
169 if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
170 if($wgOut->isArticle()) {
171 $s .= '<strong>' . $this->editThisPage() . '</strong>';
172 } else { # backlink to the article in edit or history mode
173 if($articleExists){ # no backlink if no article
174 switch($tns) {
175 case NS_TALK:
176 case NS_USER_TALK:
177 case NS_PROJECT_TALK:
178 case NS_IMAGE_TALK:
179 case NS_MEDIAWIKI_TALK:
180 case NS_TEMPLATE_TALK:
181 case NS_HELP_TALK:
182 case NS_CATEGORY_TALK:
183 $text = wfMsg('viewtalkpage');
184 break;
185 case NS_MAIN:
186 $text = wfMsg( 'articlepage' );
187 break;
188 case NS_USER:
189 $text = wfMsg( 'userpage' );
190 break;
191 case NS_PROJECT:
192 $text = wfMsg( 'projectpage' );
193 break;
194 case NS_IMAGE:
195 $text = wfMsg( 'imagepage' );
196 break;
197 case NS_MEDIAWIKI:
198 $text = wfMsg( 'mediawikipage' );
199 break;
200 case NS_TEMPLATE:
201 $text = wfMsg( 'templatepage' );
202 break;
203 case NS_HELP:
204 $text = wfMsg( 'viewhelppage' );
205 break;
206 case NS_CATEGORY:
207 $text = wfMsg( 'categorypage' );
208 break;
209 default:
210 $text= wfMsg( 'articlepage' );
213 $link = $wgTitle->getText();
214 if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
215 $link = $nstext . ':' . $link ;
218 $s .= $this->makeLink( $link, $text );
219 } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) {
220 # we just throw in a "New page" text to tell the user that he's in edit mode,
221 # and to avoid messing with the separator that is prepended to the next item
222 $s .= '<strong>' . wfMsg('newpage') . '</strong>';
227 # "Post a comment" link
228 if( ( $wgTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
229 $s .= '<br />' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit&section=new' );
231 #if( $tns%2 && $action!='edit' && !$wpPreview) {
232 #$s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit&section=new');
236 watching could cause problems in edit mode:
237 if user edits article, then loads "watch this article" in background and then saves
238 article with "Watch this article" checkbox disabled, the article is transparently
239 unwatched. Therefore we do not show the "Watch this page" link in edit mode
241 if ( $wgUser->isLoggedIn() && $articleExists) {
242 if($action!='edit' && $action != 'submit' )
244 $s .= $sep . $this->watchThisPage();
246 if ( $wgTitle->userCan( 'edit' ) )
247 $s .= $sep . $this->moveThisPage();
249 if ( $wgUser->isAllowed('delete') and $articleExists ) {
250 $s .= $sep . $this->deleteThisPage() .
251 $sep . $this->protectThisPage();
253 $s .= $sep . $this->talkLink();
254 if ($articleExists && $action !='history') {
255 $s .= $sep . $this->historyLink();
257 $s.=$sep . $this->whatLinksHere();
259 if($wgOut->isArticleRelated()) {
260 $s .= $sep . $this->watchPageLinksLink();
263 if ( NS_USER == $wgTitle->getNamespace()
264 || $wgTitle->getNamespace() == NS_USER_TALK ) {
266 $id=User::idFromName($wgTitle->getText());
267 $ip=User::isIP($wgTitle->getText());
269 if( $id || $ip ){
270 $s .= $sep . $this->userContribsLink();
272 if( $this->showEmailUser( $id ) ) {
273 $s .= $sep . $this->emailUserLink();
276 $s .= "\n<br /><hr class='sep' />";
279 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
280 $s .= $this->specialLink( 'upload' ) . $sep;
282 $s .= $this->specialLink( 'specialpages' )
283 . $sep . $this->bugReportsLink();
285 global $wgSiteSupportPage;
286 if( $wgSiteSupportPage ) {
287 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
288 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
291 $s .= "\n<br /></div>\n";
292 wfProfileOut( $fname );
293 return $s;