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