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