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