r92054: Some IE fixes
[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 $tns = $this->getSkin()->getTitle()->getNamespace();
115
116 $s = "\n<div id='quickbar'>";
117 $s .= "\n" . $this->getSkin()->logoText() . "\n<hr class='sep' />";
118
119 $sep = "\n<br />";
120
121 # Use the first heading from the Monobook sidebar as the "browse" section
122 $bar = $this->getSkin()->buildSidebar();
123 unset( $bar['SEARCH'] );
124 unset( $bar['LANGUAGES'] );
125 unset( $bar['TOOLBOX'] );
126
127 $barnumber = 1;
128 foreach ( $bar as $browseLinks ) {
129 if ( $barnumber > 1 ) {
130 $s .= "\n<hr class='sep' />";
131 }
132 foreach ( $browseLinks as $link ) {
133 if ( $link['text'] != '-' ) {
134 $s .= "<a href=\"{$link['href']}\">" .
135 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
136 }
137 }
138 if ( $barnumber == 1 ) {
139 // only show watchlist link if logged in
140 if( $wgUser->isLoggedIn() ) {
141 $s.= Linker::specialLink( 'Watchlist' ) ;
142 $s .= $sep . Linker::linkKnown(
143 SpecialPage::getTitleFor( 'Contributions' ),
144 wfMsg( 'mycontris' ),
145 array(),
146 array( 'target' => $wgUser->getName() )
147 );
148 }
149 }
150 $barnumber = $barnumber + 1;
151 }
152
153 $s .= "\n<hr class='sep' />";
154 $articleExists = $this->getSkin()->getTitle()->getArticleId();
155 if ( $wgOut->isArticle() || $action == 'edit' || $action == 'history' || $wpPreview ) {
156 if( $wgOut->isArticle() ) {
157 $s .= '<strong>' . $this->editThisPage() . '</strong>';
158 } else { # backlink to the article in edit or history mode
159 if( $articleExists ){ # no backlink if no article
160 switch( $tns ) {
161 case NS_TALK:
162 case NS_USER_TALK:
163 case NS_PROJECT_TALK:
164 case NS_FILE_TALK:
165 case NS_MEDIAWIKI_TALK:
166 case NS_TEMPLATE_TALK:
167 case NS_HELP_TALK:
168 case NS_CATEGORY_TALK:
169 $text = wfMsg('viewtalkpage');
170 break;
171 case NS_MAIN:
172 $text = wfMsg( 'articlepage' );
173 break;
174 case NS_USER:
175 $text = wfMsg( 'userpage' );
176 break;
177 case NS_PROJECT:
178 $text = wfMsg( 'projectpage' );
179 break;
180 case NS_FILE:
181 $text = wfMsg( 'imagepage' );
182 break;
183 case NS_MEDIAWIKI:
184 $text = wfMsg( 'mediawikipage' );
185 break;
186 case NS_TEMPLATE:
187 $text = wfMsg( 'templatepage' );
188 break;
189 case NS_HELP:
190 $text = wfMsg( 'viewhelppage' );
191 break;
192 case NS_CATEGORY:
193 $text = wfMsg( 'categorypage' );
194 break;
195 default:
196 $text = wfMsg( 'articlepage' );
197 }
198
199 $link = $this->getSkin()->getTitle()->getText();
200 $nstext = $wgContLang->getNsText( $tns );
201 if( $nstext ) { # add namespace if necessary
202 $link = $nstext . ':' . $link;
203 }
204
205 $s .= Linker::link( Title::newFromText( $link ), $text );
206 } elseif( $this->getSkin()->getTitle()->getNamespace() != NS_SPECIAL ) {
207 # we just throw in a "New page" text to tell the user that he's in edit mode,
208 # and to avoid messing with the separator that is prepended to the next item
209 $s .= '<strong>' . wfMsg( 'newpage' ) . '</strong>';
210 }
211 }
212
213 # "Post a comment" link
214 if( ( $this->getSkin()->getTitle()->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
215 $s .= '<br />' . $this->getSkin()->link(
216 $this->getSkin()->getTitle(),
217 wfMsg( 'postcomment' ),
218 array(),
219 array(
220 'action' => 'edit',
221 'section' => 'new'
222 ),
223 array( 'known', 'noclasses' )
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->getSkin()->getTitle()->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 == $this->getSkin()->getTitle()->getNamespace() ||
255 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
256 ) {
257
258 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
259 $ip = User::isIP( $this->getSkin()->getTitle()->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 }