Same as r48631; added "@file" when needed, also added doc in redirect.php and install...
[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, #mw-data-after-content { 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, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }\n";
60 } else if ( 4 == $qb) {
61 $s .= "#quickbar { border-right: 1px solid gray; }\n" .
62 "#article, #mw-data-after-content { 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, $wgLang;
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 $s .= $this->bottomLinks();
111 $s .= "\n<br />" . $wgLang->pipeList( array(
112 $this->mainPageLink(),
113 $this->aboutLink(),
114 $this->specialLink( 'recentchanges' ),
115 $this->searchForm() ) )
116 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
117
118 $s .= "</td>";
119 if ( $shove && !$left ) { # Right
120 $s .= $this->getQuickbarCompensator();
121 }
122 $s .= "</tr></table>\n</div>\n</div>\n";
123
124 wfProfileOut( $fname.'-3' );
125 wfProfileIn( $fname.'-4' );
126 if ( 0 != $qb ) { $s .= $this->quickBar(); }
127 wfProfileOut( $fname.'-4' );
128 wfProfileOut( $fname );
129 return $s;
130 }
131
132 function quickBar() {
133 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
134 global $wgEnableUploads, $wgRemoteUploads;
135
136 $fname = 'Skin::quickBar';
137 wfProfileIn( $fname );
138
139 $action = $wgRequest->getText( 'action' );
140 $wpPreview = $wgRequest->getBool( 'wpPreview' );
141 $tns=$wgTitle->getNamespace();
142
143 $s = "\n<div id='quickbar'>";
144 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
145
146 $sep = "\n<br />";
147
148 # Use the first heading from the Monobook sidebar as the "browse" section
149 $bar = $this->buildSidebar();
150 unset( $bar['SEARCH'] );
151 unset( $bar['LANGUAGES'] );
152 unset( $bar['TOOLBOX'] );
153 $browseLinks = reset( $bar );
154
155 foreach ( $browseLinks as $link ) {
156 if ( $link['text'] != '-' ) {
157 $s .= "<a href=\"{$link['href']}\">" .
158 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
159 }
160 }
161
162 if( $wgUser->isLoggedIn() ) {
163 $s.= $this->specialLink( 'watchlist' ) ;
164 $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
165 wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
166 }
167 // only show watchlist link if logged in
168 $s .= "\n<hr class='sep' />";
169 $articleExists = $wgTitle->getArticleId();
170 if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
171 if($wgOut->isArticle()) {
172 $s .= '<strong>' . $this->editThisPage() . '</strong>';
173 } else { # backlink to the article in edit or history mode
174 if($articleExists){ # no backlink if no article
175 switch($tns) {
176 case NS_TALK:
177 case NS_USER_TALK:
178 case NS_PROJECT_TALK:
179 case NS_FILE_TALK:
180 case NS_MEDIAWIKI_TALK:
181 case NS_TEMPLATE_TALK:
182 case NS_HELP_TALK:
183 case NS_CATEGORY_TALK:
184 $text = wfMsg('viewtalkpage');
185 break;
186 case NS_MAIN:
187 $text = wfMsg( 'articlepage' );
188 break;
189 case NS_USER:
190 $text = wfMsg( 'userpage' );
191 break;
192 case NS_PROJECT:
193 $text = wfMsg( 'projectpage' );
194 break;
195 case NS_FILE:
196 $text = wfMsg( 'imagepage' );
197 break;
198 case NS_MEDIAWIKI:
199 $text = wfMsg( 'mediawikipage' );
200 break;
201 case NS_TEMPLATE:
202 $text = wfMsg( 'templatepage' );
203 break;
204 case NS_HELP:
205 $text = wfMsg( 'viewhelppage' );
206 break;
207 case NS_CATEGORY:
208 $text = wfMsg( 'categorypage' );
209 break;
210 default:
211 $text= wfMsg( 'articlepage' );
212 }
213
214 $link = $wgTitle->getText();
215 if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
216 $link = $nstext . ':' . $link ;
217 }
218
219 $s .= $this->makeLink( $link, $text );
220 } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) {
221 # we just throw in a "New page" text to tell the user that he's in edit mode,
222 # and to avoid messing with the separator that is prepended to the next item
223 $s .= '<strong>' . wfMsg('newpage') . '</strong>';
224 }
225
226 }
227
228 # "Post a comment" link
229 if( ( $wgTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
230 $s .= '<br />' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit&section=new' );
231
232 #if( $tns%2 && $action!='edit' && !$wpPreview) {
233 #$s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit&section=new');
234 #}
235
236 /*
237 watching could cause problems in edit mode:
238 if user edits article, then loads "watch this article" in background and then saves
239 article with "Watch this article" checkbox disabled, the article is transparently
240 unwatched. Therefore we do not show the "Watch this page" link in edit mode
241 */
242 if ( $wgUser->isLoggedIn() && $articleExists) {
243 if($action!='edit' && $action != 'submit' )
244 {
245 $s .= $sep . $this->watchThisPage();
246 }
247 if ( $wgTitle->userCan( 'edit' ) )
248 $s .= $sep . $this->moveThisPage();
249 }
250 if ( $wgUser->isAllowed('delete') and $articleExists ) {
251 $s .= $sep . $this->deleteThisPage() .
252 $sep . $this->protectThisPage();
253 }
254 $s .= $sep . $this->talkLink();
255 if ($articleExists && $action !='history') {
256 $s .= $sep . $this->historyLink();
257 }
258 $s.=$sep . $this->whatLinksHere();
259
260 if($wgOut->isArticleRelated()) {
261 $s .= $sep . $this->watchPageLinksLink();
262 }
263
264 if ( NS_USER == $wgTitle->getNamespace()
265 || $wgTitle->getNamespace() == NS_USER_TALK ) {
266
267 $id=User::idFromName($wgTitle->getText());
268 $ip=User::isIP($wgTitle->getText());
269
270 if( $id || $ip ){
271 $s .= $sep . $this->userContribsLink();
272 }
273 if( $this->showEmailUser( $id ) ) {
274 $s .= $sep . $this->emailUserLink();
275 }
276 }
277 $s .= "\n<br /><hr class='sep' />";
278 }
279
280 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
281 $s .= $this->specialLink( 'upload' ) . $sep;
282 }
283 $s .= $this->specialLink( 'specialpages' );
284
285 global $wgSiteSupportPage;
286 if( $wgSiteSupportPage ) {
287 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
288 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
289 }
290
291 $s .= "\n<br /></div>\n";
292 wfProfileOut( $fname );
293 return $s;
294 }
295
296
297 }