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