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