Use 'AS' for column alias
[lhc/web/wiklou.git] / skins / MonoBook.php
1 <?php
2 /**
3 * MonoBook nouveau
4 *
5 * Translated from gwicke's previous TAL template version to remove
6 * dependency on PHPTAL.
7 *
8 * @todo document
9 * @file
10 * @ingroup Skins
11 */
12
13 if( !defined( 'MEDIAWIKI' ) )
14 die( -1 );
15
16 /**
17 * Inherit main code from SkinTemplate, set the CSS and template filter.
18 * @todo document
19 * @ingroup Skins
20 */
21 class SkinMonoBook extends SkinTemplate {
22 /** Using monobook. */
23 var $skinname = 'monobook', $stylename = 'monobook',
24 $template = 'MonoBookTemplate', $useHeadElement = true;
25
26 function setupSkinUserCss( OutputPage $out ) {
27 global $wgHandheldStyle, $wgStyleVersion, $wgJsMimeType, $wgStylePath;
28
29 parent::setupSkinUserCss( $out );
30
31 // Append to the default screen common & print styles...
32 $out->addStyle( 'monobook/main.css', 'screen' );
33 if( $wgHandheldStyle ) {
34 // Currently in testing... try 'chick/main.css'
35 $out->addStyle( $wgHandheldStyle, 'handheld' );
36 }
37
38 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
39 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
40 $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
41 }
42 }
43
44 /**
45 * @todo document
46 * @ingroup Skins
47 */
48 class MonoBookTemplate extends QuickTemplate {
49 var $skin;
50 /**
51 * Template filter callback for MonoBook skin.
52 * Takes an associative array of data set from a SkinTemplate-based
53 * class, and a wrapper for MediaWiki's localization database, and
54 * outputs a formatted page.
55 *
56 * @access private
57 */
58 function execute() {
59 global $wgRequest;
60
61 $this->skin = $skin = $this->data['skin'];
62 $action = $wgRequest->getText( 'action' );
63
64 // Suppress warnings to prevent notices about missing indexes in $this->data
65 wfSuppressWarnings();
66
67 $this->html( 'headelement' );
68 ?> <div id="globalWrapper">
69 <div id="column-content">
70 <div id="content" <?php $this->html("specialpageattributes") ?>>
71 <a id="top"></a>
72 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
73 <h1 id="firstHeading" class="firstHeading"><?php $this->html('title') ?></h1>
74 <div id="bodyContent">
75 <h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
76 <div id="contentSub" <?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
77 <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
78 <?php if($this->data['newtalk'] ) { ?><div class="usermessage"><?php $this->html('newtalk') ?></div><?php } ?>
79 <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?>
80 <!-- start content -->
81 <?php $this->html('bodytext') ?>
82 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
83 <!-- end content -->
84 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
85 <div class="visualClear"></div>
86 </div>
87 </div>
88 </div>
89 <div id="column-one" <?php $this->html('userlangattributes') ?>>
90 <div id="p-cactions" class="portlet">
91 <h5><?php $this->msg('views') ?></h5>
92 <div class="pBody">
93 <ul>
94 <?php foreach($this->data['content_actions'] as $key => $tab) {
95 echo '
96 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
97 if( $tab['class'] ) {
98 echo ' class="'.htmlspecialchars($tab['class']).'"';
99 }
100 echo '><a href="'.htmlspecialchars($tab['href']).'"';
101 # We don't want to give the watch tab an accesskey if the
102 # page is being edited, because that conflicts with the
103 # accesskey on the watch checkbox. We also don't want to
104 # give the edit tab an accesskey, because that's fairly su-
105 # perfluous and conflicts with an accesskey (Ctrl-E) often
106 # used for editing in Safari.
107 if( in_array( $action, array( 'edit', 'submit' ) )
108 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
109 echo $skin->tooltip( "ca-$key" );
110 } else {
111 echo $skin->tooltipAndAccesskey( "ca-$key" );
112 }
113 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
114 } ?>
115 </ul>
116 </div>
117 </div>
118 <div class="portlet" id="p-personal">
119 <h5><?php $this->msg('personaltools') ?></h5>
120 <div class="pBody">
121 <ul <?php $this->html('userlangattributes') ?>>
122 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
123 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
124 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
125 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
126 if(!empty($item['class'])) { ?> class="<?php
127 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
128 echo htmlspecialchars($item['text']) ?></a></li>
129 <?php } ?>
130 </ul>
131 </div>
132 </div>
133 <div class="portlet" id="p-logo">
134 <a style="background-image: url(<?php $this->text('logopath') ?>);" <?php
135 ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
136 echo $skin->tooltipAndAccesskey('p-logo') ?>></a>
137 </div>
138 <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
139 <?php
140 $sidebar = $this->data['sidebar'];
141 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
142 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
143 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
144 foreach ($sidebar as $boxName => $cont) {
145 if ( $boxName == 'SEARCH' ) {
146 $this->searchBox();
147 } elseif ( $boxName == 'TOOLBOX' ) {
148 $this->toolbox();
149 } elseif ( $boxName == 'LANGUAGES' ) {
150 $this->languageBox();
151 } else {
152 $this->customBox( $boxName, $cont );
153 }
154 }
155 ?>
156 </div><!-- end of the left (by default at least) column -->
157 <div class="visualClear"></div>
158 <div id="footer" <?php $this->html('userlangattributes') ?>>
159 <?php
160 if($this->data['poweredbyico']) { ?>
161 <div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div>
162 <?php }
163 if($this->data['copyrightico']) { ?>
164 <div id="f-copyrightico"><?php $this->html('copyrightico') ?></div>
165 <?php }
166
167 // Generate additional footer links
168 $footerlinks = array(
169 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
170 'privacy', 'about', 'disclaimer', 'tagline',
171 );
172 $validFooterLinks = array();
173 foreach( $footerlinks as $aLink ) {
174 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
175 $validFooterLinks[] = $aLink;
176 }
177 }
178 if ( count( $validFooterLinks ) > 0 ) {
179 ?> <ul id="f-list">
180 <?php
181 foreach( $validFooterLinks as $aLink ) {
182 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
183 ?> <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
184 <?php }
185 }
186 ?>
187 </ul>
188 <?php }
189 ?>
190 </div>
191 </div>
192 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
193 <?php $this->html('reporttime') ?>
194 <?php if ( $this->data['debug'] ): ?>
195 <!-- Debug output:
196 <?php $this->text( 'debug' ); ?>
197
198 -->
199 <?php endif; ?>
200 </body></html>
201 <?php
202 wfRestoreWarnings();
203 } // end of execute() method
204
205 /*************************************************************************************************/
206 function searchBox() {
207 global $wgUseTwoButtonsSearchForm;
208 ?>
209 <div id="p-search" class="portlet">
210 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
211 <div id="searchBody" class="pBody">
212 <form action="<?php $this->text('wgScript') ?>" id="searchform">
213 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
214 <?php
215 echo Html::input( 'search',
216 isset( $this->data['search'] ) ? $this->data['search'] : '', 'search',
217 array(
218 'id' => 'searchInput',
219 'title' => $this->skin->titleAttrib( 'search' ),
220 'accesskey' => $this->skin->accesskey( 'search' )
221 ) ); ?>
222
223 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?>&nbsp;
224 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
225
226 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
227
228 </form>
229 </div>
230 </div>
231 <?php
232 }
233
234 /*************************************************************************************************/
235 function toolbox() {
236 ?>
237 <div class="portlet" id="p-tb">
238 <h5><?php $this->msg('toolbox') ?></h5>
239 <div class="pBody">
240 <ul>
241 <?php
242 if($this->data['notspecialpage']) { ?>
243 <li id="t-whatlinkshere"><a href="<?php
244 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
245 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
246 <?php
247 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
248 <li id="t-recentchangeslinked"><a href="<?php
249 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
250 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li>
251 <?php }
252 }
253 if( isset( $this->data['nav_urls']['trackbacklink'] ) && $this->data['nav_urls']['trackbacklink'] ) { ?>
254 <li id="t-trackbacklink"><a href="<?php
255 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
256 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
257 <?php }
258 if($this->data['feeds']) { ?>
259 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
260 ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
261 echo htmlspecialchars($feed['href']) ?>" rel="alternate" type="application/<?php echo $key ?>+xml" class="feedlink"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a>&nbsp;
262 <?php } ?></li><?php
263 }
264
265 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
266
267 if($this->data['nav_urls'][$special]) {
268 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
269 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
270 <?php }
271 }
272
273 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
274 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
275 ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
276 }
277
278 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
279 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
280 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
281 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
282 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
283 }
284
285 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
286 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
287 ?>
288 </ul>
289 </div>
290 </div>
291 <?php
292 }
293
294 /*************************************************************************************************/
295 function languageBox() {
296 if( $this->data['language_urls'] ) {
297 ?>
298 <div id="p-lang" class="portlet">
299 <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
300 <div class="pBody">
301 <ul>
302 <?php foreach($this->data['language_urls'] as $langlink) { ?>
303 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
304 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
305 <?php } ?>
306 </ul>
307 </div>
308 </div>
309 <?php
310 }
311 }
312
313 /*************************************************************************************************/
314 function customBox( $bar, $cont ) {
315 ?>
316 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
317 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
318 <div class='pBody'>
319 <?php if ( is_array( $cont ) ) { ?>
320 <ul>
321 <?php foreach($cont as $key => $val) { ?>
322 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
323 if ( $val['active'] ) { ?> class="active" <?php }
324 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
325 <?php } ?>
326 </ul>
327 <?php } else {
328 # allow raw HTML block to be defined by extensions
329 print $cont;
330 }
331 ?>
332 </div>
333 </div>
334 <?php
335 }
336 } // end of class
337
338