New $wgGroupPermissions option 'move-subpages' added to control bulk-moving subpages...
[mediawiki.git] / skins / Standard.php
blob7d4eb9a41701fd3e861d5e97e8b08796c85061cf
1 <?php
2 /**
3 * See docs/skin.txt
5 * @todo document
6 * @file
7 * @ingroup Skins
8 */
10 if( !defined( 'MEDIAWIKI' ) )
11 die( -1 );
13 /**
14 * @todo document
15 * @ingroup Skins
17 class SkinStandard extends Skin {
19 /**
22 function getHeadScripts( $allowUserJs ) {
23 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
25 $s = parent::getHeadScripts( $allowUserJs );
26 if ( 3 == $this->qbSetting() ) { # Floating left
27 $s .= "<script language='javascript' type='$wgJsMimeType' " .
28 "src='{$wgStylePath}/common/sticky.js?$wgStyleVersion'></script>\n";
30 return $s;
33 /**
36 function getUserStyles() {
37 global $wgStylePath, $wgStyleVersion;
38 $s = '';
39 if ( 3 == $this->qbSetting() ) { # Floating left
40 $s .= "<style type='text/css'>\n" .
41 "@import '{$wgStylePath}/common/quickbar.css?$wgStyleVersion';\n</style>\n";
42 } else if ( 4 == $this->qbSetting() ) { # Floating right
43 $s .= "<style type='text/css'>\n" .
44 "@import '{$wgStylePath}/common/quickbar-right.css?$wgStyleVersion';\n</style>\n";
46 $s .= parent::getUserStyles();
47 return $s;
50 /**
53 function doGetUserStyles() {
54 global $wgStylePath;
56 $s = parent::doGetUserStyles();
57 $qb = $this->qbSetting();
59 if ( 2 == $qb ) { # Right
60 $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
61 "border-left: 2px solid #000000; }\n" .
62 "#article { margin-left: 4px; margin-right: 152px; }\n";
63 } else if ( 1 == $qb || 3 == $qb ) {
64 $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
65 "border-right: 1px solid gray; }\n" .
66 "#article { margin-left: 152px; margin-right: 4px; }\n";
67 } else if ( 4 == $qb) {
68 $s .= "#quickbar { border-right: 1px solid gray; }\n" .
69 "#article { margin-right: 152px; margin-left: 4px; }\n";
71 return $s;
74 /**
77 function getBodyOptions() {
78 $a = parent::getBodyOptions();
80 if ( 3 == $this->qbSetting() ) { # Floating left
81 $qb = "setup(\"quickbar\")";
82 if($a["onload"]) {
83 $a["onload"] .= ";$qb";
84 } else {
85 $a["onload"] = $qb;
88 return $a;
91 function doAfterContent() {
92 global $wgContLang;
93 $fname = 'SkinStandard::doAfterContent';
94 wfProfileIn( $fname );
95 wfProfileIn( $fname.'-1' );
97 $s = "\n</div><br style=\"clear:both\" />\n";
98 $s .= "\n<div id='footer'>";
99 $s .= '<table border="0" cellspacing="0"><tr>';
101 wfProfileOut( $fname.'-1' );
102 wfProfileIn( $fname.'-2' );
104 $qb = $this->qbSetting();
105 $shove = ($qb != 0);
106 $left = ($qb == 1 || $qb == 3);
107 if($wgContLang->isRTL()) $left = !$left;
109 if ( $shove && $left ) { # Left
110 $s .= $this->getQuickbarCompensator();
112 wfProfileOut( $fname.'-2' );
113 wfProfileIn( $fname.'-3' );
114 $l = $wgContLang->isRTL() ? 'right' : 'left';
115 $s .= "<td class='bottom' align='$l' valign='top'>";
117 $s .= $this->bottomLinks();
118 $s .= "\n<br />" . $this->mainPageLink()
119 . ' | ' . $this->aboutLink()
120 . ' | ' . $this->specialLink( 'recentchanges' )
121 . ' | ' . $this->searchForm()
122 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
124 $s .= "</td>";
125 if ( $shove && !$left ) { # Right
126 $s .= $this->getQuickbarCompensator();
128 $s .= "</tr></table>\n</div>\n</div>\n";
130 wfProfileOut( $fname.'-3' );
131 wfProfileIn( $fname.'-4' );
132 if ( 0 != $qb ) { $s .= $this->quickBar(); }
133 wfProfileOut( $fname.'-4' );
134 wfProfileOut( $fname );
135 return $s;
138 function quickBar() {
139 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
140 global $wgEnableUploads, $wgRemoteUploads;
142 $fname = 'Skin::quickBar';
143 wfProfileIn( $fname );
145 $action = $wgRequest->getText( 'action' );
146 $wpPreview = $wgRequest->getBool( 'wpPreview' );
147 $tns=$wgTitle->getNamespace();
149 $s = "\n<div id='quickbar'>";
150 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
152 $sep = "\n<br />";
154 # Use the first heading from the Monobook sidebar as the "browse" section
155 $bar = $this->buildSidebar();
156 $browseLinks = reset( $bar );
158 foreach ( $browseLinks as $link ) {
159 if ( $link['text'] != '-' ) {
160 $s .= "<a href=\"{$link['href']}\">" .
161 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
165 if( $wgUser->isLoggedIn() ) {
166 $s.= $this->specialLink( 'watchlist' ) ;
167 $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
168 wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
170 // only show watchlist link if logged in
171 $s .= "\n<hr class='sep' />";
172 $articleExists = $wgTitle->getArticleId();
173 if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
174 if($wgOut->isArticle()) {
175 $s .= '<strong>' . $this->editThisPage() . '</strong>';
176 } else { # backlink to the article in edit or history mode
177 if($articleExists){ # no backlink if no article
178 switch($tns) {
179 case NS_TALK:
180 case NS_USER_TALK:
181 case NS_PROJECT_TALK:
182 case NS_IMAGE_TALK:
183 case NS_MEDIAWIKI_TALK:
184 case NS_TEMPLATE_TALK:
185 case NS_HELP_TALK:
186 case NS_CATEGORY_TALK:
187 $text = wfMsg('viewtalkpage');
188 break;
189 case NS_MAIN:
190 $text = wfMsg( 'articlepage' );
191 break;
192 case NS_USER:
193 $text = wfMsg( 'userpage' );
194 break;
195 case NS_PROJECT:
196 $text = wfMsg( 'projectpage' );
197 break;
198 case NS_IMAGE:
199 $text = wfMsg( 'imagepage' );
200 break;
201 case NS_MEDIAWIKI:
202 $text = wfMsg( 'mediawikipage' );
203 break;
204 case NS_TEMPLATE:
205 $text = wfMsg( 'templatepage' );
206 break;
207 case NS_HELP:
208 $text = wfMsg( 'viewhelppage' );
209 break;
210 case NS_CATEGORY:
211 $text = wfMsg( 'categorypage' );
212 break;
213 default:
214 $text= wfMsg( 'articlepage' );
217 $link = $wgTitle->getText();
218 if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
219 $link = $nstext . ':' . $link ;
222 $s .= $this->makeLink( $link, $text );
223 } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) {
224 # we just throw in a "New page" text to tell the user that he's in edit mode,
225 # and to avoid messing with the separator that is prepended to the next item
226 $s .= '<strong>' . wfMsg('newpage') . '</strong>';
231 # "Post a comment" link
232 if( ( $wgTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
233 $s .= '<br />' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit&section=new' );
235 #if( $tns%2 && $action!='edit' && !$wpPreview) {
236 #$s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit&section=new');
240 watching could cause problems in edit mode:
241 if user edits article, then loads "watch this article" in background and then saves
242 article with "Watch this article" checkbox disabled, the article is transparently
243 unwatched. Therefore we do not show the "Watch this page" link in edit mode
245 if ( $wgUser->isLoggedIn() && $articleExists) {
246 if($action!='edit' && $action != 'submit' )
248 $s .= $sep . $this->watchThisPage();
250 if ( $wgTitle->userCan( 'edit' ) )
251 $s .= $sep . $this->moveThisPage();
253 if ( $wgUser->isAllowed('delete') and $articleExists ) {
254 $s .= $sep . $this->deleteThisPage() .
255 $sep . $this->protectThisPage();
257 $s .= $sep . $this->talkLink();
258 if ($articleExists && $action !='history') {
259 $s .= $sep . $this->historyLink();
261 $s.=$sep . $this->whatLinksHere();
263 if($wgOut->isArticleRelated()) {
264 $s .= $sep . $this->watchPageLinksLink();
267 if ( NS_USER == $wgTitle->getNamespace()
268 || $wgTitle->getNamespace() == NS_USER_TALK ) {
270 $id=User::idFromName($wgTitle->getText());
271 $ip=User::isIP($wgTitle->getText());
273 if($id||$ip) {
274 $s .= $sep . $this->userContribsLink();
276 if( $this->showEmailUser( $id ) ) {
277 $s .= $sep . $this->emailUserLink();
280 $s .= "\n<br /><hr class='sep' />";
283 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
284 $s .= $this->specialLink( 'upload' ) . $sep;
286 $s .= $this->specialLink( 'specialpages' )
287 . $sep . $this->bugReportsLink();
289 global $wgSiteSupportPage;
290 if( $wgSiteSupportPage ) {
291 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
292 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
295 $s .= "\n<br /></div>\n";
296 wfProfileOut( $fname );
297 return $s;