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