Merge "(bug 40541) Fixed $wgSecureLogin functionality."
[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 style="width: 100%;" 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">' . wfMessage( 'sitetitle' )->escaped() . '</span></a>';
88
89 $s .= '</td><td class="top" id="top-syslinks" style="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 .= wfMessage( 'sitesubtitle' )->escaped() . '</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 style="width: 98%;" 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::linkKnown(
132 Title::newMainPage()
133 ),
134 $this->getSkin()->aboutLink(),
135 $this->searchForm( wfMessage( 'qbfind' )->text() )
136 ) );
137
138 $s .= "\n<br />" . $this->pageStats();
139
140 $s .= '</td>';
141 $s .= "</tr></table>\n</div>\n</div>\n";
142
143 if ( $this->getSkin()->qbSetting() != 0 ) {
144 $s .= $this->quickBar();
145 }
146 return $s;
147 }
148
149 /**
150 * @return string
151 */
152 function sysLinks() {
153 $li = SpecialPage::getTitleFor( 'Userlogin' );
154 $lo = SpecialPage::getTitleFor( 'Userlogout' );
155
156 $rt = $this->getSkin()->getTitle()->getPrefixedURL();
157 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
158 $q = array();
159 } else {
160 $q = array( 'returnto' => $rt );
161 }
162
163 $s = array(
164 $this->getSkin()->mainPageLink(),
165 Linker::linkKnown(
166 Title::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
167 wfMessage( 'about' )->text()
168 ),
169 Linker::linkKnown(
170 Title::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
171 wfMessage( 'help' )->text()
172 ),
173 Linker::linkKnown(
174 Title::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
175 wfMessage( 'faq' )->text()
176 ),
177 Linker::specialLink( 'Specialpages' )
178 );
179
180 /* show links to different language variants */
181 if( $this->variantLinks() ) {
182 $s[] = $this->variantLinks();
183 }
184 if( $this->extensionTabLinks() ) {
185 $s[] = $this->extensionTabLinks();
186 }
187 if ( $this->data['loggedin'] ) {
188 $s[] = Linker::linkKnown(
189 $lo,
190 wfMessage( 'logout' )->text(),
191 array(),
192 $q
193 );
194 } else {
195 $s[] = Linker::linkKnown(
196 $li,
197 wfMessage( 'login' )->text(),
198 array(),
199 $q
200 );
201 }
202
203 return $this->getSkin()->getLanguage()->pipeList( $s );
204 }
205
206 /**
207 * Compute the sidebar
208 * @access private
209 *
210 * @return string
211 */
212 function quickBar(){
213 $s = "\n<div id='quickbar'>";
214
215 $sep = '<br />';
216 $s .= $this->menuHead( 'qbfind' );
217 $s .= $this->searchForm();
218
219 $s .= $this->menuHead( 'qbbrowse' );
220
221 # Use the first heading from the Monobook sidebar as the "browse" section
222 $bar = $this->getSkin()->buildSidebar();
223 unset( $bar['SEARCH'] );
224 unset( $bar['LANGUAGES'] );
225 unset( $bar['TOOLBOX'] );
226
227 $barnumber = 1;
228 foreach ( $bar as $heading => $browseLinks ) {
229 if ( $barnumber > 1 ) {
230 $headingMsg = wfMessage( $heading );
231 if ( $headingMsg->exists() ) {
232 $h = $headingMsg->text();
233 } else {
234 $h = $heading;
235 }
236 $s .= "\n<h6>" . htmlspecialchars( $h ) . "</h6>";
237 }
238 if( is_array( $browseLinks ) ) {
239 foreach ( $browseLinks as $link ) {
240 if ( $link['text'] != '-' ) {
241 $s .= "<a href=\"{$link['href']}\">" .
242 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
243 }
244 }
245 }
246 $barnumber++;
247 }
248
249 $user = $this->getSkin()->getUser();
250
251 if ( $this->data['isarticle'] ) {
252 $s .= $this->menuHead( 'qbedit' );
253 $s .= '<strong>' . $this->editThisPage() . '</strong>';
254
255 $s .= $sep . Linker::linkKnown(
256 Title::newFromText( wfMessage( 'edithelppage' )->inContentLanguage()->text() ),
257 wfMessage( 'edithelp' )->text()
258 );
259
260 if( $this->data['loggedin'] ) {
261 $s .= $sep . $this->moveThisPage();
262 }
263 if ( $user->isAllowed( 'delete' ) ) {
264 $dtp = $this->deleteThisPage();
265 if ( $dtp != '' ) {
266 $s .= $sep . $dtp;
267 }
268 }
269 if ( $user->isAllowed( 'protect' ) ) {
270 $ptp = $this->protectThisPage();
271 if ( $ptp != '' ) {
272 $s .= $sep . $ptp;
273 }
274 }
275 $s .= $sep;
276
277 $s .= $this->menuHead( 'qbpageoptions' );
278 $s .= $this->talkLink()
279 . $sep . $this->commentLink()
280 . $sep . $this->printableLink();
281 if ( $this->data['loggedin'] ) {
282 $s .= $sep . $this->watchThisPage();
283 }
284
285 $s .= $sep;
286
287 $s .= $this->menuHead( 'qbpageinfo' )
288 . $this->historyLink()
289 . $sep . $this->whatLinksHere()
290 . $sep . $this->watchPageLinksLink();
291
292 $title = $this->getSkin()->getTitle();
293 $tns = $title->getNamespace();
294 if ( $tns == NS_USER || $tns == NS_USER_TALK ) {
295 $id = User::idFromName( $title->getText() );
296 if( $id != 0 ) {
297 $s .= $sep . $this->userContribsLink();
298 if( $this->getSkin()->showEmailUser( $id ) ) {
299 $s .= $sep . $this->emailUserLink();
300 }
301 }
302 }
303 $s .= $sep;
304 }
305
306 $s .= $this->menuHead( 'qbmyoptions' );
307 if ( $this->data['loggedin'] ) {
308 $tl = Linker::linkKnown(
309 $user->getTalkPage(),
310 wfMessage( 'mytalk' )->escaped()
311 );
312 if ( $user->getNewtalk() ) {
313 $tl .= ' *';
314 }
315
316 $s .= Linker::linkKnown(
317 $user->getUserPage(),
318 wfMessage( 'mypage' )->escaped()
319 ) . $sep . $tl . $sep . Linker::specialLink( 'Watchlist' )
320 . $sep .
321 Linker::linkKnown(
322 SpecialPage::getSafeTitleFor( 'Contributions', $user->getName() ),
323 wfMessage( 'mycontris' )->escaped()
324 ) . $sep . Linker::specialLink( 'Preferences' )
325 . $sep . Linker::specialLink( 'Userlogout' );
326 } else {
327 $s .= Linker::specialLink( 'Userlogin' );
328 }
329
330 $s .= $this->menuHead( 'qbspecialpages' )
331 . Linker::specialLink( 'Newpages' )
332 . $sep . Linker::specialLink( 'Listfiles' )
333 . $sep . Linker::specialLink( 'Statistics' );
334 if( UploadBase::isEnabled() && UploadBase::isAllowed( $user ) === true ) {
335 $s .= $sep . $this->getUploadLink();
336 }
337
338 global $wgSiteSupportPage;
339
340 if( $wgSiteSupportPage ) {
341 $s .= $sep . '<a href="' . htmlspecialchars( $wgSiteSupportPage ) . '" class="internal">'
342 . wfMessage( 'sitesupport' )->escaped() . '</a>';
343 }
344
345 $s .= $sep . Linker::linkKnown(
346 SpecialPage::getTitleFor( 'Specialpages' ),
347 wfMessage( 'moredotdotdot' )->text()
348 );
349
350 $s .= $sep . "\n</div>\n";
351 return $s;
352 }
353
354 /**
355 * @param $key string
356 * @return string
357 */
358 function menuHead( $key ) {
359 $s = "\n<h6>" . wfMessage( $key )->text() . "</h6>";
360 return $s;
361 }
362
363 /**
364 * @param $label string
365 * @return string
366 */
367 function searchForm( $label = '' ) {
368 global $wgUseTwoButtonsSearchForm;
369
370 $search = $this->getSkin()->getRequest()->getText( 'search' );
371 $action = $this->data['searchaction'];
372 $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
373 if( $label != '' ) {
374 $s .= "{$label}: ";
375 }
376
377 $s .= "<input type='text' id=\"searchInput{$this->searchboxes}\" class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
378 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" /><br />"
379 . "<input type='submit' id=\"searchGoButton{$this->searchboxes}\" class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
380
381 if( $wgUseTwoButtonsSearchForm ) {
382 $s .= "<input type='submit' id=\"mw-searchButton{$this->searchboxes}\" class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
383 } else {
384 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";
385 }
386
387 $s .= '</form>';
388
389 // Ensure unique id's for search boxes made after the first
390 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
391
392 return $s;
393 }
394 }