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