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