* (bug 6100) BiDi: different directionality for user interface and wiki content ...
[lhc/web/wiklou.git] / skins / Standard.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( -1 );
12
13 /**
14 * @todo document
15 * @package MediaWiki
16 * @subpackage Skins
17 */
18 class SkinStandard extends Skin {
19
20 /**
21 *
22 */
23 function getHeadScripts() {
24 global $wgStylePath, $wgJsMimeType;
25
26 $s = parent::getHeadScripts();
27 if ( 3 == $this->qbSetting() ) { # Floating left
28 $s .= "<script language='javascript' type='$wgJsMimeType' " .
29 "src='{$wgStylePath}/common/sticky.js'></script>\n";
30 }
31 return $s;
32 }
33
34 /**
35 *
36 */
37 function getUserStyles() {
38 global $wgStylePath;
39 $s = '';
40 if ( 3 == $this->qbSetting() ) { # Floating left
41 $s .= "<style type='text/css'>\n" .
42 "@import '{$wgStylePath}/common/quickbar.css';\n</style>\n";
43 } else if ( 4 == $this->qbSetting() ) { # Floating right
44 $s .= "<style type='text/css'>\n" .
45 "@import '{$wgStylePath}/common/quickbar-right.css';\n</style>\n";
46 }
47 $s .= parent::getUserStyles();
48 return $s;
49 }
50
51 /**
52 *
53 */
54 function doGetUserStyles() {
55 global $wgStylePath, $wgLang, $wgUser;
56
57 $s = parent::doGetUserStyles();
58 $qb = $this->qbSetting();
59
60 if ( (!$wgUser->isLoggedIn() && $wgLang->isRTL() ) ||
61 ( 2 == $qb ) ) { # Right
62 $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
63 "border-left: 2px solid #000000; }\n" .
64 "#article { margin-left: 4px; margin-right: 152px; }\n";
65 } else if ( (!$wgUser->isLoggedIn()) ||
66 ( 1 == $qb || 3 == $qb ) ) {
67 $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
68 "border-right: 1px solid gray; }\n" .
69 "#article { margin-left: 152px; margin-right: 4px; }\n";
70 } else if ( 4 == $qb) {
71 $s .= "#quickbar { border-right: 1px solid gray; }\n" .
72 "#article { margin-right: 152px; margin-left: 4px; }\n";
73 }
74 return $s;
75 }
76
77 /**
78 *
79 */
80 function getBodyOptions() {
81 $a = parent::getBodyOptions();
82
83 if ( 3 == $this->qbSetting() ) { # Floating left
84 $qb = "setup(\"quickbar\")";
85 if($a["onload"]) {
86 $a["onload"] .= ";$qb";
87 } else {
88 $a["onload"] = $qb;
89 }
90 }
91 return $a;
92 }
93
94 function doAfterContent() {
95 global $wgLang;
96 $fname = 'SkinStandard::doAfterContent';
97 wfProfileIn( $fname );
98 wfProfileIn( $fname.'-1' );
99
100 $s = "\n</div><br style=\"clear:both\" />\n";
101 $s .= "\n<div id='footer'>";
102 $s .= '<table border="0" cellspacing="0"><tr>';
103
104 wfProfileOut( $fname.'-1' );
105 wfProfileIn( $fname.'-2' );
106
107 $qb = $this->qbSetting();
108 $shove = ($qb != 0);
109 $left = ($qb == 1 || $qb == 3);
110 if($wgLang->isRTL()) $left = !$left;
111
112 if ( $shove && $left ) { # Left
113 $s .= $this->getQuickbarCompensator();
114 }
115 wfProfileOut( $fname.'-2' );
116 wfProfileIn( $fname.'-3' );
117 $l = $wgLang->isRTL() ? 'right' : 'left';
118 $s .= "<td class='bottom' align='$l' valign='top'>";
119
120 $s .= $this->bottomLinks();
121 $s .= "\n<br />" . $this->mainPageLink()
122 . ' | ' . $this->aboutLink()
123 . ' | ' . $this->specialLink( 'recentchanges' )
124 . ' | ' . $this->searchForm()
125 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
126
127 $s .= "</td>";
128 if ( $shove && !$left ) { # Right
129 $s .= $this->getQuickbarCompensator();
130 }
131 $s .= "</tr></table>\n</div>\n</div>\n";
132
133 wfProfileOut( $fname.'-3' );
134 wfProfileIn( $fname.'-4' );
135 if ( 0 != $qb ) { $s .= $this->quickBar(); }
136 wfProfileOut( $fname.'-4' );
137 wfProfileOut( $fname );
138 return $s;
139 }
140
141 function quickBar() {
142 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
143 global $wgEnableUploads, $wgRemoteUploads;
144
145 $fname = 'Skin::quickBar';
146 wfProfileIn( $fname );
147
148 $action = $wgRequest->getText( 'action' );
149 $wpPreview = $wgRequest->getBool( 'wpPreview' );
150 $tns=$wgTitle->getNamespace();
151
152 $s = "\n<div id='quickbar'>";
153 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
154
155 $sep = "\n<br />";
156
157 # Use the first heading from the Monobook sidebar as the "browse" section
158 $bar = $this->buildSidebar();
159 $browseLinks = reset( $bar );
160
161 foreach ( $browseLinks as $link ) {
162 if ( $link['text'] != '-' ) {
163 $s .= "<a href=\"{$link['href']}\">" .
164 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
165 }
166 }
167
168 if( $wgUser->isLoggedIn() ) {
169 $s.= $this->specialLink( 'watchlist' ) ;
170 $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
171 wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
172 }
173 // only show watchlist link if logged in
174 $s .= "\n<hr class='sep' />";
175 $articleExists = $wgTitle->getArticleId();
176 if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
177 if($wgOut->isArticle()) {
178 $s .= '<strong>' . $this->editThisPage() . '</strong>';
179 } else { # backlink to the article in edit or history mode
180 if($articleExists){ # no backlink if no article
181 switch($tns) {
182 case 0:
183 $text = wfMsg('articlepage');
184 break;
185 case 1:
186 $text = wfMsg('viewtalkpage');
187 break;
188 case 2:
189 $text = wfMsg('userpage');
190 break;
191 case 3:
192 $text = wfMsg('viewtalkpage');
193 break;
194 case 4:
195 $text = wfMsg('projectpage');
196 break;
197 case 5:
198 $text = wfMsg('viewtalkpage');
199 break;
200 case 6:
201 $text = wfMsg('imagepage');
202 break;
203 case 7:
204 $text = wfMsg('viewtalkpage');
205 break;
206 default:
207 $text= wfMsg('articlepage');
208 }
209
210 $link = $wgTitle->getText();
211 if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
212 $link = $nstext . ':' . $link ;
213 }
214
215 $s .= $this->makeLink( $link, $text );
216 } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) {
217 # we just throw in a "New page" text to tell the user that he's in edit mode,
218 # and to avoid messing with the separator that is prepended to the next item
219 $s .= '<strong>' . wfMsg('newpage') . '</strong>';
220 }
221
222 }
223
224 # "Post a comment" link
225 if( ( $wgTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
226 $s .= '<br />' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit&section=new' );
227
228 #if( $tns%2 && $action!='edit' && !$wpPreview) {
229 #$s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit&section=new');
230 #}
231
232 /*
233 watching could cause problems in edit mode:
234 if user edits article, then loads "watch this article" in background and then saves
235 article with "Watch this article" checkbox disabled, the article is transparently
236 unwatched. Therefore we do not show the "Watch this page" link in edit mode
237 */
238 if ( $wgUser->isLoggedIn() && $articleExists) {
239 if($action!='edit' && $action != 'submit' )
240 {
241 $s .= $sep . $this->watchThisPage();
242 }
243 if ( $wgTitle->userCanEdit() )
244 $s .= $sep . $this->moveThisPage();
245 }
246 if ( $wgUser->isAllowed('delete') and $articleExists ) {
247 $s .= $sep . $this->deleteThisPage() .
248 $sep . $this->protectThisPage();
249 }
250 $s .= $sep . $this->talkLink();
251 if ($articleExists && $action !='history') {
252 $s .= $sep . $this->historyLink();
253 }
254 $s.=$sep . $this->whatLinksHere();
255
256 if($wgOut->isArticleRelated()) {
257 $s .= $sep . $this->watchPageLinksLink();
258 }
259
260 if ( NS_USER == $wgTitle->getNamespace()
261 || $wgTitle->getNamespace() == NS_USER_TALK ) {
262
263 $id=User::idFromName($wgTitle->getText());
264 $ip=User::isIP($wgTitle->getText());
265
266 if($id||$ip) {
267 $s .= $sep . $this->userContribsLink();
268 }
269 if( $this->showEmailUser( $id ) ) {
270 $s .= $sep . $this->emailUserLink();
271 }
272 }
273 $s .= "\n<br /><hr class='sep' />";
274 }
275
276 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
277 $s .= $this->specialLink( 'upload' ) . $sep;
278 }
279 $s .= $this->specialLink( 'specialpages' )
280 . $sep . $this->bugReportsLink();
281
282 global $wgSiteSupportPage;
283 if( $wgSiteSupportPage ) {
284 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
285 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
286 }
287
288 $s .= "\n<br /></div>\n";
289 wfProfileOut( $fname );
290 return $s;
291 }
292
293
294 }
295
296 ?>