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