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