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