(bug 23816) Add tracking category for any page with a broken image.
[mediawiki.git] / skins / Standard.php
blobbb540ae1870f2c60bcd62b0f0a6b2c053971cca3
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 function setupSkinUserCss( OutputPage $out ){
22 parent::setupSkinUserCss( $out );
23 $out->AddModuleStyles( 'skins.standard' );
25 global $wgContLang;
26 $qb = $this->qbSetting();
27 $rules = array();
29 if ( 2 == $qb ) { # Right
30 $rules[] = "#quickbar { position: absolute; top: 4px; right: 4px; border-left: 2px solid #000000; }";
31 $rules[] = "#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }";
32 } elseif ( 1 == $qb || 3 == $qb ) {
33 $rules[] = "#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }";
34 $rules[] = "#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }";
35 if( 3 == $qb ) {
36 $rules[] = "#quickbar { position: fixed; padding: 4px; }";
38 } elseif ( 4 == $qb ) {
39 $rules[] = "#quickbar { position: fixed; right: 0px; top: 0px; padding: 4px;}";
40 $rules[] = "#quickbar { border-right: 1px solid gray; }";
41 $rules[] = "#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }";
43 $style = implode( "\n", $rules );
44 if ( $wgContLang->getDir() === 'rtl' ) {
45 $style = CSSJanus::transform( $style, true, false );
47 $out->addInlineStyle( $style );
52 class StandardTemplate extends LegacyTemplate {
54 function doAfterContent() {
55 global $wgContLang, $wgLang;
56 wfProfileIn( __METHOD__ );
57 wfProfileIn( __METHOD__ . '-1' );
59 $s = "\n</div><br style=\"clear:both\" />\n";
60 $s .= "\n<div id='footer'>";
61 $s .= '<table border="0" cellspacing="0"><tr>';
63 wfProfileOut( __METHOD__ . '-1' );
64 wfProfileIn( __METHOD__ . '-2' );
66 $qb = $this->getSkin()->qbSetting();
67 $shove = ( $qb != 0 );
68 $left = ( $qb == 1 || $qb == 3 );
70 if ( $shove && $left ) { # Left
71 $s .= $this->getQuickbarCompensator();
73 wfProfileOut( __METHOD__ . '-2' );
74 wfProfileIn( __METHOD__ . '-3' );
75 $l = $wgContLang->alignStart();
76 $s .= "<td class='bottom' align='$l' valign='top'>";
78 $s .= $this->bottomLinks();
79 $s .= "\n<br />" . $wgLang->pipeList( array(
80 $this->getSkin()->mainPageLink(),
81 $this->getSkin()->aboutLink(),
82 Linker::specialLink( 'Recentchanges' ),
83 $this->searchForm() ) )
84 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
86 $s .= '</td>';
87 if ( $shove && !$left ) { # Right
88 $s .= $this->getQuickbarCompensator();
90 $s .= "</tr></table>\n</div>\n</div>\n";
92 wfProfileOut( __METHOD__ . '-3' );
93 wfProfileIn( __METHOD__ . '-4' );
94 if ( 0 != $qb ) {
95 $s .= $this->quickBar();
97 wfProfileOut( __METHOD__ . '-4' );
98 wfProfileOut( __METHOD__ );
99 return $s;
102 function quickBar() {
103 global $wgOut, $wgUser, $wgRequest, $wgContLang;
105 wfProfileIn( __METHOD__ );
107 $action = $wgRequest->getText( 'action' );
108 $wpPreview = $wgRequest->getBool( 'wpPreview' );
109 $tns = $this->getSkin()->getTitle()->getNamespace();
111 $s = "\n<div id='quickbar'>";
112 $s .= "\n" . $this->getSkin()->logoText() . "\n<hr class='sep' />";
114 $sep = "\n<br />";
116 # Use the first heading from the Monobook sidebar as the "browse" section
117 $bar = $this->getSkin()->buildSidebar();
118 unset( $bar['SEARCH'] );
119 unset( $bar['LANGUAGES'] );
120 unset( $bar['TOOLBOX'] );
122 $barnumber = 1;
123 foreach ( $bar as $heading => $browseLinks ) {
124 if ( $barnumber > 1 ) {
125 $s .= "\n<hr class='sep' />";
127 foreach ( $browseLinks as $link ) {
128 if ( $link['text'] != '-' ) {
129 $s .= "<a href=\"{$link['href']}\">" .
130 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
133 if ( $barnumber == 1 ) {
134 // only show watchlist link if logged in
135 if( $wgUser->isLoggedIn() ) {
136 $s.= Linker::specialLink( 'Watchlist' ) ;
137 $s .= $sep . Linker::linkKnown(
138 SpecialPage::getTitleFor( 'Contributions' ),
139 wfMsg( 'mycontris' ),
140 array(),
141 array( 'target' => $wgUser->getName() )
145 $barnumber = $barnumber + 1;
148 $s .= "\n<hr class='sep' />";
149 $articleExists = $this->getSkin()->getTitle()->getArticleId();
150 if ( $wgOut->isArticle() || $action == 'edit' || $action == 'history' || $wpPreview ) {
151 if( $wgOut->isArticle() ) {
152 $s .= '<strong>' . $this->editThisPage() . '</strong>';
153 } else { # backlink to the article in edit or history mode
154 if( $articleExists ){ # no backlink if no article
155 switch( $tns ) {
156 case NS_TALK:
157 case NS_USER_TALK:
158 case NS_PROJECT_TALK:
159 case NS_FILE_TALK:
160 case NS_MEDIAWIKI_TALK:
161 case NS_TEMPLATE_TALK:
162 case NS_HELP_TALK:
163 case NS_CATEGORY_TALK:
164 $text = wfMsg('viewtalkpage');
165 break;
166 case NS_MAIN:
167 $text = wfMsg( 'articlepage' );
168 break;
169 case NS_USER:
170 $text = wfMsg( 'userpage' );
171 break;
172 case NS_PROJECT:
173 $text = wfMsg( 'projectpage' );
174 break;
175 case NS_FILE:
176 $text = wfMsg( 'imagepage' );
177 break;
178 case NS_MEDIAWIKI:
179 $text = wfMsg( 'mediawikipage' );
180 break;
181 case NS_TEMPLATE:
182 $text = wfMsg( 'templatepage' );
183 break;
184 case NS_HELP:
185 $text = wfMsg( 'viewhelppage' );
186 break;
187 case NS_CATEGORY:
188 $text = wfMsg( 'categorypage' );
189 break;
190 default:
191 $text = wfMsg( 'articlepage' );
194 $link = $this->getSkin()->getTitle()->getText();
195 $nstext = $wgContLang->getNsText( $tns );
196 if( $nstext ) { # add namespace if necessary
197 $link = $nstext . ':' . $link;
200 $s .= Linker::link( Title::newFromText( $link ), $text );
201 } elseif( $this->getSkin()->getTitle()->getNamespace() != NS_SPECIAL ) {
202 # we just throw in a "New page" text to tell the user that he's in edit mode,
203 # and to avoid messing with the separator that is prepended to the next item
204 $s .= '<strong>' . wfMsg( 'newpage' ) . '</strong>';
208 # "Post a comment" link
209 if( ( $this->getSkin()->getTitle()->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
210 $s .= '<br />' . $this->getSkin()->link(
211 $this->getSkin()->getTitle(),
212 wfMsg( 'postcomment' ),
213 array(),
214 array(
215 'action' => 'edit',
216 'section' => 'new'
218 array( 'known', 'noclasses' )
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' ) {
229 $s .= $sep . $this->watchThisPage();
231 if ( $this->getSkin()->getTitle()->userCan( 'edit' ) )
232 $s .= $sep . $this->moveThisPage();
234 if ( $wgUser->isAllowed( 'delete' ) && $articleExists ) {
235 $s .= $sep . $this->deleteThisPage() .
236 $sep . $this->protectThisPage();
238 $s .= $sep . $this->talkLink();
239 if( $articleExists && $action != 'history' ) {
240 $s .= $sep . $this->historyLink();
242 $s .= $sep . $this->whatLinksHere();
244 if( $wgOut->isArticleRelated() ) {
245 $s .= $sep . $this->watchPageLinksLink();
248 if (
249 NS_USER == $this->getSkin()->getTitle()->getNamespace() ||
250 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
253 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
254 $ip = User::isIP( $this->getSkin()->getTitle()->getText() );
256 if( $id || $ip ){
257 $s .= $sep . $this->userContribsLink();
259 if( $this->getSkin()->showEmailUser( $id ) ) {
260 $s .= $sep . $this->emailUserLink();
263 $s .= "\n<br /><hr class='sep' />";
266 if( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
267 $s .= $this->getUploadLink() . $sep;
270 $s .= Linker::specialLink( 'Specialpages' );
272 global $wgSiteSupportPage;
273 if( $wgSiteSupportPage ) {
274 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
275 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
278 $s .= "\n<br /></div>\n";
279 wfProfileOut( __METHOD__ );
280 return $s;