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