Add returntoquery= parameter to Special:Userlogin which adds a query string to the...
[lhc/web/wiklou.git] / skins / Standard.php
1 <?php
2 /**
3 * Standard (a.k.a. Classic) skin: old MediaWiki default skin
4 *
5 * @file
6 * @ingroup Skins
7 */
8
9 if( !defined( 'MEDIAWIKI' ) )
10 die( -1 );
11
12 /**
13 * @todo document
14 * @ingroup Skins
15 */
16 class SkinStandard extends Skin {
17
18 /**
19 *
20 */
21 function getHeadScripts( $allowUserJs, $extraHtml = '' ) {
22 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
23
24 $s = parent::getHeadScripts( $allowUserJs, $extraHtml );
25 if ( 3 == $this->qbSetting() ) { # Floating left
26 $s .= "<script language='javascript' type='$wgJsMimeType' " .
27 "src='{$wgStylePath}/common/sticky.js?$wgStyleVersion'></script>\n";
28 }
29 return $s;
30 }
31
32 /**
33 *
34 */
35 function setupSkinUserCss( OutputPage $out ){
36 if ( 3 == $this->qbSetting() ) { # Floating left
37 $out->addStyle( 'common/quickbar.css' );
38 } else if ( 4 == $this->qbSetting() ) { # Floating right
39 $out->addStyle( 'common/quickbar-right.css' );
40 }
41 parent::setupSkinUserCss( $out );
42 }
43
44 /**
45 *
46 */
47 function reallyGenerateUserStylesheet() {
48 $s = parent::reallyGenerateUserStylesheet();
49 $qb = $this->qbSetting();
50
51 if ( 2 == $qb ) { # Right
52 $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
53 "border-left: 2px solid #000000; }\n" .
54 "#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }\n";
55 } else if ( 1 == $qb || 3 == $qb ) {
56 $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
57 "border-right: 1px solid gray; }\n" .
58 "#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }\n";
59 } else if ( 4 == $qb) {
60 $s .= "#quickbar { border-right: 1px solid gray; }\n" .
61 "#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }\n";
62 }
63 return $s;
64 }
65
66 /**
67 *
68 */
69 function getBodyOptions() {
70 $a = parent::getBodyOptions();
71
72 if ( 3 == $this->qbSetting() ) { # Floating left
73 $qb = "setup(\"quickbar\")";
74 if( $a['onload'] ) {
75 $a['onload'] .= ";$qb";
76 } else {
77 $a['onload'] = $qb;
78 }
79 }
80 return $a;
81 }
82
83 function doAfterContent() {
84 global $wgContLang, $wgLang;
85 wfProfileIn( __METHOD__ );
86 wfProfileIn( __METHOD__ . '-1' );
87
88 $s = "\n</div><br style=\"clear:both\" />\n";
89 $s .= "\n<div id='footer'>";
90 $s .= '<table border="0" cellspacing="0"><tr>';
91
92 wfProfileOut( __METHOD__ . '-1' );
93 wfProfileIn( __METHOD__ . '-2' );
94
95 $qb = $this->qbSetting();
96 $shove = ( $qb != 0 );
97 $left = ( $qb == 1 || $qb == 3 );
98 if( $wgContLang->isRTL() ) $left = !$left;
99
100 if ( $shove && $left ) { # Left
101 $s .= $this->getQuickbarCompensator();
102 }
103 wfProfileOut( __METHOD__ . '-2' );
104 wfProfileIn( __METHOD__ . '-3' );
105 $l = $wgContLang->isRTL() ? 'right' : 'left';
106 $s .= "<td class='bottom' align='$l' valign='top'>";
107
108 $s .= $this->bottomLinks();
109 $s .= "\n<br />" . $wgLang->pipeList( array(
110 $this->mainPageLink(),
111 $this->aboutLink(),
112 $this->specialLink( 'recentchanges' ),
113 $this->searchForm() ) )
114 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
115
116 $s .= '</td>';
117 if ( $shove && !$left ) { # Right
118 $s .= $this->getQuickbarCompensator();
119 }
120 $s .= "</tr></table>\n</div>\n</div>\n";
121
122 wfProfileOut( __METHOD__ . '-3' );
123 wfProfileIn( __METHOD__ . '-4' );
124 if ( 0 != $qb ) {
125 $s .= $this->quickBar();
126 }
127 wfProfileOut( __METHOD__ . '-4' );
128 wfProfileOut( __METHOD__ );
129 return $s;
130 }
131
132 function quickBar() {
133 global $wgOut, $wgUser, $wgRequest, $wgContLang;
134 global $wgEnableUploads, $wgRemoteUploads;
135
136 wfProfileIn( __METHOD__ );
137
138 $action = $wgRequest->getText( 'action' );
139 $wpPreview = $wgRequest->getBool( 'wpPreview' );
140 $tns = $this->mTitle->getNamespace();
141
142 $s = "\n<div id='quickbar'>";
143 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
144
145 $sep = "\n<br />";
146
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 );
153
154 foreach ( $browseLinks as $link ) {
155 if ( $link['text'] != '-' ) {
156 $s .= "<a href=\"{$link['href']}\">" .
157 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
158 }
159 }
160
161 if( $wgUser->isLoggedIn() ) {
162 $s.= $this->specialLink( 'watchlist' ) ;
163 $s .= $sep . $this->linkKnown(
164 SpecialPage::getTitleFor( 'Contributions' ),
165 wfMsg( 'mycontris' ),
166 array(),
167 array( 'target' => $wgUser->getName() )
168 );
169 }
170 // only show watchlist link if logged in
171 $s .= "\n<hr class='sep' />";
172 $articleExists = $this->mTitle->getArticleId();
173 if ( $wgOut->isArticle() || $action == 'edit' || $action == 'history' || $wpPreview ) {
174 if( $wgOut->isArticle() ) {
175 $s .= '<strong>' . $this->editThisPage() . '</strong>';
176 } else { # backlink to the article in edit or history mode
177 if( $articleExists ){ # no backlink if no article
178 switch( $tns ) {
179 case NS_TALK:
180 case NS_USER_TALK:
181 case NS_PROJECT_TALK:
182 case NS_FILE_TALK:
183 case NS_MEDIAWIKI_TALK:
184 case NS_TEMPLATE_TALK:
185 case NS_HELP_TALK:
186 case NS_CATEGORY_TALK:
187 $text = wfMsg('viewtalkpage');
188 break;
189 case NS_MAIN:
190 $text = wfMsg( 'articlepage' );
191 break;
192 case NS_USER:
193 $text = wfMsg( 'userpage' );
194 break;
195 case NS_PROJECT:
196 $text = wfMsg( 'projectpage' );
197 break;
198 case NS_FILE:
199 $text = wfMsg( 'imagepage' );
200 break;
201 case NS_MEDIAWIKI:
202 $text = wfMsg( 'mediawikipage' );
203 break;
204 case NS_TEMPLATE:
205 $text = wfMsg( 'templatepage' );
206 break;
207 case NS_HELP:
208 $text = wfMsg( 'viewhelppage' );
209 break;
210 case NS_CATEGORY:
211 $text = wfMsg( 'categorypage' );
212 break;
213 default:
214 $text = wfMsg( 'articlepage' );
215 }
216
217 $link = $this->mTitle->getText();
218 if( $nstext = $wgContLang->getNsText( $tns ) ) { # add namespace if necessary
219 $link = $nstext . ':' . $link;
220 }
221
222 $s .= $this->link(
223 Title::newFromText( $link ),
224 $text
225 );
226 } elseif( $this->mTitle->getNamespace() != NS_SPECIAL ) {
227 # we just throw in a "New page" text to tell the user that he's in edit mode,
228 # and to avoid messing with the separator that is prepended to the next item
229 $s .= '<strong>' . wfMsg( 'newpage' ) . '</strong>';
230 }
231 }
232
233 # "Post a comment" link
234 if( ( $this->mTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
235 $s .= '<br />' . $this->link(
236 $this->mTitle,
237 wfMsg( 'postcomment' ),
238 array(),
239 array(
240 'action' => 'edit',
241 'section' => 'new'
242 ),
243 array( 'known', 'noclasses' )
244 );
245
246 #if( $tns%2 && $action!='edit' && !$wpPreview) {
247 #$s.= '<br />'.$this->linkKnown( Title::newFromText( $wgTitle->getPrefixedText() ),wfMsg('postcomment'),array(),array('action'=>'edit','section'=>'new'));
248 #}
249
250 /*
251 watching could cause problems in edit mode:
252 if user edits article, then loads "watch this article" in background and then saves
253 article with "Watch this article" checkbox disabled, the article is transparently
254 unwatched. Therefore we do not show the "Watch this page" link in edit mode
255 */
256 if ( $wgUser->isLoggedIn() && $articleExists) {
257 if( $action != 'edit' && $action != 'submit' ){
258 $s .= $sep . $this->watchThisPage();
259 }
260 if ( $this->mTitle->userCan( 'edit' ) )
261 $s .= $sep . $this->moveThisPage();
262 }
263 if ( $wgUser->isAllowed( 'delete' ) and $articleExists ) {
264 $s .= $sep . $this->deleteThisPage() .
265 $sep . $this->protectThisPage();
266 }
267 $s .= $sep . $this->talkLink();
268 if( $articleExists && $action != 'history' ) {
269 $s .= $sep . $this->historyLink();
270 }
271 $s.= $sep . $this->whatLinksHere();
272
273 if( $wgOut->isArticleRelated() ) {
274 $s .= $sep . $this->watchPageLinksLink();
275 }
276
277 if ( NS_USER == $this->mTitle->getNamespace()
278 || $this->mTitle->getNamespace() == NS_USER_TALK ) {
279
280 $id = User::idFromName( $this->mTitle->getText() );
281 $ip = User::isIP( $this->mTitle->getText() );
282
283 if( $id || $ip ){
284 $s .= $sep . $this->userContribsLink();
285 }
286 if( $this->showEmailUser( $id ) ) {
287 $s .= $sep . $this->emailUserLink();
288 }
289 }
290 $s .= "\n<br /><hr class='sep' />";
291 }
292
293 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
294 $s .= $this->specialLink( 'upload' ) . $sep;
295 }
296 $s .= $this->specialLink( 'specialpages' );
297
298 global $wgSiteSupportPage;
299 if( $wgSiteSupportPage ) {
300 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
301 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
302 }
303
304 $s .= "\n<br /></div>\n";
305 wfProfileOut( __METHOD__ );
306 return $s;
307 }
308
309 }