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