2ffa8f20af0611e77040767b45bcefee103e96bb
[lhc/web/wiklou.git] / skins / Standard.php
1 <?php
2 /**
3 * See skin.doc
4 *
5 * @todo document
6 * @package MediaWiki
7 * @subpackage Skins
8 */
9
10 /**
11 * @todo document
12 * @package MediaWiki
13 * @subpackage Skins
14 */
15 class SkinStandard extends Skin {
16
17 /**
18 *
19 */
20 function getHeadScripts() {
21 global $wgStylePath;
22
23 $s = parent::getHeadScripts();
24 if ( 3 == $this->qbSetting() ) { # Floating left
25 $s .= "<script language='javascript' type='text/javascript' " .
26 "src='{$wgStylePath}/common/sticky.js'></script>\n";
27 }
28 return $s;
29 }
30
31 /**
32 *
33 */
34 function getUserStyles() {
35 global $wgStylePath;
36 $s = '';
37 if ( 3 == $this->qbSetting() ) { # Floating left
38 $s .= "<style type='text/css'>\n" .
39 "@import '{$wgStylePath}/common/quickbar.css';\n</style>\n";
40 }
41 $s .= parent::getUserStyles();
42 return $s;
43 }
44
45 /**
46 *
47 */
48 function doGetUserStyles() {
49 global $wgUser, $wgOut, $wgStylePath;
50
51 $s = parent::doGetUserStyles();
52 $qb = $this->qbSetting();
53
54 if ( 2 == $qb ) { # Right
55 $s .= "#quickbar { position: absolute; top: 4px; right: 4px; " .
56 "border-left: 2px solid #000000; }\n" .
57 "#article { margin-left: 4px; margin-right: 152px; }\n";
58 } else if ( 1 == $qb || 3 == $qb ) {
59 $s .= "#quickbar { position: absolute; top: 4px; left: 4px; " .
60 "border-right: 1px solid gray; }\n" .
61 "#article { margin-left: 152px; margin-right: 4px; }\n";
62 }
63 return $s;
64 }
65
66 /**
67 *
68 */
69 function getBodyOptions() {
70 $a = parent::getBodyOptions();
71
72 if ( 3 == $this->qbSetting() ) { # Floating left
73 $qb = "setup(\"quickbar\")";
74 if($a["onload"]) {
75 $a["onload"] .= ";$qb";
76 } else {
77 $a["onload"] = $qb;
78 }
79 }
80 return $a;
81 }
82
83 function doAfterContent() {
84 global $wgUser, $wgOut, $wgContLang;
85 $fname = 'SkinStandard::doAfterContent';
86 wfProfileIn( $fname );
87 wfProfileIn( $fname.'-1' );
88
89 $s = "\n</div><br style=\"clear:both\" />\n";
90 $s .= "\n<div id='footer'>";
91 $s .= '<table border="0" cellspacing="0"><tr>';
92
93 wfProfileOut( $fname.'-1' );
94 wfProfileIn( $fname.'-2' );
95
96 $qb = $this->qbSetting();
97 $shove = ($qb != 0);
98 $left = ($qb == 1 || $qb == 3);
99 if($wgContLang->isRTL()) $left = !$left;
100
101 if ( $shove && $left ) { # Left
102 $s .= $this->getQuickbarCompensator();
103 }
104 wfProfileOut( $fname.'-2' );
105 wfProfileIn( $fname.'-3' );
106 $l = $wgContLang->isRTL() ? 'right' : 'left';
107 $s .= "<td class='bottom' align='$l' valign='top'>";
108
109 $s .= $this->bottomLinks();
110 $s .= "\n<br />" . $this->mainPageLink()
111 . ' | ' . $this->aboutLink()
112 . ' | ' . $this->specialLink( 'recentchanges' )
113 . ' | ' . $this->searchForm()
114 . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
115
116 $s .= "</td>";
117 if ( $shove && !$left ) { # Right
118 $s .= $this->getQuickbarCompensator();
119 }
120 $s .= "</tr></table>\n</div>\n</div>\n";
121
122 wfProfileOut( $fname.'-3' );
123 wfProfileIn( $fname.'-4' );
124 if ( 0 != $qb ) { $s .= $this->quickBar(); }
125 wfProfileOut( $fname.'-4' );
126 wfProfileOut( $fname );
127 return $s;
128 }
129
130 function quickBar() {
131 global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgContLang;
132 global $wgDisableUploads, $wgRemoteUploads, $wgNavigationLinks;
133
134 $fname = 'Skin::quickBar';
135 wfProfileIn( $fname );
136
137 $action = $wgRequest->getText( 'action' );
138 $wpPreview = $wgRequest->getBool( 'wpPreview' );
139 $tns=$wgTitle->getNamespace();
140
141 $s = "\n<div id='quickbar'>";
142 $s .= "\n" . $this->logoText() . "\n<hr class='sep' />";
143
144 $sep = "\n<br />";
145
146 foreach ( $wgNavigationLinks as $link ) {
147 $msg = wfMsgForContent( $link['href'] );
148 if ( $msg != '-' ) {
149 $s .= '<a href="' . $this->makeInternalOrExternalUrl( $msg ) . '">' .
150 wfMsg( $link['text'] ) . '</a>' . $sep;
151 }
152 }
153
154
155 if ($wgUser->getID()) {
156 $s.= $this->specialLink( 'watchlist' ) ;
157 $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ),
158 wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) );
159
160 }
161 // only show watchlist link if logged in
162 $s .= "\n<hr class='sep' />";
163 $articleExists = $wgTitle->getArticleId();
164 if ( $wgOut->isArticle() || $action =='edit' || $action =='history' || $wpPreview) {
165 if($wgOut->isArticle()) {
166 $s .= '<strong>' . $this->editThisPage() . '</strong>';
167 } else { # backlink to the article in edit or history mode
168 if($articleExists){ # no backlink if no article
169 switch($tns) {
170 case 0:
171 $text = wfMsg('articlepage');
172 break;
173 case 1:
174 $text = wfMsg('viewtalkpage');
175 break;
176 case 2:
177 $text = wfMsg('userpage');
178 break;
179 case 3:
180 $text = wfMsg('viewtalkpage');
181 break;
182 case 4:
183 $text = wfMsg('wikipediapage');
184 break;
185 case 5:
186 $text = wfMsg('viewtalkpage');
187 break;
188 case 6:
189 $text = wfMsg('imagepage');
190 break;
191 case 7:
192 $text = wfMsg('viewtalkpage');
193 break;
194 default:
195 $text= wfMsg('articlepage');
196 }
197
198 $link = $wgTitle->getText();
199 if ($nstext = $wgContLang->getNsText($tns) ) { # add namespace if necessary
200 $link = $nstext . ':' . $link ;
201 }
202
203 $s .= $this->makeLink( $link, $text );
204 } elseif( $wgTitle->getNamespace() != Namespace::getSpecial() ) {
205 # we just throw in a "New page" text to tell the user that he's in edit mode,
206 # and to avoid messing with the separator that is prepended to the next item
207 $s .= '<strong>' . wfMsg('newpage') . '</strong>';
208 }
209
210 }
211
212
213 if( $tns%2 && $action!='edit' && !$wpPreview) {
214 $s.= '<br />'.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit&section=new');
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 ( 0 != $wgUser->getID() && $articleExists) {
224 if($action!='edit' && $action != 'submit' )
225 {
226 $s .= $sep . $this->watchThisPage();
227 }
228 if ( $wgTitle->userCanEdit() )
229 $s .= $sep . $this->moveThisPage();
230 }
231 if ( $wgUser->isSysop() and $articleExists ) {
232 $s .= $sep . $this->deleteThisPage() .
233 $sep . $this->protectThisPage();
234 }
235 $s .= $sep . $this->talkLink();
236 if ($articleExists && $action !='history') {
237 $s .= $sep . $this->historyLink();
238 }
239 $s.=$sep . $this->whatLinksHere();
240
241 if($wgOut->isArticleRelated()) {
242 $s .= $sep . $this->watchPageLinksLink();
243 }
244
245 if ( Namespace::getUser() == $wgTitle->getNamespace()
246 || $wgTitle->getNamespace() == Namespace::getTalk(Namespace::getUser())
247 ) {
248
249 $id=User::idFromName($wgTitle->getText());
250 $ip=User::isIP($wgTitle->getText());
251
252 if($id||$ip) {
253 $s .= $sep . $this->userContribsLink();
254 }
255 if ( 0 != $wgUser->getID() ) {
256 if($id) { # can only email real users
257 $s .= $sep . $this->emailUserLink();
258 }
259 }
260 }
261 $s .= "\n<br /><hr class='sep' />";
262 }
263
264 if ( 0 != $wgUser->getID() && ( !$wgDisableUploads || $wgRemoteUploads ) ) {
265 $s .= $this->specialLink( 'upload' ) . $sep;
266 }
267 $s .= $this->specialLink( 'specialpages' )
268 . $sep . $this->bugReportsLink();
269
270 global $wgSiteSupportPage;
271 if( $wgSiteSupportPage ) {
272 $s .= "\n<br /><a href=\"" . htmlspecialchars( $wgSiteSupportPage ) .
273 '" class="internal">' . wfMsg( 'sitesupport' ) . '</a>';
274 }
275
276 $s .= "\n<br /></div>\n";
277 wfProfileOut( $fname );
278 return $s;
279 }
280
281
282 }
283
284 ?>