Add new line after generating <script> calling mwScriptLoader.php for better source...
[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 /**
63 *
64 */
65 function getBodyOptions() {
66 $a = parent::getBodyOptions();
67
68 if ( 3 == $this->qbSetting() ) { # Floating left
69 $qb = "setup(\"quickbar\")";
70 if( $a['onload'] ) {
71 $a['onload'] .= ";$qb";
72 } else {
73 $a['onload'] = $qb;
74 }
75 }
76 return $a;
77 }
78
79 function doAfterContent() {
80 global $wgContLang, $wgLang;
81 wfProfileIn( __METHOD__ );
82 wfProfileIn( __METHOD__ . '-1' );
83
84 $s = "\n</div><br style=\"clear:both\" />\n";
85 $s .= "\n<div id='footer'>";
86 $s .= '<table border="0" cellspacing="0"><tr>';
87
88 wfProfileOut( __METHOD__ . '-1' );
89 wfProfileIn( __METHOD__ . '-2' );
90
91 $qb = $this->qbSetting();
92 $shove = ( $qb != 0 );
93 $left = ( $qb == 1 || $qb == 3 );
94 if( $wgContLang->isRTL() ) $left = !$left;
95
96 if ( $shove && $left ) { # Left
97 $s .= $this->getQuickbarCompensator();
98 }
99 wfProfileOut( __METHOD__ . '-2' );
100 wfProfileIn( __METHOD__ . '-3' );
101 $l = $wgContLang->alignStart();
102 $s .= "<td class='bottom' align='$l' valign='top'>";
103
104 $s .= $this->bottomLinks();
105 $s .= "\n<br />" . $wgLang->pipeList( array(
106 $this->mainPageLink(),
107 $this->aboutLink(),
108 $this->specialLink( 'recentchanges' ),
109 $this->searchForm() ) )
110 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
111
112 $s .= '</td>';
113 if ( $shove && !$left ) { # Right
114 $s .= $this->getQuickbarCompensator();
115 }
116 $s .= "</tr></table>\n</div>\n</div>\n";
117
118 wfProfileOut( __METHOD__ . '-3' );
119 wfProfileIn( __METHOD__ . '-4' );
120 if ( 0 != $qb ) {
121 $s .= $this->quickBar();
122 }
123 wfProfileOut( __METHOD__ . '-4' );
124 wfProfileOut( __METHOD__ );
125 return $s;
126 }
127
128 function quickBar() {
129 global $wgOut, $wgUser, $wgRequest, $wgContLang;
130 global $wgEnableUploads, $wgRemoteUploads;
131
132 wfProfileIn( __METHOD__ );
133
134 $action = $wgRequest->getText( 'action' );
135 $wpPreview = $wgRequest->getBool( 'wpPreview' );
136 $tns = $this->mTitle->getNamespace();
137
138 $s = "\n<div id='quickbar'>";
139 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
140
141 $sep = "\n<br />";
142
143 # Use the first heading from the Monobook sidebar as the "browse" section
144 $bar = $this->buildSidebar();
145 unset( $bar['SEARCH'] );
146 unset( $bar['LANGUAGES'] );
147 unset( $bar['TOOLBOX'] );
148 $browseLinks = reset( $bar );
149
150 foreach ( $browseLinks as $link ) {
151 if ( $link['text'] != '-' ) {
152 $s .= "<a href=\"{$link['href']}\">" .
153 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
154 }
155 }
156
157 if( $wgUser->isLoggedIn() ) {
158 $s.= $this->specialLink( 'watchlist' ) ;
159 $s .= $sep . $this->linkKnown(
160 SpecialPage::getTitleFor( 'Contributions' ),
161 wfMsg( 'mycontris' ),
162 array(),
163 array( 'target' => $wgUser->getName() )
164 );
165 }
166 // only show watchlist link if logged in
167 $s .= "\n<hr class='sep' />";
168 $articleExists = $this->mTitle->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_FILE_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_FILE:
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' );
211 }
212
213 $link = $this->mTitle->getText();
214 if( $nstext = $wgContLang->getNsText( $tns ) ) { # add namespace if necessary
215 $link = $nstext . ':' . $link;
216 }
217
218 $s .= $this->link(
219 Title::newFromText( $link ),
220 $text
221 );
222 } elseif( $this->mTitle->getNamespace() != NS_SPECIAL ) {
223 # we just throw in a "New page" text to tell the user that he's in edit mode,
224 # and to avoid messing with the separator that is prepended to the next item
225 $s .= '<strong>' . wfMsg( 'newpage' ) . '</strong>';
226 }
227 }
228
229 # "Post a comment" link
230 if( ( $this->mTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
231 $s .= '<br />' . $this->link(
232 $this->mTitle,
233 wfMsg( 'postcomment' ),
234 array(),
235 array(
236 'action' => 'edit',
237 'section' => 'new'
238 ),
239 array( 'known', 'noclasses' )
240 );
241
242 #if( $tns%2 && $action!='edit' && !$wpPreview) {
243 #$s.= '<br />'.$this->linkKnown( Title::newFromText( $wgTitle->getPrefixedText() ),wfMsg('postcomment'),array(),array('action'=>'edit','section'=>'new'));
244 #}
245
246 /*
247 watching could cause problems in edit mode:
248 if user edits article, then loads "watch this article" in background and then saves
249 article with "Watch this article" checkbox disabled, the article is transparently
250 unwatched. Therefore we do not show the "Watch this page" link in edit mode
251 */
252 if ( $wgUser->isLoggedIn() && $articleExists) {
253 if( $action != 'edit' && $action != 'submit' ){
254 $s .= $sep . $this->watchThisPage();
255 }
256 if ( $this->mTitle->userCan( 'edit' ) )
257 $s .= $sep . $this->moveThisPage();
258 }
259 if ( $wgUser->isAllowed( 'delete' ) and $articleExists ) {
260 $s .= $sep . $this->deleteThisPage() .
261 $sep . $this->protectThisPage();
262 }
263 $s .= $sep . $this->talkLink();
264 if( $articleExists && $action != 'history' ) {
265 $s .= $sep . $this->historyLink();
266 }
267 $s.= $sep . $this->whatLinksHere();
268
269 if( $wgOut->isArticleRelated() ) {
270 $s .= $sep . $this->watchPageLinksLink();
271 }
272
273 if ( NS_USER == $this->mTitle->getNamespace()
274 || $this->mTitle->getNamespace() == NS_USER_TALK ) {
275
276 $id = User::idFromName( $this->mTitle->getText() );
277 $ip = User::isIP( $this->mTitle->getText() );
278
279 if( $id || $ip ){
280 $s .= $sep . $this->userContribsLink();
281 }
282 if( $this->showEmailUser( $id ) ) {
283 $s .= $sep . $this->emailUserLink();
284 }
285 }
286 $s .= "\n<br /><hr class='sep' />";
287 }
288
289 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
290 $s .= $this->specialLink( 'upload' ) . $sep;
291 }
292 $s .= $this->specialLink( 'specialpages' );
293
294 global $wgSiteSupportPage;
295 if( $wgSiteSupportPage ) {
296 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
297 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
298 }
299
300 $s .= "\n<br /></div>\n";
301 wfProfileOut( __METHOD__ );
302 return $s;
303 }
304
305 }