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