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