* FiveUpgrade: large table hacks, install iw_trans update before links
[mediawiki.git] / skins / Standard.php
blob257f65de1d37f156c9f6f6a2c1889649f1d8eff6
1 <?php
2 /**
3 * See skin.txt
5 * @todo document
6 * @package MediaWiki
7 * @subpackage Skins
8 */
10 if( !defined( 'MEDIAWIKI' ) )
11 die();
13 /**
14 * @todo document
15 * @package MediaWiki
16 * @subpackage Skins
18 class SkinStandard extends Skin {
20 /**
23 function getHeadScripts() {
24 global $wgStylePath, $wgJsMimeType;
26 $s = parent::getHeadScripts();
27 if ( 3 == $this->qbSetting() ) { # Floating left
28 $s .= "<script language='javascript' type='$wgJsMimeType' " .
29 "src='{$wgStylePath}/common/sticky.js'></script>\n";
31 return $s;
34 /**
37 function getUserStyles() {
38 global $wgStylePath;
39 $s = '';
40 if ( 3 == $this->qbSetting() ) { # Floating left
41 $s .= "<style type='text/css'>\n" .
42 "@import '{$wgStylePath}/common/quickbar.css';\n</style>\n";
44 $s .= parent::getUserStyles();
45 return $s;
48 /**
51 function doGetUserStyles() {
52 global $wgUser, $wgOut, $wgStylePath;
54 $s = parent::doGetUserStyles();
55 $qb = $this->qbSetting();
57 if ( 2 == $qb ) { # Right
58 $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
59 "border-left: 2px solid #000000; }\n" .
60 "#article { margin-left: 4px; margin-right: 152px; }\n";
61 } else if ( 1 == $qb || 3 == $qb ) {
62 $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
63 "border-right: 1px solid gray; }\n" .
64 "#article { margin-left: 152px; margin-right: 4px; }\n";
66 return $s;
69 /**
72 function getBodyOptions() {
73 $a = parent::getBodyOptions();
75 if ( 3 == $this->qbSetting() ) { # Floating left
76 $qb = "setup(\"quickbar\")";
77 if($a["onload"]) {
78 $a["onload"] .= ";$qb";
79 } else {
80 $a["onload"] = $qb;
83 return $a;
86 function doAfterContent() {
87 global $wgUser, $wgOut, $wgContLang;
88 $fname = 'SkinStandard::doAfterContent';
89 wfProfileIn( $fname );
90 wfProfileIn( $fname.'-1' );
92 $s = "\n</div><br style=\"clear:both\" />\n";
93 $s .= "\n<div id='footer'>";
94 $s .= '<table border="0" cellspacing="0"><tr>';
96 wfProfileOut( $fname.'-1' );
97 wfProfileIn( $fname.'-2' );
99 $qb = $this->qbSetting();
100 $shove = ($qb != 0);
101 $left = ($qb == 1 || $qb == 3);
102 if($wgContLang->isRTL()) $left = !$left;
104 if ( $shove && $left ) { # Left
105 $s .= $this->getQuickbarCompensator();
107 wfProfileOut( $fname.'-2' );
108 wfProfileIn( $fname.'-3' );
109 $l = $wgContLang->isRTL() ? 'right' : 'left';
110 $s .= "<td class='bottom' align='$l' valign='top'>";
112 $s .= $this->bottomLinks();
113 $s .= "\n<br />" . $this->mainPageLink()
114 . ' | ' . $this->aboutLink()
115 . ' | ' . $this->specialLink( 'recentchanges' )
116 . ' | ' . $this->searchForm()
117 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
119 $s .= "</td>";
120 if ( $shove && !$left ) { # Right
121 $s .= $this->getQuickbarCompensator();
123 $s .= "</tr></table>\n</div>\n</div>\n";
125 wfProfileOut( $fname.'-3' );
126 wfProfileIn( $fname.'-4' );
127 if ( 0 != $qb ) { $s .= $this->quickBar(); }
128 wfProfileOut( $fname.'-4' );
129 wfProfileOut( $fname );
130 return $s;
133 function quickBar() {
134 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
135 global $wgEnableUploads, $wgRemoteUploads;
137 $fname = 'Skin::quickBar';
138 wfProfileIn( $fname );
140 $action = $wgRequest->getText( 'action' );
141 $wpPreview = $wgRequest->getBool( 'wpPreview' );
142 $tns=$wgTitle->getNamespace();
144 $s = "\n<div id='quickbar'>";
145 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
147 $sep = "\n<br />";
149 # Use the first heading from the Monobook sidebar as the "browse" section
150 $bar = $this->buildSidebar();
151 $browseLinks = reset( $bar );
153 foreach ( $browseLinks as $link ) {
154 if ( $link['text'] != '-' ) {
155 $s .= "<a href=\"{$link['href']}\">" .
156 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
160 if( $wgUser->isLoggedIn() ) {
161 $s.= $this->specialLink( 'watchlist' ) ;
162 $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
163 wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
165 // only show watchlist link if logged in
166 $s .= "\n<hr class='sep' />";
167 $articleExists = $wgTitle->getArticleId();
168 if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
169 if($wgOut->isArticle()) {
170 $s .= '<strong>' . $this->editThisPage() . '</strong>';
171 } else { # backlink to the article in edit or history mode
172 if($articleExists){ # no backlink if no article
173 switch($tns) {
174 case 0:
175 $text = wfMsg('articlepage');
176 break;
177 case 1:
178 $text = wfMsg('viewtalkpage');
179 break;
180 case 2:
181 $text = wfMsg('userpage');
182 break;
183 case 3:
184 $text = wfMsg('viewtalkpage');
185 break;
186 case 4:
187 $text = wfMsg('wikipediapage');
188 break;
189 case 5:
190 $text = wfMsg('viewtalkpage');
191 break;
192 case 6:
193 $text = wfMsg('imagepage');
194 break;
195 case 7:
196 $text = wfMsg('viewtalkpage');
197 break;
198 default:
199 $text= wfMsg('articlepage');
202 $link = $wgTitle->getText();
203 if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
204 $link = $nstext . ':' . $link ;
207 $s .= $this->makeLink( $link, $text );
208 } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) {
209 # we just throw in a "New page" text to tell the user that he's in edit mode,
210 # and to avoid messing with the separator that is prepended to the next item
211 $s .= '<strong>' . wfMsg('newpage') . '</strong>';
217 if( $tns%2 && $action!='edit' && !$wpPreview) {
218 $s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit&section=new');
222 watching could cause problems in edit mode:
223 if user edits article, then loads "watch this article" in background and then saves
224 article with "Watch this article" checkbox disabled, the article is transparently
225 unwatched. Therefore we do not show the "Watch this page" link in edit mode
227 if ( $wgUser->isLoggedIn() && $articleExists) {
228 if($action!='edit' && $action != 'submit' )
230 $s .= $sep . $this->watchThisPage();
232 if ( $wgTitle->userCanEdit() )
233 $s .= $sep . $this->moveThisPage();
235 if ( $wgUser->isAllowed('delete') and $articleExists ) {
236 $s .= $sep . $this->deleteThisPage() .
237 $sep . $this->protectThisPage();
239 $s .= $sep . $this->talkLink();
240 if ($articleExists && $action !='history') {
241 $s .= $sep . $this->historyLink();
243 $s.=$sep . $this->whatLinksHere();
245 if($wgOut->isArticleRelated()) {
246 $s .= $sep . $this->watchPageLinksLink();
249 if ( NS_USER == $wgTitle->getNamespace()
250 || $wgTitle->getNamespace() == NS_USER_TALK ) {
252 $id=User::idFromName($wgTitle->getText());
253 $ip=User::isIP($wgTitle->getText());
255 if($id||$ip) {
256 $s .= $sep . $this->userContribsLink();
258 if( $this->showEmailUser( $id ) ) {
259 $s .= $sep . $this->emailUserLink();
262 $s .= "\n<br /><hr class='sep' />";
265 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
266 $s .= $this->specialLink( 'upload' ) . $sep;
268 $s .= $this->specialLink( 'specialpages' )
269 . $sep . $this->bugReportsLink();
271 global $wgSiteSupportPage;
272 if( $wgSiteSupportPage ) {
273 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
274 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
277 $s .= "\n<br /></div>\n";
278 wfProfileOut( $fname );
279 return $s;