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