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