Revert old page navigation back to a subtitle
[mediawiki.git] / skins / Standard.php
blobff1e9337bd581b2e1a32b7a1816c8c80b79c20cb
1 <?php
2 /**
3 * Standard (a.k.a. Classic) skin: old MediaWiki default skin
5 * @file
6 * @ingroup Skins
7 */
9 if( !defined( 'MEDIAWIKI' ) ) {
10 die( -1 );
13 /**
14 * @todo document
15 * @ingroup Skins
17 class SkinStandard extends SkinLegacy {
18 var $skinname = 'standard', $stylename = 'standard',
19 $template = 'StandardTemplate';
21 /**
22 * @param $out OutputPage
24 function setupSkinUserCss( OutputPage $out ){
25 parent::setupSkinUserCss( $out );
26 $out->AddModuleStyles( 'skins.standard' );
28 global $wgContLang;
29 $qb = $this->qbSetting();
30 $rules = array();
32 if ( 2 == $qb ) { # Right
33 $rules[] = "#quickbar { position: absolute; top: 4px; right: 4px; border-left: 2px solid #000000; }";
34 $rules[] = "#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }";
35 } elseif ( 1 == $qb || 3 == $qb ) {
36 $rules[] = "#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }";
37 $rules[] = "#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }";
38 if( 3 == $qb ) {
39 $rules[] = "#quickbar { position: fixed; padding: 4px; }";
41 } elseif ( 4 == $qb ) {
42 $rules[] = "#quickbar { position: fixed; right: 0px; top: 0px; padding: 4px;}";
43 $rules[] = "#quickbar { border-right: 1px solid gray; }";
44 $rules[] = "#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }";
46 $style = implode( "\n", $rules );
47 if ( $wgContLang->getDir() === 'rtl' ) {
48 $style = CSSJanus::transform( $style, true, false );
50 $out->addInlineStyle( $style );
55 class StandardTemplate extends LegacyTemplate {
57 /**
58 * @return string
60 function doAfterContent() {
61 global $wgContLang, $wgLang;
62 wfProfileIn( __METHOD__ );
63 wfProfileIn( __METHOD__ . '-1' );
65 $s = "\n</div><br style=\"clear:both\" />\n";
66 $s .= "\n<div id='footer'>";
67 $s .= '<table border="0" cellspacing="0"><tr>';
69 wfProfileOut( __METHOD__ . '-1' );
70 wfProfileIn( __METHOD__ . '-2' );
72 $qb = $this->getSkin()->qbSetting();
73 $shove = ( $qb != 0 );
74 $left = ( $qb == 1 || $qb == 3 );
76 if ( $shove && $left ) { # Left
77 $s .= $this->getQuickbarCompensator();
79 wfProfileOut( __METHOD__ . '-2' );
80 wfProfileIn( __METHOD__ . '-3' );
81 $l = $wgContLang->alignStart();
82 $s .= "<td class='bottom' align='$l' valign='top'>";
84 $s .= $this->bottomLinks();
85 $s .= "\n<br />" . $wgLang->pipeList( array(
86 $this->getSkin()->mainPageLink(),
87 $this->getSkin()->aboutLink(),
88 Linker::specialLink( 'Recentchanges' ),
89 $this->searchForm() ) )
90 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
92 $s .= '</td>';
93 if ( $shove && !$left ) { # Right
94 $s .= $this->getQuickbarCompensator();
96 $s .= "</tr></table>\n</div>\n</div>\n";
98 wfProfileOut( __METHOD__ . '-3' );
99 wfProfileIn( __METHOD__ . '-4' );
100 if ( 0 != $qb ) {
101 $s .= $this->quickBar();
103 wfProfileOut( __METHOD__ . '-4' );
104 wfProfileOut( __METHOD__ );
105 return $s;
109 * @return string
111 function quickBar() {
112 global $wgOut, $wgUser, $wgRequest, $wgContLang;
114 wfProfileIn( __METHOD__ );
116 $action = $wgRequest->getText( 'action' );
117 $wpPreview = $wgRequest->getBool( 'wpPreview' );
118 $tns = $this->getSkin()->getTitle()->getNamespace();
120 $s = "\n<div id='quickbar'>";
121 $s .= "\n" . $this->getSkin()->logoText() . "\n<hr class='sep' />";
123 $sep = "\n<br />";
125 # Use the first heading from the Monobook sidebar as the "browse" section
126 $bar = $this->getSkin()->buildSidebar();
127 unset( $bar['SEARCH'] );
128 unset( $bar['LANGUAGES'] );
129 unset( $bar['TOOLBOX'] );
131 $barnumber = 1;
132 foreach ( $bar as $browseLinks ) {
133 if ( $barnumber > 1 ) {
134 $s .= "\n<hr class='sep' />";
136 foreach ( $browseLinks as $link ) {
137 if ( $link['text'] != '-' ) {
138 $s .= "<a href=\"{$link['href']}\">" .
139 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
142 if ( $barnumber == 1 ) {
143 // only show watchlist link if logged in
144 if( $wgUser->isLoggedIn() ) {
145 $s.= Linker::specialLink( 'Watchlist' ) ;
146 $s .= $sep . Linker::linkKnown(
147 SpecialPage::getTitleFor( 'Contributions' ),
148 wfMsg( 'mycontris' ),
149 array(),
150 array( 'target' => $wgUser->getName() )
154 $barnumber = $barnumber + 1;
157 $s .= "\n<hr class='sep' />";
158 $articleExists = $this->getSkin()->getTitle()->getArticleId();
159 if ( $wgOut->isArticle() || $action == 'edit' || $action == 'history' || $wpPreview ) {
160 if( $wgOut->isArticle() ) {
161 $s .= '<strong>' . $this->editThisPage() . '</strong>';
162 } else { # backlink to the article in edit or history mode
163 if( $articleExists ){ # no backlink if no article
164 switch( $tns ) {
165 case NS_TALK:
166 case NS_USER_TALK:
167 case NS_PROJECT_TALK:
168 case NS_FILE_TALK:
169 case NS_MEDIAWIKI_TALK:
170 case NS_TEMPLATE_TALK:
171 case NS_HELP_TALK:
172 case NS_CATEGORY_TALK:
173 $text = wfMsg('viewtalkpage');
174 break;
175 case NS_MAIN:
176 $text = wfMsg( 'articlepage' );
177 break;
178 case NS_USER:
179 $text = wfMsg( 'userpage' );
180 break;
181 case NS_PROJECT:
182 $text = wfMsg( 'projectpage' );
183 break;
184 case NS_FILE:
185 $text = wfMsg( 'imagepage' );
186 break;
187 case NS_MEDIAWIKI:
188 $text = wfMsg( 'mediawikipage' );
189 break;
190 case NS_TEMPLATE:
191 $text = wfMsg( 'templatepage' );
192 break;
193 case NS_HELP:
194 $text = wfMsg( 'viewhelppage' );
195 break;
196 case NS_CATEGORY:
197 $text = wfMsg( 'categorypage' );
198 break;
199 default:
200 $text = wfMsg( 'articlepage' );
203 $link = $this->getSkin()->getTitle()->getText();
204 $nstext = $wgContLang->getNsText( $tns );
205 if( $nstext ) { # add namespace if necessary
206 $link = $nstext . ':' . $link;
209 $s .= Linker::link( Title::newFromText( $link ), $text );
210 } elseif( $this->getSkin()->getTitle()->getNamespace() != NS_SPECIAL ) {
211 # we just throw in a "New page" text to tell the user that he's in edit mode,
212 # and to avoid messing with the separator that is prepended to the next item
213 $s .= '<strong>' . wfMsg( 'newpage' ) . '</strong>';
217 # "Post a comment" link
218 if( ( $this->getSkin()->getTitle()->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
219 $s .= '<br />' . $this->getSkin()->link(
220 $this->getSkin()->getTitle(),
221 wfMsg( 'postcomment' ),
222 array(),
223 array(
224 'action' => 'edit',
225 'section' => 'new'
227 array( 'known', 'noclasses' )
231 watching could cause problems in edit mode:
232 if user edits article, then loads "watch this article" in background and then saves
233 article with "Watch this article" checkbox disabled, the article is transparently
234 unwatched. Therefore we do not show the "Watch this page" link in edit mode
236 if ( $wgUser->isLoggedIn() && $articleExists ) {
237 if( $action != 'edit' && $action != 'submit' ) {
238 $s .= $sep . $this->watchThisPage();
240 if ( $this->getSkin()->getTitle()->userCan( 'edit' ) )
241 $s .= $sep . $this->moveThisPage();
243 if ( $wgUser->isAllowed( 'delete' ) && $articleExists ) {
244 $s .= $sep . $this->deleteThisPage() .
245 $sep . $this->protectThisPage();
247 $s .= $sep . $this->talkLink();
248 if( $articleExists && $action != 'history' ) {
249 $s .= $sep . $this->historyLink();
251 $s .= $sep . $this->whatLinksHere();
253 if( $wgOut->isArticleRelated() ) {
254 $s .= $sep . $this->watchPageLinksLink();
257 if (
258 NS_USER == $this->getSkin()->getTitle()->getNamespace() ||
259 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
262 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
263 $ip = User::isIP( $this->getSkin()->getTitle()->getText() );
265 if( $id || $ip ){
266 $s .= $sep . $this->userContribsLink();
268 if( $this->getSkin()->showEmailUser( $id ) ) {
269 $s .= $sep . $this->emailUserLink();
272 $s .= "\n<br /><hr class='sep' />";
275 if( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
276 $s .= $this->getUploadLink() . $sep;
279 $s .= Linker::specialLink( 'Specialpages' );
281 global $wgSiteSupportPage;
282 if( $wgSiteSupportPage ) {
283 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
284 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
287 $s .= "\n<br /></div>\n";
288 wfProfileOut( __METHOD__ );
289 return $s;