* (bug 13824) AJAX search suggestion now works with non-SkinTemplate skins
[lhc/web/wiklou.git] / skins / CologneBlue.php
1 <?php
2 /**
3 * See docs/skin.txt
4 *
5 * @todo document
6 * @addtogroup Skins
7 */
8
9 if( !defined( 'MEDIAWIKI' ) )
10 die( -1 );
11
12 /**
13 * @todo document
14 * @addtogroup Skins
15 */
16 class SkinCologneBlue extends Skin {
17
18 function getStylesheet() {
19 return 'common/cologneblue.css';
20 }
21 function getSkinName() {
22 return "cologneblue";
23 }
24
25 function doBeforeContent() {
26
27 $s = "";
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 {
68 global $wgOut;
69
70 $s = "\n</div><br clear='all' />\n";
71
72 $s .= "\n<div id='footer'>";
73 $s .= "<table width='98%' border='0' cellspacing='0'><tr>";
74
75 $qb = $this->qbSetting();
76 if ( 1 == $qb || 3 == $qb ) { # Left
77 $s .= $this->getQuickbarCompensator();
78 }
79 $s .= "<td class='bottom' align='center' valign='top'>";
80
81 $s .= $this->bottomLinks();
82 $s .= "\n<br />" . $this->makeKnownLinkObj( Title::newMainPage() ) . " | "
83 . $this->aboutLink() . " | "
84 . $this->searchForm( wfMsg( "qbfind" ) );
85
86 $s .= "\n<br />" . $this->pageStats();
87
88 $s .= "</td>";
89 if ( 2 == $qb ) { # Right
90 $s .= $this->getQuickbarCompensator();
91 }
92 $s .= "</tr></table>\n</div>\n</div>\n";
93
94 if ( 0 != $qb ) { $s .= $this->quickBar(); }
95 return $s;
96 }
97
98 function doGetUserStyles() {
99 global $wgOut;
100 $s = parent::doGetUserStyles();
101 $qb = $this->qbSetting();
102
103 if ( 2 == $qb ) { # Right
104 $s .= "#quickbar { position: absolute; right: 4px; }\n" .
105 "#article { margin-left: 4px; margin-right: 148px; }\n";
106 } else if ( 1 == $qb ) {
107 $s .= "#quickbar { position: absolute; left: 4px; }\n" .
108 "#article { margin-left: 148px; margin-right: 4px; }\n";
109 } else if ( 3 == $qb ) { # Floating left
110 $s .= "#quickbar { position:absolute; left:4px } \n" .
111 "#topbar { margin-left: 148px }\n" .
112 "#article { margin-left:148px; margin-right: 4px; } \n" .
113 "body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto ;bottom:4px;} \n"; # Hides from IE
114 } else if ( 4 == $qb ) { # Floating right
115 $s .= "#quickbar { position: fixed; right: 4px; } \n" .
116 "#topbar { margin-right: 148px }\n" .
117 "#article { margin-right: 148px; margin-left: 4px; } \n" .
118 "body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto ;bottom:4px;} \n"; # Hides from IE
119 }
120 return $s;
121 }
122
123 function sysLinks() {
124 global $wgUser, $wgContLang, $wgTitle;
125 $li = $wgContLang->specialPage("Userlogin");
126 $lo = $wgContLang->specialPage("Userlogout");
127
128 $rt = $wgTitle->getPrefixedURL();
129 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
130 $q = "";
131 } else {
132 $q = "returnto={$rt}";
133 }
134
135 $s = "" .
136 $this->mainPageLink()
137 . " | " .
138 $this->makeKnownLink( wfMsgForContent( "aboutpage" ), wfMsg( "about" ) )
139 . " | " .
140 $this->makeKnownLink( wfMsgForContent( "helppage" ), wfMsg( "help" ) )
141 . " | " .
142 $this->makeKnownLink( wfMsgForContent( "faqpage" ), wfMsg("faq") )
143 . " | " .
144 $this->specialLink( "specialpages" );
145
146 /* show links to different language variants */
147 $s .= $this->variantLinks();
148 $s .= $this->extensionTabLinks();
149
150 $s .= " | ";
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 return $s;
158 }
159
160 /**
161 * Compute the sidebar
162 * @access private
163 */
164 function quickBar()
165 {
166 global $wgOut, $wgTitle, $wgUser, $wgLang, $wgContLang, $wgEnableUploads;
167
168 $tns=$wgTitle->getNamespace();
169
170 $s = "\n<div id='quickbar'>";
171
172 $sep = "<br />";
173 $s .= $this->menuHead( "qbfind" );
174 $s .= $this->searchForm();
175
176 $s .= $this->menuHead( "qbbrowse" );
177
178 # Use the first heading from the Monobook sidebar as the "browse" section
179 $bar = $this->buildSidebar();
180 $browseLinks = reset( $bar );
181
182 foreach ( $browseLinks as $link ) {
183 if ( $link['text'] != '-' ) {
184 $s .= "<a href=\"{$link['href']}\">" .
185 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
186 }
187 }
188
189 if ( $wgOut->isArticle() ) {
190 $s .= $this->menuHead( "qbedit" );
191 $s .= "<strong>" . $this->editThisPage() . "</strong>";
192
193 $s .= $sep . $this->makeKnownLink( wfMsgForContent( "edithelppage" ), wfMsg( "edithelp" ) );
194
195 if( $wgUser->isLoggedIn() ) {
196 $s .= $sep . $this->moveThisPage();
197 }
198 if ( $wgUser->isAllowed('delete') ) {
199 $dtp = $this->deleteThisPage();
200 if ( "" != $dtp ) {
201 $s .= $sep . $dtp;
202 }
203 }
204 if ( $wgUser->isAllowed('protect') ) {
205 $ptp = $this->protectThisPage();
206 if ( "" != $ptp ) {
207 $s .= $sep . $ptp;
208 }
209 }
210 $s .= $sep;
211
212 $s .= $this->menuHead( "qbpageoptions" );
213 $s .= $this->talkLink()
214 . $sep . $this->commentLink()
215 . $sep . $this->printableLink();
216 if ( $wgUser->isLoggedIn() ) {
217 $s .= $sep . $this->watchThisPage();
218 }
219
220 $s .= $sep;
221
222 $s .= $this->menuHead("qbpageinfo")
223 . $this->historyLink()
224 . $sep . $this->whatLinksHere()
225 . $sep . $this->watchPageLinksLink();
226
227 if( $tns == NS_USER || $tns == NS_USER_TALK ) {
228 $id=User::idFromName($wgTitle->getText());
229 if ($id != 0) {
230 $s .= $sep . $this->userContribsLink();
231 if( $this->showEmailUser( $id ) ) {
232 $s .= $sep . $this->emailUserLink();
233 }
234 }
235 }
236 $s .= $sep;
237 }
238
239 $s .= $this->menuHead( "qbmyoptions" );
240 if ( $wgUser->isLoggedIn() ) {
241 $name = $wgUser->getName();
242 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
243 wfMsg( 'mytalk' ) );
244 if ( $wgUser->getNewtalk() ) {
245 $tl .= " *";
246 }
247
248 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
249 wfMsg( "mypage" ) )
250 . $sep . $tl
251 . $sep . $this->specialLink( "watchlist" )
252 . $sep . $this->makeKnownLinkObj( SpecialPage::getSafeTitleFor( "Contributions", $wgUser->getName() ),
253 wfMsg( "mycontris" ) )
254 . $sep . $this->specialLink( "preferences" )
255 . $sep . $this->specialLink( "userlogout" );
256 } else {
257 $s .= $this->specialLink( "userlogin" );
258 }
259
260 $s .= $this->menuHead( "qbspecialpages" )
261 . $this->specialLink( "newpages" )
262 . $sep . $this->specialLink( "imagelist" )
263 . $sep . $this->specialLink( "statistics" )
264 . $sep . $this->bugReportsLink();
265 if ( $wgUser->isLoggedIn() && $wgEnableUploads ) {
266 $s .= $sep . $this->specialLink( "upload" );
267 }
268 global $wgSiteSupportPage;
269 if( $wgSiteSupportPage) {
270 $s .= $sep."<a href=\"".htmlspecialchars($wgSiteSupportPage)."\" class =\"internal\">"
271 .wfMsg( "sitesupport" )."</a>";
272 }
273
274 $s .= $sep . $this->makeKnownLinkObj(
275 SpecialPage::getTitleFor( 'Specialpages' ),
276 wfMsg( 'moredotdotdot' ) );
277
278 $s .= $sep . "\n</div>\n";
279 return $s;
280 }
281
282 function menuHead( $key )
283 {
284 $s = "\n<h6>" . wfMsg( $key ) . "</h6>";
285 return $s;
286 }
287
288 function searchForm( $label = "" )
289 {
290 global $wgRequest;
291
292 $search = $wgRequest->getText( 'search' );
293 $action = $this->escapeSearchLink();
294 $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
295 if ( "" != $label ) { $s .= "{$label}: "; }
296
297 $s .= "<input type='text' id=\"searchInput{$this->searchboxes}\" class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
298 . htmlspecialchars(substr($search,0,256)) . "\" /><br />"
299 . "<input type='submit' id=\"searchGoButton{$this->searchboxes}\" class=\"searchButton\" name=\"go\" value=\"" . htmlspecialchars( wfMsg( "searcharticle" ) ) . "\" />"
300 . "<input type='submit' id=\"mw-searchButton{$this->searchboxes}\" class=\"searchButton\" name=\"fulltext\" value=\"" . htmlspecialchars( wfMsg( "search" ) ) . "\" /></form>";
301
302 // Ensure unique id's for search boxes made after the first
303 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
304
305 return $s;
306 }
307 }
308
309