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