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