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