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