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