Merge "updater now shows the SQLite file being used"
[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 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
22 *
23 * @todo document
24 * @file
25 * @ingroup Skins
26 */
27
28 if( !defined( 'MEDIAWIKI' ) )
29 die( -1 );
30
31 /**
32 * Inherit main code from SkinTemplate, set the CSS and template filter.
33 * @todo document
34 * @ingroup Skins
35 */
36 class SkinMonoBook extends SkinTemplate {
37 /** Using monobook. */
38 var $skinname = 'monobook', $stylename = 'monobook',
39 $template = 'MonoBookTemplate', $useHeadElement = true;
40
41 /**
42 * @param $out OutputPage
43 */
44 function setupSkinUserCss( OutputPage $out ) {
45 global $wgHandheldStyle;
46 parent::setupSkinUserCss( $out );
47
48 $out->addModuleStyles( 'skins.monobook' );
49
50 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
51 if( $wgHandheldStyle ) {
52 // Currently in testing... try 'chick/main.css'
53 $out->addStyle( $wgHandheldStyle, 'handheld' );
54 }
55
56 // TODO: Migrate all of these
57 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
58 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
59
60 }
61 }
62
63 /**
64 * @todo document
65 * @ingroup Skins
66 */
67 class MonoBookTemplate extends BaseTemplate {
68
69 /**
70 * Template filter callback for MonoBook skin.
71 * Takes an associative array of data set from a SkinTemplate-based
72 * class, and a wrapper for MediaWiki's localization database, and
73 * outputs a formatted page.
74 *
75 * @access private
76 */
77 function execute() {
78 // Suppress warnings to prevent notices about missing indexes in $this->data
79 wfSuppressWarnings();
80
81 $this->html( 'headelement' );
82 ?><div id="globalWrapper">
83 <div id="column-content"><div id="content" class="mw-body-primary" role="main">
84 <a id="top"></a>
85 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
86
87 <h1 id="firstHeading" class="firstHeading" lang="<?php
88 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageLanguage()->getCode();
89 $this->html( 'pageLanguage' );
90 ?>"><span dir="auto"><?php $this->html('title') ?></span></h1>
91 <div id="bodyContent" class="mw-body">
92 <div id="siteSub"><?php $this->msg('tagline') ?></div>
93 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
94 <?php if($this->data['undelete']) { ?>
95 <div id="contentSub2"><?php $this->html('undelete') ?></div>
96 <?php } ?><?php if($this->data['newtalk'] ) { ?>
97 <div class="usermessage"><?php $this->html('newtalk') ?></div>
98 <?php } ?><?php if($this->data['showjumplinks']) { ?>
99 <div id="jump-to-nav" class="mw-jump"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a><?php $this->msg( 'comma-separator' ) ?><a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div>
100 <?php } ?>
101 <!-- start content -->
102 <?php $this->html('bodytext') ?>
103 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
104 <!-- end content -->
105 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
106 <div class="visualClear"></div>
107 </div>
108 </div></div>
109 <div id="column-one"<?php $this->html('userlangattributes') ?>>
110 <?php $this->cactions(); ?>
111 <div class="portlet" id="p-personal" role="navigation">
112 <h5><?php $this->msg('personaltools') ?></h5>
113 <div class="pBody">
114 <ul<?php $this->html('userlangattributes') ?>>
115 <?php foreach($this->getPersonalTools() as $key => $item) { ?>
116 <?php echo $this->makeListItem($key, $item); ?>
117
118 <?php } ?>
119 </ul>
120 </div>
121 </div>
122 <div class="portlet" id="p-logo" role="banner">
123 <?php
124 echo Html::element( 'a', array(
125 'href' => $this->data['nav_urls']['mainpage']['href'],
126 'style' => "background-image: url({$this->data['logopath']});" )
127 + Linker::tooltipAndAccesskeyAttribs('p-logo') ); ?>
128
129 </div>
130 <?php
131 $this->renderPortals( $this->data['sidebar'] );
132 ?>
133 </div><!-- end of the left (by default at least) column -->
134 <div class="visualClear"></div>
135 <?php
136 $validFooterIcons = $this->getFooterIcons( "icononly" );
137 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
138
139 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
140 <div id="footer" role="contentinfo"<?php $this->html('userlangattributes') ?>>
141 <?php
142 $footerEnd = '</div>';
143 } else {
144 $footerEnd = '';
145 }
146 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
147 <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
148 <?php foreach ( $footerIcons as $icon ) { ?>
149 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
150
151 <?php }
152 ?>
153 </div>
154 <?php }
155
156 if ( count( $validFooterLinks ) > 0 ) {
157 ?> <ul id="f-list">
158 <?php
159 foreach( $validFooterLinks as $aLink ) { ?>
160 <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
161 <?php
162 }
163 ?>
164 </ul>
165 <?php }
166 echo $footerEnd;
167 ?>
168
169 </div>
170 <?php
171 $this->printTrail();
172 echo Html::closeElement( 'body' );
173 echo Html::closeElement( 'html' );
174 wfRestoreWarnings();
175 } // end of execute() method
176
177 /*************************************************************************************************/
178
179 /**
180 * @param $sidebar array
181 */
182 protected function renderPortals( $sidebar ) {
183 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
184 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
185 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
186
187 foreach( $sidebar as $boxName => $content ) {
188 if ( $content === false )
189 continue;
190
191 if ( $boxName == 'SEARCH' ) {
192 $this->searchBox();
193 } elseif ( $boxName == 'TOOLBOX' ) {
194 $this->toolbox();
195 } elseif ( $boxName == 'LANGUAGES' ) {
196 $this->languageBox();
197 } else {
198 $this->customBox( $boxName, $content );
199 }
200 }
201 }
202
203 function searchBox() {
204 global $wgUseTwoButtonsSearchForm;
205 ?>
206 <div id="p-search" class="portlet" role="search">
207 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
208 <div id="searchBody" class="pBody">
209 <form action="<?php $this->text('wgScript') ?>" id="searchform">
210 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
211 <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
212
213 <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
214 if ($wgUseTwoButtonsSearchForm): ?>&#160;
215 <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
216 else: ?>
217
218 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php
219 endif; ?>
220
221 </form>
222 </div>
223 </div>
224 <?php
225 }
226
227 /**
228 * Prints the cactions bar.
229 * Shared between MonoBook and Modern
230 */
231 function cactions() {
232 ?>
233 <div id="p-cactions" class="portlet" role="navigation">
234 <h5><?php $this->msg('views') ?></h5>
235 <div class="pBody">
236 <ul><?php
237 foreach($this->data['content_actions'] as $key => $tab) {
238 echo '
239 ' . $this->makeListItem( $key, $tab );
240 } ?>
241
242 </ul>
243 </div>
244 </div>
245 <?php
246 }
247 /*************************************************************************************************/
248 function toolbox() {
249 ?>
250 <div class="portlet" id="p-tb" role="navigation">
251 <h5><?php $this->msg('toolbox') ?></h5>
252 <div class="pBody">
253 <ul>
254 <?php
255 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
256 <?php echo $this->makeListItem($key, $tbitem); ?>
257
258 <?php
259 }
260 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
261 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
262 ?>
263 </ul>
264 </div>
265 </div>
266 <?php
267 }
268
269 /*************************************************************************************************/
270 function languageBox() {
271 if( $this->data['language_urls'] ) {
272 ?>
273 <div id="p-lang" class="portlet" role="navigation">
274 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
275 <div class="pBody">
276 <ul>
277 <?php foreach($this->data['language_urls'] as $key => $langlink) { ?>
278 <?php echo $this->makeListItem($key, $langlink); ?>
279
280 <?php } ?>
281 </ul>
282 </div>
283 </div>
284 <?php
285 }
286 }
287
288 /*************************************************************************************************/
289 /**
290 * @param $bar string
291 * @param $cont array|string
292 */
293 function customBox( $bar, $cont ) {
294 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ), 'role' => 'navigation' );
295 $tooltip = Linker::titleAttrib( "p-$bar" );
296 if ( $tooltip !== false ) {
297 $portletAttribs['title'] = $tooltip;
298 }
299 echo ' ' . Html::openElement( 'div', $portletAttribs );
300 ?>
301
302 <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
303 <div class='pBody'>
304 <?php if ( is_array( $cont ) ) { ?>
305 <ul>
306 <?php foreach($cont as $key => $val) { ?>
307 <?php echo $this->makeListItem($key, $val); ?>
308
309 <?php } ?>
310 </ul>
311 <?php } else {
312 # allow raw HTML block to be defined by extensions
313 print $cont;
314 }
315 ?>
316 </div>
317 </div>
318 <?php
319 }
320 } // end of class
321
322