Use Skin->getCategories() instead of Skin->getCategoryLinks() and manually wrapping...
[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' );
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
81 $s .= $this->getSkin()->getCategories();
82
83 $s .= '<br />' . $this->pageTitleLinks();
84 $s .= '</span></font>';
85
86 $s .= "</td></tr></table>\n";
87
88 $s .= "\n</div>\n<div id='article'>";
89
90 $notice = $this->getSkin()->getSiteNotice();
91 if( $notice ) {
92 $s .= "\n<div id='siteNotice'>$notice</div>\n";
93 }
94 $s .= $this->pageTitle();
95 $s .= $this->pageSubtitle() . "\n";
96 return $s;
97 }
98
99 /**
100 * @return string
101 */
102 function doAfterContent(){
103 $s = "\n</div><br clear='all' />\n";
104
105 $s .= "\n<div id='footer'>";
106 $s .= '<table width="98%" border="0" cellspacing="0"><tr>';
107
108 $qb = $this->getSkin()->qbSetting();
109 if ( 1 == $qb || 3 == $qb ) { # Left
110 $s .= $this->getQuickbarCompensator();
111 }
112 $s .= '<td class="bottom">';
113
114 $s .= $this->bottomLinks();
115 $s .= $this->getSkin()->getLang()->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 if ( 2 == $qb ) { # Right
131 $s .= $this->getQuickbarCompensator();
132 }
133 $s .= "</tr></table>\n</div>\n</div>\n";
134
135 if ( 0 != $qb ) {
136 $s .= $this->quickBar();
137 }
138 return $s;
139 }
140
141 /**
142 * @return string
143 */
144 function sysLinks() {
145 $li = SpecialPage::getTitleFor( 'Userlogin' );
146 $lo = SpecialPage::getTitleFor( 'Userlogout' );
147
148 $rt = $this->getSkin()->getTitle()->getPrefixedURL();
149 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
150 $q = array();
151 } else {
152 $q = array( 'returnto' => $rt );
153 }
154
155 $s = array(
156 $this->getSkin()->mainPageLink(),
157 Linker::linkKnown(
158 Title::newFromText( wfMsgForContent( 'aboutpage' ) ),
159 wfMsg( 'about' )
160 ),
161 Linker::linkKnown(
162 Title::newFromText( wfMsgForContent( 'helppage' ) ),
163 wfMsg( 'help' )
164 ),
165 Linker::linkKnown(
166 Title::newFromText( wfMsgForContent( 'faqpage' ) ),
167 wfMsg( 'faq' )
168 ),
169 Linker::specialLink( 'Specialpages' )
170 );
171
172 /* show links to different language variants */
173 if( $this->variantLinks() ) {
174 $s[] = $this->variantLinks();
175 }
176 if( $this->extensionTabLinks() ) {
177 $s[] = $this->extensionTabLinks();
178 }
179 if ( $this->data['loggedin'] ) {
180 $s[] = Linker::linkKnown(
181 $lo,
182 wfMsg( 'logout' ),
183 array(),
184 $q
185 );
186 } else {
187 $s[] = Linker::linkKnown(
188 $li,
189 wfMsg( 'login' ),
190 array(),
191 $q
192 );
193 }
194
195 return $this->getSkin()->getLang()->pipeList( $s );
196 }
197
198 /**
199 * Compute the sidebar
200 * @access private
201 *
202 * @return string
203 */
204 function quickBar(){
205 $tns = $this->getSkin()->getTitle()->getNamespace();
206
207 $s = "\n<div id='quickbar'>";
208
209 $sep = '<br />';
210 $s .= $this->menuHead( 'qbfind' );
211 $s .= $this->searchForm();
212
213 $s .= $this->menuHead( 'qbbrowse' );
214
215 # Use the first heading from the Monobook sidebar as the "browse" section
216 $bar = $this->getSkin()->buildSidebar();
217 unset( $bar['SEARCH'] );
218 unset( $bar['LANGUAGES'] );
219 unset( $bar['TOOLBOX'] );
220
221 $barnumber = 1;
222 foreach ( $bar as $heading => $browseLinks ) {
223 if ( $barnumber > 1 ) {
224 $headingMsg = wfMessage( $heading );
225 if ( $headingMsg->exists() ) {
226 $h = $headingMsg->text();
227 } else {
228 $h = $heading;
229 }
230 $s .= "\n<h6>" . htmlspecialchars( $h ) . "</h6>";
231 }
232 if( is_array( $browseLinks ) ) {
233 foreach ( $browseLinks as $link ) {
234 if ( $link['text'] != '-' ) {
235 $s .= "<a href=\"{$link['href']}\">" .
236 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
237 }
238 }
239 }
240 $barnumber++;
241 }
242
243 if ( $this->data['isarticle'] ) {
244 $s .= $this->menuHead( 'qbedit' );
245 $s .= '<strong>' . $this->editThisPage() . '</strong>';
246
247 $s .= $sep . Linker::linkKnown(
248 Title::newFromText( wfMsgForContent( 'edithelppage' ) ),
249 wfMsg( 'edithelp' )
250 );
251
252 if( $this->data['loggedin'] ) {
253 $s .= $sep . $this->moveThisPage();
254 }
255 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
256 $dtp = $this->deleteThisPage();
257 if ( $dtp != '' ) {
258 $s .= $sep . $dtp;
259 }
260 }
261 if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
262 $ptp = $this->protectThisPage();
263 if ( $ptp != '' ) {
264 $s .= $sep . $ptp;
265 }
266 }
267 $s .= $sep;
268
269 $s .= $this->menuHead( 'qbpageoptions' );
270 $s .= $this->talkLink()
271 . $sep . $this->commentLink()
272 . $sep . $this->printableLink();
273 if ( $this->data['loggedin'] ) {
274 $s .= $sep . $this->watchThisPage();
275 }
276
277 $s .= $sep;
278
279 $s .= $this->menuHead( 'qbpageinfo' )
280 . $this->historyLink()
281 . $sep . $this->whatLinksHere()
282 . $sep . $this->watchPageLinksLink();
283
284 if( $tns == NS_USER || $tns == NS_USER_TALK ) {
285 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
286 if( $id != 0 ) {
287 $s .= $sep . $this->userContribsLink();
288 if( $this->getSkin()->showEmailUser( $id ) ) {
289 $s .= $sep . $this->emailUserLink();
290 }
291 }
292 }
293 $s .= $sep;
294 }
295
296 $s .= $this->menuHead( 'qbmyoptions' );
297 if ( $this->data['loggedin'] ) {
298 $tl = Linker::link(
299 $this->getSkin()->getUser()->getTalkPage(),
300 wfMsg( 'mytalk' ),
301 array(),
302 array(),
303 array( 'known', 'noclasses' )
304 );
305 if ( $this->getSkin()->getUser()->getNewtalk() ) {
306 $tl .= ' *';
307 }
308
309 $s .= Linker::link(
310 $this->getSkin()->getUser()->getUserPage(),
311 wfMsg( 'mypage' ),
312 array(),
313 array(),
314 array( 'known', 'noclasses' )
315 ) . $sep . $tl . $sep . Linker::specialLink( 'Watchlist' )
316 . $sep .
317 Linker::link(
318 SpecialPage::getSafeTitleFor( 'Contributions', $this->getSkin()->getUser()->getName() ),
319 wfMsg( 'mycontris' ),
320 array(),
321 array(),
322 array( 'known', 'noclasses' )
323 ) . $sep . Linker::specialLink( 'Preferences' )
324 . $sep . Linker::specialLink( 'Userlogout' );
325 } else {
326 $s .= Linker::specialLink( 'Userlogin' );
327 }
328
329 $s .= $this->menuHead( 'qbspecialpages' )
330 . Linker::specialLink( 'Newpages' )
331 . $sep . Linker::specialLink( 'Listfiles' )
332 . $sep . Linker::specialLink( 'Statistics' );
333 if( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getSkin()->getUser() ) === true ) {
334 $s .= $sep . $this->getUploadLink();
335 }
336
337 global $wgSiteSupportPage;
338
339 if( $wgSiteSupportPage ) {
340 $s .= $sep . '<a href="' . htmlspecialchars( $wgSiteSupportPage ) . '" class="internal">'
341 . wfMsg( 'sitesupport' ) . '</a>';
342 }
343
344 $s .= $sep . Linker::link(
345 SpecialPage::getTitleFor( 'Specialpages' ),
346 wfMsg( 'moredotdotdot' ),
347 array(),
348 array(),
349 array( 'known', 'noclasses' )
350 );
351
352 $s .= $sep . "\n</div>\n";
353 return $s;
354 }
355
356 /**
357 * @param $key string
358 * @return string
359 */
360 function menuHead( $key ) {
361 $s = "\n<h6>" . wfMsg( $key ) . "</h6>";
362 return $s;
363 }
364
365 /**
366 * @param $label string
367 * @return string
368 */
369 function searchForm( $label = '' ) {
370 global $wgUseTwoButtonsSearchForm;
371
372 $search = $this->getSkin()->getRequest()->getText( 'search' );
373 $action = $this->data['searchaction'];
374 $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
375 if( $label != '' ) {
376 $s .= "{$label}: ";
377 }
378
379 $s .= "<input type='text' id=\"searchInput{$this->searchboxes}\" class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
380 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" /><br />"
381 . "<input type='submit' id=\"searchGoButton{$this->searchboxes}\" class=\"searchButton\" name=\"go\" value=\"" . htmlspecialchars( wfMsg( 'searcharticle' ) ) . "\" />";
382
383 if( $wgUseTwoButtonsSearchForm ) {
384 $s .= "<input type='submit' id=\"mw-searchButton{$this->searchboxes}\" class=\"searchButton\" name=\"fulltext\" value=\"" . htmlspecialchars( wfMsg( 'search' ) ) . "\" />\n";
385 } else {
386 $s .= '<div><a href="' . $action . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a></div>\n";
387 }
388
389 $s .= '</form>';
390
391 // Ensure unique id's for search boxes made after the first
392 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
393
394 return $s;
395 }
396 }