Fix support of legacy skins Standard & CologneBlue for user language direction: the...
[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 */#topbar, #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 */#topbar, #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 */#topbar, #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 */#topbar, #footer { margin-left: 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="' . $mainPageObj->escapeLocalURL() . '">';
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-linkcollection">';
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()->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 $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()->getLang()->pipeList( $s );
193 }
194
195 /**
196 * Compute the sidebar
197 * @access private
198 *
199 * @return string
200 */
201 function quickBar(){
202 $tns = $this->getSkin()->getTitle()->getNamespace();
203
204 $s = "\n<div id='quickbar'>";
205
206 $sep = '<br />';
207 $s .= $this->menuHead( 'qbfind' );
208 $s .= $this->searchForm();
209
210 $s .= $this->menuHead( 'qbbrowse' );
211
212 # Use the first heading from the Monobook sidebar as the "browse" section
213 $bar = $this->getSkin()->buildSidebar();
214 unset( $bar['SEARCH'] );
215 unset( $bar['LANGUAGES'] );
216 unset( $bar['TOOLBOX'] );
217
218 $barnumber = 1;
219 foreach ( $bar as $heading => $browseLinks ) {
220 if ( $barnumber > 1 ) {
221 $headingMsg = wfMessage( $heading );
222 if ( $headingMsg->exists() ) {
223 $h = $headingMsg->text();
224 } else {
225 $h = $heading;
226 }
227 $s .= "\n<h6>" . htmlspecialchars( $h ) . "</h6>";
228 }
229 if( is_array( $browseLinks ) ) {
230 foreach ( $browseLinks as $link ) {
231 if ( $link['text'] != '-' ) {
232 $s .= "<a href=\"{$link['href']}\">" .
233 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
234 }
235 }
236 }
237 $barnumber++;
238 }
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 ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
253 $dtp = $this->deleteThisPage();
254 if ( $dtp != '' ) {
255 $s .= $sep . $dtp;
256 }
257 }
258 if ( $this->getSkin()->getUser()->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 if( $tns == NS_USER || $tns == NS_USER_TALK ) {
282 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
283 if( $id != 0 ) {
284 $s .= $sep . $this->userContribsLink();
285 if( $this->getSkin()->showEmailUser( $id ) ) {
286 $s .= $sep . $this->emailUserLink();
287 }
288 }
289 }
290 $s .= $sep;
291 }
292
293 $s .= $this->menuHead( 'qbmyoptions' );
294 if ( $this->data['loggedin'] ) {
295 $tl = Linker::link(
296 $this->getSkin()->getUser()->getTalkPage(),
297 wfMsg( 'mytalk' ),
298 array(),
299 array(),
300 array( 'known', 'noclasses' )
301 );
302 if ( $this->getSkin()->getUser()->getNewtalk() ) {
303 $tl .= ' *';
304 }
305
306 $s .= Linker::link(
307 $this->getSkin()->getUser()->getUserPage(),
308 wfMsg( 'mypage' ),
309 array(),
310 array(),
311 array( 'known', 'noclasses' )
312 ) . $sep . $tl . $sep . Linker::specialLink( 'Watchlist' )
313 . $sep .
314 Linker::link(
315 SpecialPage::getSafeTitleFor( 'Contributions', $this->getSkin()->getUser()->getName() ),
316 wfMsg( 'mycontris' ),
317 array(),
318 array(),
319 array( 'known', 'noclasses' )
320 ) . $sep . Linker::specialLink( 'Preferences' )
321 . $sep . Linker::specialLink( 'Userlogout' );
322 } else {
323 $s .= Linker::specialLink( 'Userlogin' );
324 }
325
326 $s .= $this->menuHead( 'qbspecialpages' )
327 . Linker::specialLink( 'Newpages' )
328 . $sep . Linker::specialLink( 'Listfiles' )
329 . $sep . Linker::specialLink( 'Statistics' );
330 if( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getSkin()->getUser() ) === true ) {
331 $s .= $sep . $this->getUploadLink();
332 }
333
334 global $wgSiteSupportPage;
335
336 if( $wgSiteSupportPage ) {
337 $s .= $sep . '<a href="' . htmlspecialchars( $wgSiteSupportPage ) . '" class="internal">'
338 . wfMsg( 'sitesupport' ) . '</a>';
339 }
340
341 $s .= $sep . Linker::link(
342 SpecialPage::getTitleFor( 'Specialpages' ),
343 wfMsg( 'moredotdotdot' ),
344 array(),
345 array(),
346 array( 'known', 'noclasses' )
347 );
348
349 $s .= $sep . "\n</div>\n";
350 return $s;
351 }
352
353 /**
354 * @param $key string
355 * @return string
356 */
357 function menuHead( $key ) {
358 $s = "\n<h6>" . wfMsg( $key ) . "</h6>";
359 return $s;
360 }
361
362 /**
363 * @param $label string
364 * @return string
365 */
366 function searchForm( $label = '' ) {
367 global $wgUseTwoButtonsSearchForm;
368
369 $search = $this->getSkin()->getRequest()->getText( 'search' );
370 $action = $this->data['searchaction'];
371 $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
372 if( $label != '' ) {
373 $s .= "{$label}: ";
374 }
375
376 $s .= "<input type='text' id=\"searchInput{$this->searchboxes}\" class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
377 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" /><br />"
378 . "<input type='submit' id=\"searchGoButton{$this->searchboxes}\" class=\"searchButton\" name=\"go\" value=\"" . htmlspecialchars( wfMsg( 'searcharticle' ) ) . "\" />";
379
380 if( $wgUseTwoButtonsSearchForm ) {
381 $s .= "<input type='submit' id=\"mw-searchButton{$this->searchboxes}\" class=\"searchButton\" name=\"fulltext\" value=\"" . htmlspecialchars( wfMsg( 'search' ) ) . "\" />\n";
382 } else {
383 $s .= '<div><a href="' . $action . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a></div>\n";
384 }
385
386 $s .= '</form>';
387
388 // Ensure unique id's for search boxes made after the first
389 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
390
391 return $s;
392 }
393 }