Repair quickbar of standard and cologneblue skins to work under Resourceloader.
[lhc/web/wiklou.git] / skins / CologneBlue.php
1 <?php
2 /**
3 * Cologne Blue: A nicer-looking alternative to Standard.
4 *
5 * @todo document
6 * @file
7 * @ingroup Skins
8 */
9
10 if( !defined( 'MEDIAWIKI' ) ) {
11 die( -1 );
12 }
13
14 /**
15 * @todo document
16 * @ingroup Skins
17 */
18 class SkinCologneBlue extends Skin {
19
20 function getStylesheet() {
21 return 'common/cologneblue.css';
22 }
23
24 function getSkinName() {
25 return 'cologneblue';
26 }
27
28 function doBeforeContent() {
29 $mainPageObj = Title::newMainPage();
30
31 $s = "\n<div id='content'>\n<div id='topbar'>" .
32 '<table width="100%" border="0" cellspacing="0" cellpadding="8"><tr>';
33
34 $s .= '<td class="top" align="left" valign="middle" nowrap="nowrap">';
35 $s .= '<a href="' . $mainPageObj->escapeLocalURL() . '">';
36 $s .= '<span id="sitetitle">' . wfMsg( 'sitetitle' ) . '</span></a>';
37
38 $s .= '</td><td class="top" align="right" valign="bottom" width="100%">';
39 $s .= $this->sysLinks();
40 $s .= '</td></tr><tr><td valign="top">';
41
42 $s .= '<font size="-1"><span id="sitesub">';
43 $s .= htmlspecialchars( wfMsg( 'sitesubtitle' ) ) . '</span></font>';
44 $s .= '</td><td align="right">';
45
46 $s .= '<font size="-1"><span id="langlinks">';
47 $s .= str_replace( '<br />', '', $this->otherLanguages() );
48 $cat = $this->getCategoryLinks();
49 if( $cat ) {
50 $s .= "<br />$cat\n";
51 }
52 $s .= '<br />' . $this->pageTitleLinks();
53 $s .= '</span></font>';
54
55 $s .= "</td></tr></table>\n";
56
57 $s .= "\n</div>\n<div id='article'>";
58
59 $notice = wfGetSiteNotice();
60 if( $notice ) {
61 $s .= "\n<div id='siteNotice'>$notice</div>\n";
62 }
63 $s .= $this->pageTitle();
64 $s .= $this->pageSubtitle() . "\n";
65 return $s;
66 }
67
68 function doAfterContent(){
69 global $wgLang;
70
71 $s = "\n</div><br clear='all' />\n";
72
73 $s .= "\n<div id='footer'>";
74 $s .= '<table width="98%" border="0" cellspacing="0"><tr>';
75
76 $qb = $this->qbSetting();
77 if ( 1 == $qb || 3 == $qb ) { # Left
78 $s .= $this->getQuickbarCompensator();
79 }
80 $s .= '<td class="bottom" align="center" valign="top">';
81
82 $s .= $this->bottomLinks();
83 $s .= $wgLang->pipeList( array(
84 "\n<br />" . $this->link(
85 Title::newMainPage(),
86 null,
87 array(),
88 array(),
89 array( 'known', 'noclasses' )
90 ),
91 $this->aboutLink(),
92 $this->searchForm( wfMsg( 'qbfind' ) )
93 ) );
94
95 $s .= "\n<br />" . $this->pageStats();
96
97 $s .= '</td>';
98 if ( 2 == $qb ) { # Right
99 $s .= $this->getQuickbarCompensator();
100 }
101 $s .= "</tr></table>\n</div>\n</div>\n";
102
103 if ( 0 != $qb ) {
104 $s .= $this->quickBar();
105 }
106 return $s;
107 }
108
109 function setupSkinUserCss( OutputPage $out ){
110 global $wgContLang;
111 $qb = $this->qbSetting();
112
113 if ( 2 == $qb ) { # Right
114 $rules[] = "#quickbar { position: absolute; right: 4px; }";
115 $rules[] = "#article { margin-left: 4px; margin-right: 148px; }";
116 } elseif ( 1 == $qb ) {
117 $rules[] = "#quickbar { position: absolute; left: 4px; }";
118 $rules[] = "#article { margin-left: 148px; margin-right: 4px; }";
119 } elseif ( 3 == $qb ) { # Floating left
120 $rules[] = "#quickbar { position:absolute; left:4px }";
121 $rules[] = "#topbar { margin-left: 148px }";
122 $rules[] = "#article { margin-left:148px; margin-right: 4px; }";
123 $rules[] = "body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto ;bottom:4px;}"; # Hides from IE
124 } elseif ( 4 == $qb ) { # Floating right
125 $rules[] = "#quickbar { position: fixed; right: 4px; }";
126 $rules[] = "#topbar { margin-right: 148px }";
127 $rules[] = "#article { margin-right: 148px; margin-left: 4px; }";
128 $rules[] = "body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto ;bottom:4px;}"; # Hides from IE
129 }
130 $style = implode( "\n", $rules );
131 if ( $wgContLang->getDir() === 'rtl' ) {
132 $style = CSSJanus::transform( $style, true, false );
133 }
134 $out->addInlineStyle( $style );
135 parent::setupSkinUserCss( $out );
136 }
137
138 function sysLinks() {
139 global $wgUser, $wgLang;
140 $li = SpecialPage::getTitleFor( 'Userlogin' );
141 $lo = SpecialPage::getTitleFor( 'Userlogout' );
142
143 $rt = $this->mTitle->getPrefixedURL();
144 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
145 $q = array();
146 } else {
147 $q = array( 'returnto' => $rt );
148 }
149
150 $s = array(
151 $this->mainPageLink(),
152 $this->linkKnown(
153 Title::newFromText( wfMsgForContent( 'aboutpage' ) ),
154 wfMsg( 'about' )
155 ),
156 $this->linkKnown(
157 Title::newFromText( wfMsgForContent( 'helppage' ) ),
158 wfMsg( 'help' )
159 ),
160 $this->linkKnown(
161 Title::newFromText( wfMsgForContent( 'faqpage' ) ),
162 wfMsg( 'faq' )
163 ),
164 $this->specialLink( 'Specialpages' )
165 );
166
167 /* show links to different language variants */
168 if( $this->variantLinks() ) {
169 $s[] = $this->variantLinks();
170 }
171 if( $this->extensionTabLinks() ) {
172 $s[] = $this->extensionTabLinks();
173 }
174 if ( $wgUser->isLoggedIn() ) {
175 $s[] = $this->linkKnown(
176 $lo,
177 wfMsg( 'logout' ),
178 array(),
179 $q
180 );
181 } else {
182 $s[] = $this->linkKnown(
183 $li,
184 wfMsg( 'login' ),
185 array(),
186 $q
187 );
188 }
189
190 return $wgLang->pipeList( $s );
191 }
192
193 /**
194 * Compute the sidebar
195 * @access private
196 */
197 function quickBar(){
198 global $wgOut, $wgUser;
199
200 $tns = $this->mTitle->getNamespace();
201
202 $s = "\n<div id='quickbar'>";
203
204 $sep = '<br />';
205 $s .= $this->menuHead( 'qbfind' );
206 $s .= $this->searchForm();
207
208 $s .= $this->menuHead( 'qbbrowse' );
209
210 # Use the first heading from the Monobook sidebar as the "browse" section
211 $bar = $this->buildSidebar();
212 unset( $bar['SEARCH'] );
213 unset( $bar['LANGUAGES'] );
214 unset( $bar['TOOLBOX'] );
215 $browseLinks = reset( $bar );
216
217 foreach ( $browseLinks as $link ) {
218 if ( $link['text'] != '-' ) {
219 $s .= "<a href=\"{$link['href']}\">" .
220 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
221 }
222 }
223
224 if ( $wgOut->isArticle() ) {
225 $s .= $this->menuHead( 'qbedit' );
226 $s .= '<strong>' . $this->editThisPage() . '</strong>';
227
228 $s .= $sep . $this->linkKnown(
229 Title::newFromText( wfMsgForContent( 'edithelppage' ) ),
230 wfMsg( 'edithelp' )
231 );
232
233 if( $wgUser->isLoggedIn() ) {
234 $s .= $sep . $this->moveThisPage();
235 }
236 if ( $wgUser->isAllowed( 'delete' ) ) {
237 $dtp = $this->deleteThisPage();
238 if ( $dtp != '' ) {
239 $s .= $sep . $dtp;
240 }
241 }
242 if ( $wgUser->isAllowed( 'protect' ) ) {
243 $ptp = $this->protectThisPage();
244 if ( $ptp != '' ) {
245 $s .= $sep . $ptp;
246 }
247 }
248 $s .= $sep;
249
250 $s .= $this->menuHead( 'qbpageoptions' );
251 $s .= $this->talkLink()
252 . $sep . $this->commentLink()
253 . $sep . $this->printableLink();
254 if ( $wgUser->isLoggedIn() ) {
255 $s .= $sep . $this->watchThisPage();
256 }
257
258 $s .= $sep;
259
260 $s .= $this->menuHead( 'qbpageinfo' )
261 . $this->historyLink()
262 . $sep . $this->whatLinksHere()
263 . $sep . $this->watchPageLinksLink();
264
265 if( $tns == NS_USER || $tns == NS_USER_TALK ) {
266 $id = User::idFromName( $this->mTitle->getText() );
267 if( $id != 0 ) {
268 $s .= $sep . $this->userContribsLink();
269 if( $this->showEmailUser( $id ) ) {
270 $s .= $sep . $this->emailUserLink();
271 }
272 }
273 }
274 $s .= $sep;
275 }
276
277 $s .= $this->menuHead( 'qbmyoptions' );
278 if ( $wgUser->isLoggedIn() ) {
279 $tl = $this->link(
280 $wgUser->getTalkPage(),
281 wfMsg( 'mytalk' ),
282 array(),
283 array(),
284 array( 'known', 'noclasses' )
285 );
286 if ( $wgUser->getNewtalk() ) {
287 $tl .= ' *';
288 }
289
290 $s .= $this->link(
291 $wgUser->getUserPage(),
292 wfMsg( 'mypage' ),
293 array(),
294 array(),
295 array( 'known', 'noclasses' )
296 ) . $sep . $tl . $sep . $this->specialLink( 'Watchlist' )
297 . $sep .
298 $this->link(
299 SpecialPage::getSafeTitleFor( 'Contributions', $wgUser->getName() ),
300 wfMsg( 'mycontris' ),
301 array(),
302 array(),
303 array( 'known', 'noclasses' )
304 ) . $sep . $this->specialLink( 'Preferences' )
305 . $sep . $this->specialLink( 'Userlogout' );
306 } else {
307 $s .= $this->specialLink( 'Userlogin' );
308 }
309
310 $s .= $this->menuHead( 'qbspecialpages' )
311 . $this->specialLink( 'Newpages' )
312 . $sep . $this->specialLink( 'Listfiles' )
313 . $sep . $this->specialLink( 'Statistics' );
314 if( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
315 $s .= $sep . $this->getUploadLink();
316 }
317
318 global $wgSiteSupportPage;
319
320 if( $wgSiteSupportPage ) {
321 $s .= $sep . '<a href="' . htmlspecialchars( $wgSiteSupportPage ) . '" class="internal">'
322 . wfMsg( 'sitesupport' ) . '</a>';
323 }
324
325 $s .= $sep . $this->link(
326 SpecialPage::getTitleFor( 'Specialpages' ),
327 wfMsg( 'moredotdotdot' ),
328 array(),
329 array(),
330 array( 'known', 'noclasses' )
331 );
332
333 $s .= $sep . "\n</div>\n";
334 return $s;
335 }
336
337 function menuHead( $key ) {
338 $s = "\n<h6>" . wfMsg( $key ) . "</h6>";
339 return $s;
340 }
341
342 function searchForm( $label = '' ) {
343 global $wgRequest, $wgUseTwoButtonsSearchForm;
344
345 $search = $wgRequest->getText( 'search' );
346 $action = $this->escapeSearchLink();
347 $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
348 if( $label != '' ) {
349 $s .= "{$label}: ";
350 }
351
352 $s .= "<input type='text' id=\"searchInput{$this->searchboxes}\" class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
353 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" /><br />"
354 . "<input type='submit' id=\"searchGoButton{$this->searchboxes}\" class=\"searchButton\" name=\"go\" value=\"" . htmlspecialchars( wfMsg( 'searcharticle' ) ) . "\" />";
355
356 if( $wgUseTwoButtonsSearchForm ) {
357 $s .= "<input type='submit' id=\"mw-searchButton{$this->searchboxes}\" class=\"searchButton\" name=\"fulltext\" value=\"" . htmlspecialchars( wfMsg( 'search' ) ) . "\" />\n";
358 } else {
359 $s .= '<div><a href="' . $action . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a></div>\n";
360 }
361
362 $s .= '</form>';
363
364 // Ensure unique id's for search boxes made after the first
365 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
366
367 return $s;
368 }
369 }