]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - skins/Standard.php
MediaWiki 1.11.0-scripts
[autoinstallsdev/mediawiki.git] / skins / Standard.php
1 <?php
2 /**
3  * See skin.txt
4  *
5  * @todo document
6  * @addtogroup Skins
7  */
8
9 if( !defined( 'MEDIAWIKI' ) )
10         die( -1 );
11
12 /**
13  * @todo document
14  * @addtogroup Skins
15  */
16 class SkinStandard extends Skin {
17
18         /**
19          *
20          */
21         function getHeadScripts( $allowUserJs ) {
22                 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
23
24                 $s = parent::getHeadScripts( $allowUserJs );
25                 if ( 3 == $this->qbSetting() ) { # Floating left
26                         $s .= "<script language='javascript' type='$wgJsMimeType' " .
27                           "src='{$wgStylePath}/common/sticky.js?$wgStyleVersion'></script>\n";
28                 }
29                 return $s;
30         }
31
32         /**
33          *
34          */
35         function getUserStyles() {
36                 global $wgStylePath, $wgStyleVersion;
37                 $s = '';
38                 if ( 3 == $this->qbSetting() ) { # Floating left
39                         $s .= "<style type='text/css'>\n" .
40                           "@import '{$wgStylePath}/common/quickbar.css?$wgStyleVersion';\n</style>\n";
41                 } else if ( 4 == $this->qbSetting() ) { # Floating right
42                         $s .= "<style type='text/css'>\n" .
43                           "@import '{$wgStylePath}/common/quickbar-right.css?$wgStyleVersion';\n</style>\n";
44                 }
45                 $s .= parent::getUserStyles();
46                 return $s;
47         }
48
49         /**
50          *
51          */
52         function doGetUserStyles() {
53                 global $wgStylePath;
54
55                 $s = parent::doGetUserStyles();
56                 $qb = $this->qbSetting();
57
58                 if ( 2 == $qb ) { # Right
59                         $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
60                           "border-left: 2px solid #000000; }\n" .
61                           "#article { margin-left: 4px; margin-right: 152px; }\n";
62                 } else if ( 1 == $qb || 3 == $qb ) {
63                         $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
64                           "border-right: 1px solid gray; }\n" .
65                           "#article { margin-left: 152px; margin-right: 4px; }\n";
66                 } else if ( 4 == $qb) {
67                         $s .= "#quickbar { border-right: 1px solid gray; }\n" .
68                           "#article { margin-right: 152px; margin-left: 4px; }\n";
69                 }
70                 return $s;
71         }
72
73         /**
74          *
75          */
76         function getBodyOptions() {
77                 $a = parent::getBodyOptions();
78
79                 if ( 3 == $this->qbSetting() ) { # Floating left
80                         $qb = "setup(\"quickbar\")";
81                         if($a["onload"]) {
82                                 $a["onload"] .= ";$qb";
83                         } else {
84                                 $a["onload"] = $qb;
85                         }
86                 }
87                 return $a;
88         }
89
90         function doAfterContent() {
91                 global $wgContLang;
92                 $fname =  'SkinStandard::doAfterContent';
93                 wfProfileIn( $fname );
94                 wfProfileIn( $fname.'-1' );
95
96                 $s = "\n</div><br style=\"clear:both\" />\n";
97                 $s .= "\n<div id='footer'>";
98                 $s .= '<table border="0" cellspacing="0"><tr>';
99
100                 wfProfileOut( $fname.'-1' );
101                 wfProfileIn( $fname.'-2' );
102
103                 $qb = $this->qbSetting();
104                 $shove = ($qb != 0);
105                 $left = ($qb == 1 || $qb == 3);
106                 if($wgContLang->isRTL()) $left = !$left;
107
108                 if ( $shove && $left ) { # Left
109                                 $s .= $this->getQuickbarCompensator();
110                 }
111                 wfProfileOut( $fname.'-2' );
112                 wfProfileIn( $fname.'-3' );
113                 $l = $wgContLang->isRTL() ? 'right' : 'left';
114                 $s .= "<td class='bottom' align='$l' valign='top'>";
115
116                 $s .= $this->bottomLinks();
117                 $s .= "\n<br />" . $this->mainPageLink()
118                   . ' | ' . $this->aboutLink()
119                   . ' | ' . $this->specialLink( 'recentchanges' )
120                   . ' | ' . $this->searchForm()
121                   . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
122
123                 $s .= "</td>";
124                 if ( $shove && !$left ) { # Right
125                         $s .= $this->getQuickbarCompensator();
126                 }
127                 $s .= "</tr></table>\n</div>\n</div>\n";
128
129                 wfProfileOut( $fname.'-3' );
130                 wfProfileIn( $fname.'-4' );
131                 if ( 0 != $qb ) { $s .= $this->quickBar(); }
132                 wfProfileOut( $fname.'-4' );
133                 wfProfileOut( $fname );
134                 return $s;
135         }
136
137         function quickBar() {
138                 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
139                 global $wgEnableUploads, $wgRemoteUploads;
140
141                 $fname =  'Skin::quickBar';
142                 wfProfileIn( $fname );
143
144                 $action = $wgRequest->getText( 'action' );
145                 $wpPreview = $wgRequest->getBool( 'wpPreview' );
146                 $tns=$wgTitle->getNamespace();
147
148                 $s = "\n<div id='quickbar'>";
149                 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
150
151                 $sep = "\n<br />";
152
153                 # Use the first heading from the Monobook sidebar as the "browse" section
154                 $bar = $this->buildSidebar();
155                 $browseLinks = reset( $bar );
156
157                 foreach ( $browseLinks as $link ) {
158                         if ( $link['text'] != '-' ) {
159                                 $s .= "<a href=\"{$link['href']}\">" .
160                                         htmlspecialchars( $link['text'] ) . '</a>' . $sep;
161                         }
162                 }
163
164                 if( $wgUser->isLoggedIn() ) {
165                         $s.= $this->specialLink( 'watchlist' ) ;
166                         $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
167                                 wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
168                 }
169                 // only show watchlist link if logged in
170                 $s .= "\n<hr class='sep' />";
171                 $articleExists = $wgTitle->getArticleId();
172                 if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
173                         if($wgOut->isArticle()) {
174                                 $s .= '<strong>' . $this->editThisPage() . '</strong>';
175                         } else { # backlink to the article in edit or history mode
176                                 if($articleExists){ # no backlink if no article
177                                         switch($tns) {
178                                                 case NS_TALK:
179                                                 case NS_USER_TALK:
180                                                 case NS_PROJECT_TALK:
181                                                 case NS_IMAGE_TALK:
182                                                 case NS_MEDIAWIKI_TALK:
183                                                 case NS_TEMPLATE_TALK:
184                                                 case NS_HELP_TALK:
185                                                 case NS_CATEGORY_TALK:
186                                                         $text = wfMsg('viewtalkpage');
187                                                         break;
188                                                 case NS_MAIN:
189                                                         $text = wfMsg( 'articlepage' );
190                                                         break;
191                                                 case NS_USER:
192                                                         $text = wfMsg( 'userpage' );
193                                                         break;
194                                                 case NS_PROJECT:
195                                                         $text = wfMsg( 'projectpage' );
196                                                         break;
197                                                 case NS_IMAGE:
198                                                         $text = wfMsg( 'imagepage' );
199                                                         break;
200                                                 case NS_MEDIAWIKI:
201                                                         $text = wfMsg( 'mediawikipage' );
202                                                         break;
203                                                 case NS_TEMPLATE:
204                                                         $text = wfMsg( 'templatepage' );
205                                                         break;
206                                                 case NS_HELP:
207                                                         $text = wfMsg( 'viewhelppage' );
208                                                         break;
209                                                 case NS_CATEGORY:
210                                                         $text = wfMsg( 'categorypage' );
211                                                         break;
212                                                 default:
213                                                         $text= wfMsg( 'articlepage' );
214                                         }
215
216                                         $link = $wgTitle->getText();
217                                         if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
218                                                 $link = $nstext . ':' . $link ;
219                                         }
220
221                                         $s .= $this->makeLink( $link, $text );
222                                 } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) {
223                                         # we just throw in a "New page" text to tell the user that he's in edit mode,
224                                         # and to avoid messing with the separator that is prepended to the next item
225                                         $s .= '<strong>' . wfMsg('newpage') . '</strong>';
226                                 }
227
228                         }
229
230                         # "Post a comment" link
231                         if( ( $wgTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview )
232                                 $s .= '<br />' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit&section=new' );
233                         
234                         #if( $tns%2 && $action!='edit' && !$wpPreview) {
235                                 #$s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit&section=new');
236                         #}
237
238                         /*
239                         watching could cause problems in edit mode:
240                         if user edits article, then loads "watch this article" in background and then saves
241                         article with "Watch this article" checkbox disabled, the article is transparently
242                         unwatched. Therefore we do not show the "Watch this page" link in edit mode
243                         */
244                         if ( $wgUser->isLoggedIn() && $articleExists) {
245                                 if($action!='edit' && $action != 'submit' )
246                                 {
247                                         $s .= $sep . $this->watchThisPage();
248                                 }
249                                 if ( $wgTitle->userCan( 'edit' ) )
250                                         $s .= $sep . $this->moveThisPage();
251                         }
252                         if ( $wgUser->isAllowed('delete') and $articleExists ) {
253                                 $s .= $sep . $this->deleteThisPage() .
254                                 $sep . $this->protectThisPage();
255                         }
256                         $s .= $sep . $this->talkLink();
257                         if ($articleExists && $action !='history') {
258                                 $s .= $sep . $this->historyLink();
259                         }
260                         $s.=$sep . $this->whatLinksHere();
261
262                         if($wgOut->isArticleRelated()) {
263                                 $s .= $sep . $this->watchPageLinksLink();
264                         }
265
266                         if ( NS_USER == $wgTitle->getNamespace()
267                                 || $wgTitle->getNamespace() == NS_USER_TALK ) {
268
269                                 $id=User::idFromName($wgTitle->getText());
270                                 $ip=User::isIP($wgTitle->getText());
271
272                                 if($id||$ip) {
273                                         $s .= $sep . $this->userContribsLink();
274                                 }
275                                 if( $this->showEmailUser( $id ) ) {
276                                         $s .= $sep . $this->emailUserLink();
277                                 }
278                         }
279                         $s .= "\n<br /><hr class='sep' />";
280                 }
281
282                 if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) {
283                         $s .= $this->specialLink( 'upload' ) . $sep;
284                 }
285                 $s .= $this->specialLink( 'specialpages' )
286                   . $sep . $this->bugReportsLink();
287
288                 global $wgSiteSupportPage;
289                 if( $wgSiteSupportPage ) {
290                         $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
291                           '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
292                 }
293
294                 $s .= "\n<br /></div>\n";
295                 wfProfileOut( $fname );
296                 return $s;
297         }
298
299
300 }
301
302