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