(bug 34956) Parser should use mUrlProtocol instead of wfUrlProtocols()
[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[] = "/* @noflip */#quickbar { position: absolute; top: 4px; right: 4px; border-left: 2px solid #000000; }";
33 $rules[] = "/* @noflip */#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }";
34 $rules[] = "/* @noflip */#topbar, #footer { margin-right: 152px; }";
35 } elseif ( 1 == $qb || 3 == $qb ) {
36 $rules[] = "/* @noflip */#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }";
37 $rules[] = "/* @noflip */#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }";
38 $rules[] = "/* @noflip */#topbar, #footer { margin-left: 152px; }";
39 if( 3 == $qb ) {
40 $rules[] = "/* @noflip */#quickbar { position: fixed; padding: 4px; }";
41 }
42 } elseif ( 4 == $qb ) {
43 $rules[] = "/* @noflip */#quickbar { position: fixed; right: 0; top: 0; padding: 4px; }";
44 $rules[] = "/* @noflip */#quickbar { border-right: 1px solid gray; }";
45 $rules[] = "/* @noflip */#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }";
46 $rules[] = "/* @noflip */#topbar, #footer { margin-right: 152px; }";
47 }
48 $style = implode( "\n", $rules );
49 $out->addInlineStyle( $style, 'flip' );
50 }
51
52 }
53
54 class StandardTemplate extends LegacyTemplate {
55
56 /**
57 * @return string
58 */
59 function doAfterContent() {
60 wfProfileIn( __METHOD__ );
61 wfProfileIn( __METHOD__ . '-1' );
62
63 $s = "\n</div><br style=\"clear:both\" />\n";
64 $s .= "\n<div id='footer'>";
65 $s .= '<table border="0" cellspacing="0"><tr>';
66
67 wfProfileOut( __METHOD__ . '-1' );
68 wfProfileIn( __METHOD__ . '-2' );
69 $l = $this->getSkin()->getLanguage()->alignStart();
70 $s .= "<td class='bottom' align='$l' valign='top'>";
71
72 $s .= $this->bottomLinks();
73 $s .= "\n<br />" . $this->getSkin()->getLanguage()->pipeList( array(
74 $this->getSkin()->mainPageLink(),
75 $this->getSkin()->aboutLink(),
76 Linker::specialLink( 'Recentchanges' ),
77 $this->searchForm() ) )
78 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
79
80 $s .= '</td>';
81 $s .= "</tr></table>\n</div>\n</div>\n";
82
83 wfProfileOut( __METHOD__ . '-2' );
84 wfProfileIn( __METHOD__ . '-3' );
85 if ( $this->getSkin()->qbSetting() != 0 ) {
86 $s .= $this->quickBar();
87 }
88 wfProfileOut( __METHOD__ . '-3' );
89 wfProfileOut( __METHOD__ );
90 return $s;
91 }
92
93 /**
94 * @return string
95 */
96 function quickBar() {
97 global $wgContLang;
98
99 wfProfileIn( __METHOD__ );
100
101 $action = $this->getSkin()->getRequest()->getText( 'action' );
102 $wpPreview = $this->getSkin()->getRequest()->getBool( 'wpPreview' );
103 $title = $this->getSkin()->getTitle();
104 $tns = $title->getNamespace();
105
106 $s = "\n<div id='quickbar'>";
107 $s .= "\n" . $this->getSkin()->logoText() . "\n<hr class='sep' />";
108
109 $sep = "\n<br />";
110
111 # Use the first heading from the Monobook sidebar as the "browse" section
112 $bar = $this->getSkin()->buildSidebar();
113 unset( $bar['SEARCH'] );
114 unset( $bar['LANGUAGES'] );
115 unset( $bar['TOOLBOX'] );
116
117 $barnumber = 1;
118 foreach ( $bar as $browseLinks ) {
119 if ( is_array( $browseLinks ) ) {
120 if ( $barnumber > 1 ) {
121 $s .= "\n<hr class='sep' />";
122 }
123 foreach ( $browseLinks as $link ) {
124 if ( $link['text'] != '-' ) {
125 $s .= "<a href=\"{$link['href']}\">" .
126 htmlspecialchars( $link['text'] ) . '</a>' . $sep;
127 }
128 }
129 }
130 if ( $barnumber == 1 ) {
131 // only show watchlist link if logged in
132 if( $this->data['loggedin'] ) {
133 $s.= Linker::specialLink( 'Watchlist' ) ;
134 $s .= $sep . Linker::linkKnown(
135 SpecialPage::getTitleFor( 'Contributions' ),
136 wfMsg( 'mycontris' ),
137 array(),
138 array( 'target' => $this->data['username'] )
139 );
140 }
141 }
142 $barnumber = $barnumber + 1;
143 }
144
145 $s .= "\n<hr class='sep' />";
146 $articleExists = $title->getArticleID();
147 if ( $this->data['isarticle'] || $action == 'edit' || $action == 'history' || $wpPreview ) {
148 if( $this->data['isarticle'] ) {
149 $s .= '<strong>' . $this->editThisPage() . '</strong>';
150 } else { # backlink to the article in edit or history mode
151 if( $articleExists ){ # no backlink if no article
152 switch( $tns ) {
153 case NS_TALK:
154 case NS_USER_TALK:
155 case NS_PROJECT_TALK:
156 case NS_FILE_TALK:
157 case NS_MEDIAWIKI_TALK:
158 case NS_TEMPLATE_TALK:
159 case NS_HELP_TALK:
160 case NS_CATEGORY_TALK:
161 $text = wfMsg('viewtalkpage');
162 break;
163 case NS_MAIN:
164 $text = wfMsg( 'articlepage' );
165 break;
166 case NS_USER:
167 $text = wfMsg( 'userpage' );
168 break;
169 case NS_PROJECT:
170 $text = wfMsg( 'projectpage' );
171 break;
172 case NS_FILE:
173 $text = wfMsg( 'imagepage' );
174 break;
175 case NS_MEDIAWIKI:
176 $text = wfMsg( 'mediawikipage' );
177 break;
178 case NS_TEMPLATE:
179 $text = wfMsg( 'templatepage' );
180 break;
181 case NS_HELP:
182 $text = wfMsg( 'viewhelppage' );
183 break;
184 case NS_CATEGORY:
185 $text = wfMsg( 'categorypage' );
186 break;
187 default:
188 $text = wfMsg( 'articlepage' );
189 }
190
191 $link = $title->getText();
192 $nstext = $wgContLang->getNsText( $tns );
193 if( $nstext ) { # add namespace if necessary
194 $link = $nstext . ':' . $link;
195 }
196
197 $s .= Linker::link( Title::newFromText( $link ), $text );
198 } elseif( $title->getNamespace() != NS_SPECIAL ) {
199 # we just throw in a "New page" text to tell the user that he's in edit mode,
200 # and to avoid messing with the separator that is prepended to the next item
201 $s .= '<strong>' . wfMsg( 'newpage' ) . '</strong>';
202 }
203 }
204
205 # "Post a comment" link
206 if( ( $title->isTalkPage() || $this->getSkin()->getOutput()->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
207 $s .= '<br />' . Linker::link(
208 $title,
209 wfMsg( 'postcomment' ),
210 array(),
211 array(
212 'action' => 'edit',
213 'section' => 'new'
214 )
215 );
216
217 /**
218 * Watching could cause problems in edit mode:
219 * if user edits article, then loads "watch this article" in background and then saves
220 * article with "Watch this article" checkbox disabled, the article is transparently
221 * unwatched. Therefore we do not show the "Watch this page" link in edit mode.
222 */
223 if ( $this->data['loggedin'] && $articleExists ) {
224 if( $action != 'edit' && $action != 'submit' ) {
225 $s .= $sep . $this->watchThisPage();
226 }
227 if ( $title->userCan( 'edit' ) )
228 $s .= $sep . $this->moveThisPage();
229 }
230 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) && $articleExists ) {
231 $s .= $sep . $this->deleteThisPage() .
232 $sep . $this->protectThisPage();
233 }
234 $s .= $sep . $this->talkLink();
235 if( $articleExists && $action != 'history' ) {
236 $s .= $sep . $this->historyLink();
237 }
238 $s .= $sep . $this->whatLinksHere();
239
240 if( $this->getSkin()->getOutput()->isArticleRelated() ) {
241 $s .= $sep . $this->watchPageLinksLink();
242 }
243
244 if (
245 NS_USER == $title->getNamespace() ||
246 $title->getNamespace() == NS_USER_TALK
247 ) {
248
249 $id = User::idFromName( $title->getText() );
250 $ip = User::isIP( $title->getText() );
251
252 if( $id || $ip ){
253 $s .= $sep . $this->userContribsLink();
254 }
255 if( $this->getSkin()->showEmailUser( $id ) ) {
256 $s .= $sep . $this->emailUserLink();
257 }
258 }
259 $s .= "\n<br /><hr class='sep' />";
260 }
261
262 if( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getSkin()->getUser() ) === true ) {
263 $s .= $this->getUploadLink() . $sep;
264 }
265
266 $s .= Linker::specialLink( 'Specialpages' );
267
268 global $wgSiteSupportPage;
269 if( $wgSiteSupportPage ) {
270 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
271 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
272 }
273
274 $s .= "\n<br /></div>\n";
275 wfProfileOut( __METHOD__ );
276 return $s;
277 }
278
279 }