ab72506769589f350859a44878d6223e68258d60
[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/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
43 //$out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
44 //$out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
45 //$out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
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 = $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">
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(); ?>
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 $this->renderPortals( $this->data['sidebar'] );
127 ?>
128 </div><!-- end of the left (by default at least) column -->
129 <div class="visualClear"></div>
130 <?php
131 $validFooterIcons = $this->getFooterIcons( "icononly" );
132 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
133
134 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
135 <div id="footer"<?php $this->html('userlangattributes') ?>>
136 <?php
137 $footerEnd = '</div>';
138 } else {
139 $footerEnd = '';
140 }
141 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
142 <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
143 <?php foreach ( $footerIcons as $icon ) { ?>
144 <?php echo $this->skin->makeFooterIcon( $icon ); ?>
145
146 <?php }
147 ?>
148 </div>
149 <?php }
150
151 if ( count( $validFooterLinks ) > 0 ) {
152 ?> <ul id="f-list">
153 <?php
154 foreach( $validFooterLinks as $aLink ) { ?>
155 <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
156 <?php
157 }
158 ?>
159 </ul>
160 <?php }
161 echo $footerEnd;
162 ?>
163
164 </div>
165 <?php
166 $this->printTrail();
167 echo Html::closeElement( 'body' );
168 echo Html::closeElement( 'html' );
169 wfRestoreWarnings();
170 } // end of execute() method
171
172 /*************************************************************************************************/
173
174 protected function renderPortals( $sidebar ) {
175 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
176 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
177 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
178
179 foreach( $sidebar as $boxName => $content ) {
180 if ( $content === false )
181 continue;
182
183 if ( $boxName == 'SEARCH' ) {
184 $this->searchBox();
185 } elseif ( $boxName == 'TOOLBOX' ) {
186 $this->toolbox();
187 } elseif ( $boxName == 'LANGUAGES' ) {
188 $this->languageBox();
189 } else {
190 $this->customBox( $boxName, $content );
191 }
192 }
193 }
194
195 function searchBox() {
196 global $wgUseTwoButtonsSearchForm;
197 ?>
198 <div id="p-search" class="portlet">
199 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
200 <div id="searchBody" class="pBody">
201 <form action="<?php $this->text('wgScript') ?>" id="searchform">
202 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
203 <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
204
205 <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
206 if ($wgUseTwoButtonsSearchForm): ?>&#160;
207 <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
208 else: ?>
209
210 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php
211 endif; ?>
212
213 </form>
214 </div>
215 </div>
216 <?php
217 }
218
219 /**
220 * Prints the cactions bar.
221 * Shared between MonoBook and Modern
222 *
223 * @param $skin Skin
224 */
225 function cactions() {
226 ?>
227 <div id="p-cactions" class="portlet">
228 <h5><?php $this->msg('views') ?></h5>
229 <div class="pBody">
230 <ul><?php
231 foreach($this->data['content_actions'] as $key => $tab) {
232 $linkAttribs = array( 'href' => $tab['href'] );
233
234 if( isset( $tab["tooltiponly"] ) && $tab["tooltiponly"] ) {
235 $title = Linker::titleAttrib( "ca-$key" );
236 if ( $title !== false ) {
237 $linkAttribs['title'] = $title;
238 }
239 } else {
240 $linkAttribs += Linker::tooltipAndAccesskeyAttribs( "ca-$key" );
241 }
242 $linkHtml = Html::element( 'a', $linkAttribs, $tab['text'] );
243
244 /* Surround with a <li> */
245 $liAttribs = array( 'id' => Sanitizer::escapeId( "ca-$key" ) );
246 if( $tab['class'] ) {
247 $liAttribs['class'] = $tab['class'];
248 }
249 echo '
250 ' . Html::rawElement( 'li', $liAttribs, $linkHtml );
251 } ?>
252
253 </ul>
254 </div>
255 </div>
256 <?php
257 }
258 /*************************************************************************************************/
259 function toolbox() {
260 ?>
261 <div class="portlet" id="p-tb">
262 <h5><?php $this->msg('toolbox') ?></h5>
263 <div class="pBody">
264 <ul>
265 <?php
266 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
267 <?php echo $this->makeListItem($key, $tbitem); ?>
268
269 <?php
270 }
271 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
272 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
273 ?>
274 </ul>
275 </div>
276 </div>
277 <?php
278 }
279
280 /*************************************************************************************************/
281 function languageBox() {
282 if( $this->data['language_urls'] ) {
283 ?>
284 <div id="p-lang" class="portlet">
285 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
286 <div class="pBody">
287 <ul>
288 <?php foreach($this->data['language_urls'] as $key => $langlink) { ?>
289 <?php echo $this->makeListItem($key, $langlink); ?>
290
291 <?php } ?>
292 </ul>
293 </div>
294 </div>
295 <?php
296 }
297 }
298
299 /*************************************************************************************************/
300 function customBox( $bar, $cont ) {
301 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ) );
302 $tooltip = Linker::titleAttrib( "p-$bar" );
303 if ( $tooltip !== false ) {
304 $portletAttribs['title'] = $tooltip;
305 }
306 echo ' ' . Html::openElement( 'div', $portletAttribs );
307 ?>
308
309 <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
310 <div class='pBody'>
311 <?php if ( is_array( $cont ) ) { ?>
312 <ul>
313 <?php foreach($cont as $key => $val) { ?>
314 <?php echo $this->makeListItem($key, $val); ?>
315
316 <?php } ?>
317 </ul>
318 <?php } else {
319 # allow raw HTML block to be defined by extensions
320 print $cont;
321 }
322 ?>
323 </div>
324 </div>
325 <?php
326 }
327 } // end of class
328
329