Factorise calls to $this->getSkin()->getUser() in SkinCologneBlue::quickBar(); also...
[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 /**
27 * @param $out OutputPage
28 */
29 function setupSkinUserCss( OutputPage $out ) {
30 global $wgHandheldStyle;
31 parent::setupSkinUserCss( $out );
32
33 $out->addModuleStyles( 'skins.monobook' );
34
35 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
36 if( $wgHandheldStyle ) {
37 // Currently in testing... try 'chick/main.css'
38 $out->addStyle( $wgHandheldStyle, 'handheld' );
39 }
40
41 // TODO: Migrate all of these
42 $out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
43 $out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
44 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
45 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
46
47 }
48 }
49
50 /**
51 * @todo document
52 * @ingroup Skins
53 */
54 class MonoBookTemplate extends BaseTemplate {
55
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 // Suppress warnings to prevent notices about missing indexes in $this->data
66 wfSuppressWarnings();
67
68 $this->html( 'headelement' );
69 ?><div id="globalWrapper">
70 <div id="column-content"><div id="content">
71 <a id="top"></a>
72 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
73
74 <h1 id="firstHeading" class="firstHeading"><?php $this->html('title') ?></h1>
75 <div id="bodyContent" class="mw-body">
76 <div id="siteSub"><?php $this->msg('tagline') ?></div>
77 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
78 <?php if($this->data['undelete']) { ?>
79 <div id="contentSub2"><?php $this->html('undelete') ?></div>
80 <?php } ?><?php if($this->data['newtalk'] ) { ?>
81 <div class="usermessage"><?php $this->html('newtalk') ?></div>
82 <?php } ?><?php if($this->data['showjumplinks']) { ?>
83 <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>
84 <?php } ?>
85 <!-- start content -->
86 <?php $this->html('bodytext') ?>
87 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
88 <!-- end content -->
89 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
90 <div class="visualClear"></div>
91 </div>
92 </div></div>
93 <div id="column-one"<?php $this->html('userlangattributes') ?>>
94 <?php $this->cactions(); ?>
95 <div class="portlet" id="p-personal">
96 <h5><?php $this->msg('personaltools') ?></h5>
97 <div class="pBody">
98 <ul<?php $this->html('userlangattributes') ?>>
99 <?php foreach($this->getPersonalTools() as $key => $item) { ?>
100 <?php echo $this->makeListItem($key, $item); ?>
101
102 <?php } ?>
103 </ul>
104 </div>
105 </div>
106 <div class="portlet" id="p-logo">
107 <?php
108 echo Html::element( 'a', array(
109 'href' => $this->data['nav_urls']['mainpage']['href'],
110 'style' => "background-image: url({$this->data['logopath']});" )
111 + Linker::tooltipAndAccesskeyAttribs('p-logo') ); ?>
112
113 </div>
114 <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
115 <?php
116 $this->renderPortals( $this->data['sidebar'] );
117 ?>
118 </div><!-- end of the left (by default at least) column -->
119 <div class="visualClear"></div>
120 <?php
121 $validFooterIcons = $this->getFooterIcons( "icononly" );
122 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
123
124 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
125 <div id="footer"<?php $this->html('userlangattributes') ?>>
126 <?php
127 $footerEnd = '</div>';
128 } else {
129 $footerEnd = '';
130 }
131 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
132 <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
133 <?php foreach ( $footerIcons as $icon ) { ?>
134 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
135
136 <?php }
137 ?>
138 </div>
139 <?php }
140
141 if ( count( $validFooterLinks ) > 0 ) {
142 ?> <ul id="f-list">
143 <?php
144 foreach( $validFooterLinks as $aLink ) { ?>
145 <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
146 <?php
147 }
148 ?>
149 </ul>
150 <?php }
151 echo $footerEnd;
152 ?>
153
154 </div>
155 <?php
156 $this->printTrail();
157 echo Html::closeElement( 'body' );
158 echo Html::closeElement( 'html' );
159 wfRestoreWarnings();
160 } // end of execute() method
161
162 /*************************************************************************************************/
163
164 protected function renderPortals( $sidebar ) {
165 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
166 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
167 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
168
169 foreach( $sidebar as $boxName => $content ) {
170 if ( $content === false )
171 continue;
172
173 if ( $boxName == 'SEARCH' ) {
174 $this->searchBox();
175 } elseif ( $boxName == 'TOOLBOX' ) {
176 $this->toolbox();
177 } elseif ( $boxName == 'LANGUAGES' ) {
178 $this->languageBox();
179 } else {
180 $this->customBox( $boxName, $content );
181 }
182 }
183 }
184
185 function searchBox() {
186 global $wgUseTwoButtonsSearchForm;
187 ?>
188 <div id="p-search" class="portlet">
189 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
190 <div id="searchBody" class="pBody">
191 <form action="<?php $this->text('wgScript') ?>" id="searchform">
192 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
193 <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
194
195 <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
196 if ($wgUseTwoButtonsSearchForm): ?>&#160;
197 <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
198 else: ?>
199
200 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php
201 endif; ?>
202
203 </form>
204 </div>
205 </div>
206 <?php
207 }
208
209 /**
210 * Prints the cactions bar.
211 * Shared between MonoBook and Modern
212 *
213 * @param $skin Skin
214 */
215 function cactions() {
216 ?>
217 <div id="p-cactions" class="portlet">
218 <h5><?php $this->msg('views') ?></h5>
219 <div class="pBody">
220 <ul><?php
221 foreach($this->data['content_actions'] as $key => $tab) {
222 echo '
223 ' . $this->makeListItem( $key, $tab );
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 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ) );
275 $tooltip = Linker::titleAttrib( "p-$bar" );
276 if ( $tooltip !== false ) {
277 $portletAttribs['title'] = $tooltip;
278 }
279 echo ' ' . Html::openElement( 'div', $portletAttribs );
280 ?>
281
282 <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h5>
283 <div class='pBody'>
284 <?php if ( is_array( $cont ) ) { ?>
285 <ul>
286 <?php foreach($cont as $key => $val) { ?>
287 <?php echo $this->makeListItem($key, $val); ?>
288
289 <?php } ?>
290 </ul>
291 <?php } else {
292 # allow raw HTML block to be defined by extensions
293 print $cont;
294 }
295 ?>
296 </div>
297 </div>
298 <?php
299 }
300 } // end of class
301
302