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