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