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