drop comment about a removed parameter
[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 /**
27 * @param $out OutputPage
28 */
29 function setupSkinUserCss( OutputPage $out ) {
30 global $wgHandheldStyle;
31 parent::setupSkinUserCss( $out );
32
33 $out->addModuleStyles( 'skins.monobook' );
34
35 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
36 if( $wgHandheldStyle ) {
37 // Currently in testing... try 'chick/main.css'
38 $out->addStyle( $wgHandheldStyle, 'handheld' );
39 }
40
41 // TODO: Migrate all of these
42 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
43 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
44
45 }
46 }
47
48 /**
49 * @todo document
50 * @ingroup Skins
51 */
52 class MonoBookTemplate extends BaseTemplate {
53
54 /**
55 * Template filter callback for MonoBook skin.
56 * Takes an associative array of data set from a SkinTemplate-based
57 * class, and a wrapper for MediaWiki's localization database, and
58 * outputs a formatted page.
59 *
60 * @access private
61 */
62 function execute() {
63 // Suppress warnings to prevent notices about missing indexes in $this->data
64 wfSuppressWarnings();
65
66 $this->html( 'headelement' );
67 ?><div id="globalWrapper">
68 <div id="column-content"><div id="content">
69 <a id="top"></a>
70 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
71
72 <h1 id="firstHeading" class="firstHeading"><span dir="auto"><?php $this->html('title') ?></span></h1>
73 <div id="bodyContent" class="mw-body">
74 <div id="siteSub"><?php $this->msg('tagline') ?></div>
75 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
76 <?php if($this->data['undelete']) { ?>
77 <div id="contentSub2"><?php $this->html('undelete') ?></div>
78 <?php } ?><?php if($this->data['newtalk'] ) { ?>
79 <div class="usermessage"><?php $this->html('newtalk') ?></div>
80 <?php } ?><?php if($this->data['showjumplinks']) { ?>
81 <div id="jump-to-nav" class="mw-jump"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div>
82 <?php } ?>
83 <!-- start content -->
84 <?php $this->html('bodytext') ?>
85 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
86 <!-- end content -->
87 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
88 <div class="visualClear"></div>
89 </div>
90 </div></div>
91 <div id="column-one"<?php $this->html('userlangattributes') ?>>
92 <?php $this->cactions(); ?>
93 <div class="portlet" id="p-personal">
94 <h5><?php $this->msg('personaltools') ?></h5>
95 <div class="pBody">
96 <ul<?php $this->html('userlangattributes') ?>>
97 <?php foreach($this->getPersonalTools() as $key => $item) { ?>
98 <?php echo $this->makeListItem($key, $item); ?>
99
100 <?php } ?>
101 </ul>
102 </div>
103 </div>
104 <div class="portlet" id="p-logo">
105 <?php
106 echo Html::element( 'a', array(
107 'href' => $this->data['nav_urls']['mainpage']['href'],
108 'style' => "background-image: url({$this->data['logopath']});" )
109 + Linker::tooltipAndAccesskeyAttribs('p-logo') ); ?>
110
111 </div>
112 <?php
113 $this->renderPortals( $this->data['sidebar'] );
114 ?>
115 </div><!-- end of the left (by default at least) column -->
116 <div class="visualClear"></div>
117 <?php
118 $validFooterIcons = $this->getFooterIcons( "icononly" );
119 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
120
121 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
122 <div id="footer"<?php $this->html('userlangattributes') ?>>
123 <?php
124 $footerEnd = '</div>';
125 } else {
126 $footerEnd = '';
127 }
128 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
129 <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
130 <?php foreach ( $footerIcons as $icon ) { ?>
131 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
132
133 <?php }
134 ?>
135 </div>
136 <?php }
137
138 if ( count( $validFooterLinks ) > 0 ) {
139 ?> <ul id="f-list">
140 <?php
141 foreach( $validFooterLinks as $aLink ) { ?>
142 <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
143 <?php
144 }
145 ?>
146 </ul>
147 <?php }
148 echo $footerEnd;
149 ?>
150
151 </div>
152 <?php
153 $this->printTrail();
154 echo Html::closeElement( 'body' );
155 echo Html::closeElement( 'html' );
156 wfRestoreWarnings();
157 } // end of execute() method
158
159 /*************************************************************************************************/
160
161 protected function renderPortals( $sidebar ) {
162 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
163 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
164 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
165
166 foreach( $sidebar as $boxName => $content ) {
167 if ( $content === false )
168 continue;
169
170 if ( $boxName == 'SEARCH' ) {
171 $this->searchBox();
172 } elseif ( $boxName == 'TOOLBOX' ) {
173 $this->toolbox();
174 } elseif ( $boxName == 'LANGUAGES' ) {
175 $this->languageBox();
176 } else {
177 $this->customBox( $boxName, $content );
178 }
179 }
180 }
181
182 function searchBox() {
183 global $wgUseTwoButtonsSearchForm;
184 ?>
185 <div id="p-search" class="portlet">
186 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
187 <div id="searchBody" class="pBody">
188 <form action="<?php $this->text('wgScript') ?>" id="searchform">
189 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
190 <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
191
192 <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
193 if ($wgUseTwoButtonsSearchForm): ?>&#160;
194 <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
195 else: ?>
196
197 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php
198 endif; ?>
199
200 </form>
201 </div>
202 </div>
203 <?php
204 }
205
206 /**
207 * Prints the cactions bar.
208 * Shared between MonoBook and Modern
209 */
210 function cactions() {
211 ?>
212 <div id="p-cactions" class="portlet">
213 <h5><?php $this->msg('views') ?></h5>
214 <div class="pBody">
215 <ul><?php
216 foreach($this->data['content_actions'] as $key => $tab) {
217 echo '
218 ' . $this->makeListItem( $key, $tab );
219 } ?>
220
221 </ul>
222 </div>
223 </div>
224 <?php
225 }
226 /*************************************************************************************************/
227 function toolbox() {
228 ?>
229 <div class="portlet" id="p-tb">
230 <h5><?php $this->msg('toolbox') ?></h5>
231 <div class="pBody">
232 <ul>
233 <?php
234 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
235 <?php echo $this->makeListItem($key, $tbitem); ?>
236
237 <?php
238 }
239 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
240 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
241 ?>
242 </ul>
243 </div>
244 </div>
245 <?php
246 }
247
248 /*************************************************************************************************/
249 function languageBox() {
250 if( $this->data['language_urls'] ) {
251 ?>
252 <div id="p-lang" class="portlet">
253 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
254 <div class="pBody">
255 <ul>
256 <?php foreach($this->data['language_urls'] as $key => $langlink) { ?>
257 <?php echo $this->makeListItem($key, $langlink); ?>
258
259 <?php } ?>
260 </ul>
261 </div>
262 </div>
263 <?php
264 }
265 }
266
267 /*************************************************************************************************/
268 function customBox( $bar, $cont ) {
269 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ) );
270 $tooltip = Linker::titleAttrib( "p-$bar" );
271 if ( $tooltip !== false ) {
272 $portletAttribs['title'] = $tooltip;
273 }
274 echo ' ' . Html::openElement( 'div', $portletAttribs );
275 ?>
276
277 <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
278 <div class='pBody'>
279 <?php if ( is_array( $cont ) ) { ?>
280 <ul>
281 <?php foreach($cont as $key => $val) { ?>
282 <?php echo $this->makeListItem($key, $val); ?>
283
284 <?php } ?>
285 </ul>
286 <?php } else {
287 # allow raw HTML block to be defined by extensions
288 print $cont;
289 }
290 ?>
291 </div>
292 </div>
293 <?php
294 }
295 } // end of class
296
297