Follow-up I0b781c11 (2a55449): use User::getAutomaticGroups().
[lhc/web/wiklou.git] / skins / CologneBlue.php
1 <?php
2 /**
3 * Cologne Blue: A nicer-looking alternative to Standard.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @todo document
21 * @file
22 * @ingroup Skins
23 */
24
25 if( !defined( 'MEDIAWIKI' ) ) {
26 die( -1 );
27 }
28
29 /**
30 * @todo document
31 * @ingroup Skins
32 */
33 class SkinCologneBlue extends SkinLegacy {
34 var $skinname = 'cologneblue', $stylename = 'cologneblue',
35 $template = 'CologneBlueTemplate';
36
37 /**
38 * @param $out OutputPage
39 */
40 function setupSkinUserCss( OutputPage $out ){
41 parent::setupSkinUserCss( $out );
42 $out->addModuleStyles( 'skins.cologneblue' );
43
44 $qb = $this->qbSetting();
45 $rules = array();
46
47 if ( 2 == $qb ) { # Right
48 $rules[] = "/* @noflip */#quickbar { position: absolute; right: 4px; }";
49 $rules[] = "/* @noflip */#article { margin-left: 4px; margin-right: 148px; }";
50 $rules[] = "/* @noflip */#footer { margin-right: 152px; }";
51 } elseif ( 1 == $qb ) {
52 $rules[] = "/* @noflip */#quickbar { position: absolute; left: 4px; }";
53 $rules[] = "/* @noflip */#article { margin-left: 148px; margin-right: 4px; }";
54 $rules[] = "/* @noflip */#footer { margin-left: 152px; }";
55 } elseif ( 3 == $qb ) { # Floating left
56 $rules[] = "/* @noflip */#quickbar { position:absolute; left:4px }";
57 $rules[] = "/* @noflip */#topbar { margin-left: 148px }";
58 $rules[] = "/* @noflip */#article { margin-left:148px; margin-right: 4px; }";
59 $rules[] = "/* @noflip */body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto; bottom:4px;}"; # Hides from IE
60 $rules[] = "/* @noflip */#footer { margin-left: 152px; }";
61 } elseif ( 4 == $qb ) { # Floating right
62 $rules[] = "/* @noflip */#quickbar { position: fixed; right: 4px; }";
63 $rules[] = "/* @noflip */#topbar { margin-right: 148px }";
64 $rules[] = "/* @noflip */#article { margin-right: 148px; margin-left: 4px; }";
65 $rules[] = "/* @noflip */body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto; bottom:4px;}"; # Hides from IE
66 $rules[] = "/* @noflip */#footer { margin-right: 152px; }";
67 }
68 $style = implode( "\n", $rules );
69 $out->addInlineStyle( $style, 'flip' );
70 }
71
72 }
73
74 class CologneBlueTemplate extends LegacyTemplate {
75
76 /**
77 * @return string
78 */
79 function doBeforeContent() {
80 $mainPageObj = Title::newMainPage();
81
82 $s = "\n<div id='content'>\n<div id='topbar'>" .
83 '<table width="100%" border="0" cellspacing="0" cellpadding="8"><tr>';
84
85 $s .= '<td class="top" nowrap="nowrap">';
86 $s .= '<a href="' . htmlspecialchars( $mainPageObj->getLocalURL() ) . '">';
87 $s .= '<span id="sitetitle">' . wfMsg( 'sitetitle' ) . '</span></a>';
88
89 $s .= '</td><td class="top" id="top-syslinks" width="100%">';
90 $s .= $this->sysLinks();
91 $s .= '</td></tr><tr><td class="top-subheader">';
92
93 $s .= '<font size="-1"><span id="sitesub">';
94 $s .= htmlspecialchars( wfMsg( 'sitesubtitle' ) ) . '</span></font>';
95 $s .= '</td><td class="top-linkcollection">';
96
97 $s .= '<font size="-1"><span id="langlinks">';
98 $s .= str_replace( '<br />', '', $this->otherLanguages() );
99
100 $s .= $this->getSkin()->getCategories();
101
102 $s .= '<br />' . $this->pageTitleLinks();
103 $s .= '</span></font>';
104
105 $s .= "</td></tr></table>\n";
106
107 $s .= "\n</div>\n<div id='article'>";
108
109 $notice = $this->getSkin()->getSiteNotice();
110 if( $notice ) {
111 $s .= "\n<div id='siteNotice'>$notice</div>\n";
112 }
113 $s .= $this->pageTitle();
114 $s .= $this->pageSubtitle() . "\n";
115 return $s;
116 }
117
118 /**
119 * @return string
120 */
121 function doAfterContent(){
122 $s = "\n</div><br clear='all' />\n";
123
124 $s .= "\n<div id='footer'>";
125 $s .= '<table width="98%" border="0" cellspacing="0"><tr>';
126
127 $s .= '<td class="bottom">';
128
129 $s .= $this->bottomLinks();
130 $s .= $this->getSkin()->getLanguage()->pipeList( array(
131 "\n<br />" . Linker::link(
132 Title::newMainPage(),
133 null,
134 array(),
135 array(),
136 array( 'known', 'noclasses' )
137 ),
138 $this->getSkin()->aboutLink(),
139 $this->searchForm( wfMsg( 'qbfind' ) )
140 ) );
141
142 $s .= "\n<br />" . $this->pageStats();
143
144 $s .= '</td>';
145 $s .= "</tr></table>\n</div>\n</div>\n";
146
147 if ( $this->getSkin()->qbSetting() != 0 ) {
148 $s .= $this->quickBar();
149 }
150 return $s;
151 }
152
153 /**
154 * @return string
155 */
156 function sysLinks() {
157 $li = SpecialPage::getTitleFor( 'Userlogin' );
158 $lo = SpecialPage::getTitleFor( 'Userlogout' );
159
160 $rt = $this->getSkin()->getTitle()->getPrefixedURL();
161 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
162 $q = array();
163 } else {
164 $q = array( 'returnto' => $rt );
165 }
166
167 $s = array(
168 $this->getSkin()->mainPageLink(),
169 Linker::linkKnown(
170 Title::newFromText( wfMsgForContent( 'aboutpage' ) ),
171 wfMsg( 'about' )
172 ),
173 Linker::linkKnown(
174 Title::newFromText( wfMsgForContent( 'helppage' ) ),
175 wfMsg( 'help' )
176 ),
177 Linker::linkKnown(
178 Title::newFromText( wfMsgForContent( 'faqpage' ) ),
179 wfMsg( 'faq' )
180 ),
181 Linker::specialLink( 'Specialpages' )
182 );
183
184 /* show links to different language variants */
185 if( $this->variantLinks() ) {
186 $s[] = $this->variantLinks();
187 }
188 if( $this->extensionTabLinks() ) {
189 $s[] = $this->extensionTabLinks();
190 }
191 if ( $this->data['loggedin'] ) {
192 $s[] = Linker::linkKnown(
193 $lo,
194 wfMsg( 'logout' ),
195 array(),
196 $q
197 );
198 } else {
199 $s[] = Linker::linkKnown(
200 $li,
201 wfMsg( 'login' ),
202 array(),
203 $q
204 );
205 }
206
207 return $this->getSkin()->getLanguage()->pipeList( $s );
208 }
209
210 /**
211 * Compute the sidebar
212 * @access private
213 *
214 * @return string
215 */
216 function quickBar(){
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 if( is_array( $browseLinks ) ) {
243 foreach ( $browseLinks as $link ) {
244 if ( $link['text'] != '-' ) {
245 $s .= "<a href=\"{$link['href']}\">" .
246 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
247 }
248 }
249 }
250 $barnumber++;
251 }
252
253 $user = $this->getSkin()->getUser();
254
255 if ( $this->data['isarticle'] ) {
256 $s .= $this->menuHead( 'qbedit' );
257 $s .= '<strong>' . $this->editThisPage() . '</strong>';
258
259 $s .= $sep . Linker::linkKnown(
260 Title::newFromText( wfMsgForContent( 'edithelppage' ) ),
261 wfMsg( 'edithelp' )
262 );
263
264 if( $this->data['loggedin'] ) {
265 $s .= $sep . $this->moveThisPage();
266 }
267 if ( $user->isAllowed( 'delete' ) ) {
268 $dtp = $this->deleteThisPage();
269 if ( $dtp != '' ) {
270 $s .= $sep . $dtp;
271 }
272 }
273 if ( $user->isAllowed( 'protect' ) ) {
274 $ptp = $this->protectThisPage();
275 if ( $ptp != '' ) {
276 $s .= $sep . $ptp;
277 }
278 }
279 $s .= $sep;
280
281 $s .= $this->menuHead( 'qbpageoptions' );
282 $s .= $this->talkLink()
283 . $sep . $this->commentLink()
284 . $sep . $this->printableLink();
285 if ( $this->data['loggedin'] ) {
286 $s .= $sep . $this->watchThisPage();
287 }
288
289 $s .= $sep;
290
291 $s .= $this->menuHead( 'qbpageinfo' )
292 . $this->historyLink()
293 . $sep . $this->whatLinksHere()
294 . $sep . $this->watchPageLinksLink();
295
296 $title = $this->getSkin()->getTitle();
297 $tns = $title->getNamespace();
298 if ( $tns == NS_USER || $tns == NS_USER_TALK ) {
299 $id = User::idFromName( $title->getText() );
300 if( $id != 0 ) {
301 $s .= $sep . $this->userContribsLink();
302 if( $this->getSkin()->showEmailUser( $id ) ) {
303 $s .= $sep . $this->emailUserLink();
304 }
305 }
306 }
307 $s .= $sep;
308 }
309
310 $s .= $this->menuHead( 'qbmyoptions' );
311 if ( $this->data['loggedin'] ) {
312 $tl = Linker::link(
313 $user->getTalkPage(),
314 wfMsg( 'mytalk' ),
315 array(),
316 array(),
317 array( 'known', 'noclasses' )
318 );
319 if ( $user->getNewtalk() ) {
320 $tl .= ' *';
321 }
322
323 $s .= Linker::link(
324 $user->getUserPage(),
325 wfMsg( 'mypage' ),
326 array(),
327 array(),
328 array( 'known', 'noclasses' )
329 ) . $sep . $tl . $sep . Linker::specialLink( 'Watchlist' )
330 . $sep .
331 Linker::link(
332 SpecialPage::getSafeTitleFor( 'Contributions', $user->getName() ),
333 wfMsg( 'mycontris' ),
334 array(),
335 array(),
336 array( 'known', 'noclasses' )
337 ) . $sep . Linker::specialLink( 'Preferences' )
338 . $sep . Linker::specialLink( 'Userlogout' );
339 } else {
340 $s .= Linker::specialLink( 'Userlogin' );
341 }
342
343 $s .= $this->menuHead( 'qbspecialpages' )
344 . Linker::specialLink( 'Newpages' )
345 . $sep . Linker::specialLink( 'Listfiles' )
346 . $sep . Linker::specialLink( 'Statistics' );
347 if( UploadBase::isEnabled() && UploadBase::isAllowed( $user ) === true ) {
348 $s .= $sep . $this->getUploadLink();
349 }
350
351 global $wgSiteSupportPage;
352
353 if( $wgSiteSupportPage ) {
354 $s .= $sep . '<a href="' . htmlspecialchars( $wgSiteSupportPage ) . '" class="internal">'
355 . wfMsg( 'sitesupport' ) . '</a>';
356 }
357
358 $s .= $sep . Linker::link(
359 SpecialPage::getTitleFor( 'Specialpages' ),
360 wfMsg( 'moredotdotdot' ),
361 array(),
362 array(),
363 array( 'known', 'noclasses' )
364 );
365
366 $s .= $sep . "\n</div>\n";
367 return $s;
368 }
369
370 /**
371 * @param $key string
372 * @return string
373 */
374 function menuHead( $key ) {
375 $s = "\n<h6>" . wfMsg( $key ) . "</h6>";
376 return $s;
377 }
378
379 /**
380 * @param $label string
381 * @return string
382 */
383 function searchForm( $label = '' ) {
384 global $wgUseTwoButtonsSearchForm;
385
386 $search = $this->getSkin()->getRequest()->getText( 'search' );
387 $action = $this->data['searchaction'];
388 $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
389 if( $label != '' ) {
390 $s .= "{$label}: ";
391 }
392
393 $s .= "<input type='text' id=\"searchInput{$this->searchboxes}\" class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
394 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" /><br />"
395 . "<input type='submit' id=\"searchGoButton{$this->searchboxes}\" class=\"searchButton\" name=\"go\" value=\"" . htmlspecialchars( wfMsg( 'searcharticle' ) ) . "\" />";
396
397 if( $wgUseTwoButtonsSearchForm ) {
398 $s .= "<input type='submit' id=\"mw-searchButton{$this->searchboxes}\" class=\"searchButton\" name=\"fulltext\" value=\"" . htmlspecialchars( wfMsg( 'search' ) ) . "\" />\n";
399 } else {
400 $s .= '<div><a href="' . $action . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a></div>\n";
401 }
402
403 $s .= '</form>';
404
405 // Ensure unique id's for search boxes made after the first
406 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
407
408 return $s;
409 }
410 }