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