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