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