Merge "(Bug 38439) Attempt on fixing the suicidal LangObjCache"
[lhc/web/wiklou.git] / skins / Standard.php
1 <?php
2 /**
3 * Standard (a.k.a. Classic) skin: old MediaWiki default skin
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 *
21 * @file
22 * @ingroup Skins
23 */
24
25 if( !defined( 'MEDIAWIKI' ) ) {
26 die( -1 );
27 }
28
29 /**
30 * @todo document
31 * @ingroup Skins
32 */
33 class SkinStandard extends SkinLegacy {
34 var $skinname = 'standard', $stylename = 'standard',
35 $template = 'StandardTemplate';
36
37 /**
38 * @param $out OutputPage
39 */
40 function setupSkinUserCss( OutputPage $out ){
41 parent::setupSkinUserCss( $out );
42 $out->addModuleStyles( 'skins.standard' );
43
44 $qb = $this->qbSetting();
45 $rules = array();
46
47 if ( 2 == $qb ) { # Right
48 $rules[] = "/* @noflip */#quickbar { position: absolute; top: 4px; right: 4px; border-left: 2px solid #000000; }";
49 $rules[] = "/* @noflip */#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }";
50 $rules[] = "/* @noflip */#topbar, #footer { margin-right: 152px; }";
51 } elseif ( 1 == $qb || 3 == $qb ) {
52 $rules[] = "/* @noflip */#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }";
53 $rules[] = "/* @noflip */#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }";
54 $rules[] = "/* @noflip */#topbar, #footer { margin-left: 152px; }";
55 if( 3 == $qb ) {
56 $rules[] = "/* @noflip */#quickbar { position: fixed; padding: 4px; }";
57 }
58 } elseif ( 4 == $qb ) {
59 $rules[] = "/* @noflip */#quickbar { position: fixed; right: 0; top: 0; padding: 4px; }";
60 $rules[] = "/* @noflip */#quickbar { border-right: 1px solid gray; }";
61 $rules[] = "/* @noflip */#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }";
62 $rules[] = "/* @noflip */#topbar, #footer { margin-right: 152px; }";
63 }
64 $style = implode( "\n", $rules );
65 $out->addInlineStyle( $style, 'flip' );
66 }
67
68 }
69
70 class StandardTemplate extends LegacyTemplate {
71
72 /**
73 * @return string
74 */
75 function doAfterContent() {
76 wfProfileIn( __METHOD__ );
77 wfProfileIn( __METHOD__ . '-1' );
78
79 $s = "\n</div><br style=\"clear:both\" />\n";
80 $s .= "\n<div id='footer'>";
81 $s .= '<table cellspacing="0"><tr>';
82
83 wfProfileOut( __METHOD__ . '-1' );
84 wfProfileIn( __METHOD__ . '-2' );
85 $l = $this->getSkin()->getLanguage()->alignStart();
86 $s .= "<td class='bottom' style='text-align: $l; vertical-align: top;'>";
87
88 $s .= $this->bottomLinks();
89 $s .= "\n<br />" . $this->getSkin()->getLanguage()->pipeList( array(
90 $this->getSkin()->mainPageLink(),
91 $this->getSkin()->aboutLink(),
92 Linker::specialLink( 'Recentchanges' ),
93 $this->searchForm() ) )
94 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
95
96 $s .= '</td>';
97 $s .= "</tr></table>\n</div>\n</div>\n";
98
99 wfProfileOut( __METHOD__ . '-2' );
100 wfProfileIn( __METHOD__ . '-3' );
101 if ( $this->getSkin()->qbSetting() != 0 ) {
102 $s .= $this->quickBar();
103 }
104 wfProfileOut( __METHOD__ . '-3' );
105 wfProfileOut( __METHOD__ );
106 return $s;
107 }
108
109 /**
110 * @return string
111 */
112 function quickBar() {
113 global $wgContLang;
114
115 wfProfileIn( __METHOD__ );
116
117 $action = $this->getSkin()->getRequest()->getText( 'action' );
118 $wpPreview = $this->getSkin()->getRequest()->getBool( 'wpPreview' );
119 $title = $this->getSkin()->getTitle();
120 $tns = $title->getNamespace();
121
122 $s = "\n<div id='quickbar'>";
123 $s .= "\n" . $this->getSkin()->logoText() . "\n<hr class='sep' />";
124
125 $sep = "\n<br />";
126
127 # Use the first heading from the Monobook sidebar as the "browse" section
128 $bar = $this->getSkin()->buildSidebar();
129 unset( $bar['SEARCH'] );
130 unset( $bar['LANGUAGES'] );
131 unset( $bar['TOOLBOX'] );
132
133 $barnumber = 1;
134 foreach ( $bar as $browseLinks ) {
135 if ( is_array( $browseLinks ) ) {
136 if ( $barnumber > 1 ) {
137 $s .= "\n<hr class='sep' />";
138 }
139 foreach ( $browseLinks as $link ) {
140 if ( $link['text'] != '-' ) {
141 $s .= "<a href=\"{$link['href']}\">" .
142 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
143 }
144 }
145 }
146 if ( $barnumber == 1 ) {
147 // only show watchlist link if logged in
148 if( $this->data['loggedin'] ) {
149 $s.= Linker::specialLink( 'Watchlist' ) ;
150 $s .= $sep . Linker::linkKnown(
151 SpecialPage::getTitleFor( 'Contributions' ),
152 wfMessage( 'mycontris' )->escaped(),
153 array(),
154 array( 'target' => $this->data['username'] )
155 );
156 }
157 }
158 $barnumber = $barnumber + 1;
159 }
160
161 $s .= "\n<hr class='sep' />";
162 $articleExists = $title->getArticleID();
163 if ( $this->data['isarticle'] || $action == 'edit' || $action == 'history' || $wpPreview ) {
164 if( $this->data['isarticle'] ) {
165 $s .= '<strong>' . $this->editThisPage() . '</strong>';
166 } else { # backlink to the article in edit or history mode
167 if( $articleExists ){ # no backlink if no article
168 switch( $tns ) {
169 case NS_TALK:
170 case NS_USER_TALK:
171 case NS_PROJECT_TALK:
172 case NS_FILE_TALK:
173 case NS_MEDIAWIKI_TALK:
174 case NS_TEMPLATE_TALK:
175 case NS_HELP_TALK:
176 case NS_CATEGORY_TALK:
177 $text = wfMessage('viewtalkpage');
178 break;
179 case NS_MAIN:
180 $text = wfMessage( 'articlepage' );
181 break;
182 case NS_USER:
183 $text = wfMessage( 'userpage' );
184 break;
185 case NS_PROJECT:
186 $text = wfMessage( 'projectpage' );
187 break;
188 case NS_FILE:
189 $text = wfMessage( 'imagepage' );
190 break;
191 case NS_MEDIAWIKI:
192 $text = wfMessage( 'mediawikipage' );
193 break;
194 case NS_TEMPLATE:
195 $text = wfMessage( 'templatepage' );
196 break;
197 case NS_HELP:
198 $text = wfMessage( 'viewhelppage' );
199 break;
200 case NS_CATEGORY:
201 $text = wfMessage( 'categorypage' );
202 break;
203 default:
204 $text = wfMessage( 'articlepage' );
205 }
206
207 $link = $title->getText();
208 $nstext = $wgContLang->getNsText( $tns );
209 if( $nstext ) { # add namespace if necessary
210 $link = $nstext . ':' . $link;
211 }
212
213 $s .= Linker::link( Title::newFromText( $link ), $text->escaped() );
214 } elseif( $title->getNamespace() != NS_SPECIAL ) {
215 # we just throw in a "New page" text to tell the user that he's in edit mode,
216 # and to avoid messing with the separator that is prepended to the next item
217 $s .= '<strong>' . wfMessage( 'newpage' )->escaped() . '</strong>';
218 }
219 }
220
221 # "Post a comment" link
222 if( ( $title->isTalkPage() || $this->getSkin()->getOutput()->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
223 $s .= '<br />' . Linker::link(
224 $title,
225 wfMessage( 'postcomment' )->escaped(),
226 array(),
227 array(
228 'action' => 'edit',
229 'section' => 'new'
230 )
231 );
232
233 /**
234 * Watching could cause problems in edit mode:
235 * if user edits article, then loads "watch this article" in background and then saves
236 * article with "Watch this article" checkbox disabled, the article is transparently
237 * unwatched. Therefore we do not show the "Watch this page" link in edit mode.
238 */
239 if ( $this->data['loggedin'] && $articleExists ) {
240 if( $action != 'edit' && $action != 'submit' ) {
241 $s .= $sep . $this->watchThisPage();
242 }
243 if ( $title->userCan( 'edit' ) )
244 $s .= $sep . $this->moveThisPage();
245 }
246 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) && $articleExists ) {
247 $s .= $sep . $this->deleteThisPage() .
248 $sep . $this->protectThisPage();
249 }
250 $s .= $sep . $this->talkLink();
251 if( $articleExists && $action != 'history' ) {
252 $s .= $sep . $this->historyLink();
253 }
254 $s .= $sep . $this->whatLinksHere();
255
256 if( $this->getSkin()->getOutput()->isArticleRelated() ) {
257 $s .= $sep . $this->watchPageLinksLink();
258 }
259
260 if (
261 NS_USER == $title->getNamespace() ||
262 $title->getNamespace() == NS_USER_TALK
263 ) {
264
265 $id = User::idFromName( $title->getText() );
266 $ip = User::isIP( $title->getText() );
267
268 if( $id || $ip ){
269 $s .= $sep . $this->userContribsLink();
270 }
271 if( $this->getSkin()->showEmailUser( $id ) ) {
272 $s .= $sep . $this->emailUserLink();
273 }
274 }
275 $s .= "\n<br /><hr class='sep' />";
276 }
277
278 if( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getSkin()->getUser() ) === true ) {
279 $s .= $this->getUploadLink() . $sep;
280 }
281
282 $s .= Linker::specialLink( 'Specialpages' );
283
284 global $wgSiteSupportPage;
285 if( $wgSiteSupportPage ) {
286 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
287 '" class="internal">' . wfMessage( 'sitesupport' )->escaped() . '</a>';
288 }
289
290 $s .= "\n<br /></div>\n";
291 wfProfileOut( __METHOD__ );
292 return $s;
293 }
294 }