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