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