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