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