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