Fixes to OutputPage's documentation
[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 * @todo document
14 * @ingroup Skins
15 */
16 class SkinStandard extends Skin {
17 /*
18 * OutputPage
19 */
20 function outputPage( OutputPage $out ) {
21 global $wgStylePath;
22 parent::outputPage( $out );
23 }
24
25 /**
26 *
27 */
28 function setupSkinUserCss( OutputPage $out ){
29 if ( 3 == $this->qbSetting() ) { # Floating left
30 $out->addStyle( 'common/quickbar.css' );
31 } else if ( 4 == $this->qbSetting() ) { # Floating right
32 $out->addStyle( 'common/quickbar-right.css' );
33 }
34 parent::setupSkinUserCss( $out );
35 }
36
37 /**
38 *
39 */
40 function reallyGenerateUserStylesheet() {
41 $s = parent::reallyGenerateUserStylesheet();
42 $qb = $this->qbSetting();
43
44 if ( 2 == $qb ) { # Right
45 $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
46 "border-left: 2px solid #000000; }\n" .
47 "#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }\n";
48 } else if ( 1 == $qb || 3 == $qb ) {
49 $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
50 "border-right: 1px solid gray; }\n" .
51 "#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }\n";
52 } else if ( 4 == $qb) {
53 $s .= "#quickbar { border-right: 1px solid gray; }\n" .
54 "#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }\n";
55 }
56 return $s;
57 }
58
59 function doAfterContent() {
60 global $wgContLang, $wgLang;
61 wfProfileIn( __METHOD__ );
62 wfProfileIn( __METHOD__ . '-1' );
63
64 $s = "\n</div><br style=\"clear:both\" />\n";
65 $s .= "\n<div id='footer'>";
66 $s .= '<table border="0" cellspacing="0"><tr>';
67
68 wfProfileOut( __METHOD__ . '-1' );
69 wfProfileIn( __METHOD__ . '-2' );
70
71 $qb = $this->qbSetting();
72 $shove = ( $qb != 0 );
73 $left = ( $qb == 1 || $qb == 3 );
74 if( $wgContLang->isRTL() ) $left = !$left;
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->mainPageLink(),
87 $this->aboutLink(),
88 $this->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 function quickBar() {
109 global $wgOut, $wgUser, $wgRequest, $wgContLang;
110 global $wgEnableUploads, $wgRemoteUploads;
111
112 wfProfileIn( __METHOD__ );
113
114 $action = $wgRequest->getText( 'action' );
115 $wpPreview = $wgRequest->getBool( 'wpPreview' );
116 $tns = $this->mTitle->getNamespace();
117
118 $s = "\n<div id='quickbar'>";
119 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
120
121 $sep = "\n<br />";
122
123 # Use the first heading from the Monobook sidebar as the "browse" section
124 $bar = $this->buildSidebar();
125 unset( $bar['SEARCH'] );
126 unset( $bar['LANGUAGES'] );
127 unset( $bar['TOOLBOX'] );
128 $browseLinks = reset( $bar );
129
130 foreach ( $browseLinks as $link ) {
131 if ( $link['text'] != '-' ) {
132 $s .= "<a href=\"{$link['href']}\">" .
133 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
134 }
135 }
136
137 if( $wgUser->isLoggedIn() ) {
138 $s.= $this->specialLink( 'watchlist' ) ;
139 $s .= $sep . $this->linkKnown(
140 SpecialPage::getTitleFor( 'Contributions' ),
141 wfMsg( 'mycontris' ),
142 array(),
143 array( 'target' => $wgUser->getName() )
144 );
145 }
146 // only show watchlist link if logged in
147 $s .= "\n<hr class='sep' />";
148 $articleExists = $this->mTitle->getArticleId();
149 if ( $wgOut->isArticle() || $action == 'edit' || $action == 'history' || $wpPreview ) {
150 if( $wgOut->isArticle() ) {
151 $s .= '<strong>' . $this->editThisPage() . '</strong>';
152 } else { # backlink to the article in edit or history mode
153 if( $articleExists ){ # no backlink if no article
154 switch( $tns ) {
155 case NS_TALK:
156 case NS_USER_TALK:
157 case NS_PROJECT_TALK:
158 case NS_FILE_TALK:
159 case NS_MEDIAWIKI_TALK:
160 case NS_TEMPLATE_TALK:
161 case NS_HELP_TALK:
162 case NS_CATEGORY_TALK:
163 $text = wfMsg('viewtalkpage');
164 break;
165 case NS_MAIN:
166 $text = wfMsg( 'articlepage' );
167 break;
168 case NS_USER:
169 $text = wfMsg( 'userpage' );
170 break;
171 case NS_PROJECT:
172 $text = wfMsg( 'projectpage' );
173 break;
174 case NS_FILE:
175 $text = wfMsg( 'imagepage' );
176 break;
177 case NS_MEDIAWIKI:
178 $text = wfMsg( 'mediawikipage' );
179 break;
180 case NS_TEMPLATE:
181 $text = wfMsg( 'templatepage' );
182 break;
183 case NS_HELP:
184 $text = wfMsg( 'viewhelppage' );
185 break;
186 case NS_CATEGORY:
187 $text = wfMsg( 'categorypage' );
188 break;
189 default:
190 $text = wfMsg( 'articlepage' );
191 }
192
193 $link = $this->mTitle->getText();
194 if( $nstext = $wgContLang->getNsText( $tns ) ) { # add namespace if necessary
195 $link = $nstext . ':' . $link;
196 }
197
198 $s .= $this->link(
199 Title::newFromText( $link ),
200 $text
201 );
202 } elseif( $this->mTitle->getNamespace() != NS_SPECIAL ) {
203 # we just throw in a "New page" text to tell the user that he's in edit mode,
204 # and to avoid messing with the separator that is prepended to the next item
205 $s .= '<strong>' . wfMsg( 'newpage' ) . '</strong>';
206 }
207 }
208
209 # "Post a comment" link
210 if( ( $this->mTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
211 $s .= '<br />' . $this->link(
212 $this->mTitle,
213 wfMsg( 'postcomment' ),
214 array(),
215 array(
216 'action' => 'edit',
217 'section' => 'new'
218 ),
219 array( 'known', 'noclasses' )
220 );
221
222 #if( $tns%2 && $action!='edit' && !$wpPreview) {
223 #$s.= '<br />'.$this->linkKnown( Title::newFromText( $wgTitle->getPrefixedText() ),wfMsg('postcomment'),array(),array('action'=>'edit','section'=>'new'));
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 ( $this->mTitle->userCan( 'edit' ) )
237 $s .= $sep . $this->moveThisPage();
238 }
239 if ( $wgUser->isAllowed( 'delete' ) and $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 ( NS_USER == $this->mTitle->getNamespace()
254 || $this->mTitle->getNamespace() == NS_USER_TALK ) {
255
256 $id = User::idFromName( $this->mTitle->getText() );
257 $ip = User::isIP( $this->mTitle->getText() );
258
259 if( $id || $ip ){
260 $s .= $sep . $this->userContribsLink();
261 }
262 if( $this->showEmailUser( $id ) ) {
263 $s .= $sep . $this->emailUserLink();
264 }
265 }
266 $s .= "\n<br /><hr class='sep' />";
267 }
268
269 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
270 $s .= $this->specialLink( 'upload' ) . $sep;
271 }
272 $s .= $this->specialLink( 'specialpages' );
273
274 global $wgSiteSupportPage;
275 if( $wgSiteSupportPage ) {
276 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
277 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
278 }
279
280 $s .= "\n<br /></div>\n";
281 wfProfileOut( __METHOD__ );
282 return $s;
283 }
284
285 }