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