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