Remove extra space, ping r109550
[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 * @param $skin Skin
211 */
212 function cactions() {
213 ?>
214 <div id="p-cactions" class="portlet">
215 <h5><?php $this->msg('views') ?></h5>
216 <div class="pBody">
217 <ul><?php
218 foreach($this->data['content_actions'] as $key => $tab) {
219 echo '
220 ' . $this->makeListItem( $key, $tab );
221 } ?>
222
223 </ul>
224 </div>
225 </div>
226 <?php
227 }
228 /*************************************************************************************************/
229 function toolbox() {
230 ?>
231 <div class="portlet" id="p-tb">
232 <h5><?php $this->msg('toolbox') ?></h5>
233 <div class="pBody">
234 <ul>
235 <?php
236 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
237 <?php echo $this->makeListItem($key, $tbitem); ?>
238
239 <?php
240 }
241 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
242 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
243 ?>
244 </ul>
245 </div>
246 </div>
247 <?php
248 }
249
250 /*************************************************************************************************/
251 function languageBox() {
252 if( $this->data['language_urls'] ) {
253 ?>
254 <div id="p-lang" class="portlet">
255 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
256 <div class="pBody">
257 <ul>
258 <?php foreach($this->data['language_urls'] as $key => $langlink) { ?>
259 <?php echo $this->makeListItem($key, $langlink); ?>
260
261 <?php } ?>
262 </ul>
263 </div>
264 </div>
265 <?php
266 }
267 }
268
269 /*************************************************************************************************/
270 function customBox( $bar, $cont ) {
271 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ) );
272 $tooltip = Linker::titleAttrib( "p-$bar" );
273 if ( $tooltip !== false ) {
274 $portletAttribs['title'] = $tooltip;
275 }
276 echo ' ' . Html::openElement( 'div', $portletAttribs );
277 ?>
278
279 <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
280 <div class='pBody'>
281 <?php if ( is_array( $cont ) ) { ?>
282 <ul>
283 <?php foreach($cont as $key => $val) { ?>
284 <?php echo $this->makeListItem($key, $val); ?>
285
286 <?php } ?>
287 </ul>
288 <?php } else {
289 # allow raw HTML block to be defined by extensions
290 print $cont;
291 }
292 ?>
293 </div>
294 </div>
295 <?php
296 }
297 } // end of class
298
299