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