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