Merge "Introducing LinksUpdateTest."
[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/IE60Fixes.css', 'screen', 'IE 6' );
43 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
44
45 }
46 }
47
48 /**
49 * @todo document
50 * @ingroup Skins
51 */
52 class MonoBookTemplate extends BaseTemplate {
53
54 /**
55 * Template filter callback for MonoBook skin.
56 * Takes an associative array of data set from a SkinTemplate-based
57 * class, and a wrapper for MediaWiki's localization database, and
58 * outputs a formatted page.
59 *
60 * @access private
61 */
62 function execute() {
63 // Suppress warnings to prevent notices about missing indexes in $this->data
64 wfSuppressWarnings();
65
66 $this->html( 'headelement' );
67 ?><div id="globalWrapper">
68 <div id="column-content"><div id="content">
69 <a id="top"></a>
70 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
71
72 <h1 id="firstHeading" class="firstHeading"><span dir="auto"><?php $this->html('title') ?></span></h1>
73 <div id="bodyContent" class="mw-body">
74 <div id="siteSub"><?php $this->msg('tagline') ?></div>
75 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
76 <?php if($this->data['undelete']) { ?>
77 <div id="contentSub2"><?php $this->html('undelete') ?></div>
78 <?php } ?><?php if($this->data['newtalk'] ) { ?>
79 <div class="usermessage"><?php $this->html('newtalk') ?></div>
80 <?php } ?><?php if($this->data['showjumplinks']) { ?>
81 <div id="jump-to-nav" class="mw-jump"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div>
82 <?php } ?>
83 <!-- start content -->
84 <?php $this->html('bodytext') ?>
85 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
86 <!-- end content -->
87 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
88 <div class="visualClear"></div>
89 </div>
90 </div></div>
91 <div id="column-one"<?php $this->html('userlangattributes') ?>>
92 <?php $this->cactions(); ?>
93 <div class="portlet" id="p-personal">
94 <h5><?php $this->msg('personaltools') ?></h5>
95 <div class="pBody">
96 <ul<?php $this->html('userlangattributes') ?>>
97 <?php foreach($this->getPersonalTools() as $key => $item) { ?>
98 <?php echo $this->makeListItem($key, $item); ?>
99
100 <?php } ?>
101 </ul>
102 </div>
103 </div>
104 <div class="portlet" id="p-logo">
105 <?php
106 echo Html::element( 'a', array(
107 'href' => $this->data['nav_urls']['mainpage']['href'],
108 'style' => "background-image: url({$this->data['logopath']});" )
109 + Linker::tooltipAndAccesskeyAttribs('p-logo') ); ?>
110
111 </div>
112 <?php
113 $this->renderPortals( $this->data['sidebar'] );
114 ?>
115 </div><!-- end of the left (by default at least) column -->
116 <div class="visualClear"></div>
117 <?php
118 $validFooterIcons = $this->getFooterIcons( "icononly" );
119 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
120
121 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
122 <div id="footer"<?php $this->html('userlangattributes') ?>>
123 <?php
124 $footerEnd = '</div>';
125 } else {
126 $footerEnd = '';
127 }
128 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
129 <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
130 <?php foreach ( $footerIcons as $icon ) { ?>
131 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
132
133 <?php }
134 ?>
135 </div>
136 <?php }
137
138 if ( count( $validFooterLinks ) > 0 ) {
139 ?> <ul id="f-list">
140 <?php
141 foreach( $validFooterLinks as $aLink ) { ?>
142 <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
143 <?php
144 }
145 ?>
146 </ul>
147 <?php }
148 echo $footerEnd;
149 ?>
150
151 </div>
152 <?php
153 $this->printTrail();
154 echo Html::closeElement( 'body' );
155 echo Html::closeElement( 'html' );
156 wfRestoreWarnings();
157 } // end of execute() method
158
159 /*************************************************************************************************/
160
161 /**
162 * @param $sidebar array
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 function cactions() {
214 ?>
215 <div id="p-cactions" class="portlet">
216 <h5><?php $this->msg('views') ?></h5>
217 <div class="pBody">
218 <ul><?php
219 foreach($this->data['content_actions'] as $key => $tab) {
220 echo '
221 ' . $this->makeListItem( $key, $tab );
222 } ?>
223
224 </ul>
225 </div>
226 </div>
227 <?php
228 }
229 /*************************************************************************************************/
230 function toolbox() {
231 ?>
232 <div class="portlet" id="p-tb">
233 <h5><?php $this->msg('toolbox') ?></h5>
234 <div class="pBody">
235 <ul>
236 <?php
237 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
238 <?php echo $this->makeListItem($key, $tbitem); ?>
239
240 <?php
241 }
242 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
243 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
244 ?>
245 </ul>
246 </div>
247 </div>
248 <?php
249 }
250
251 /*************************************************************************************************/
252 function languageBox() {
253 if( $this->data['language_urls'] ) {
254 ?>
255 <div id="p-lang" class="portlet">
256 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
257 <div class="pBody">
258 <ul>
259 <?php foreach($this->data['language_urls'] as $key => $langlink) { ?>
260 <?php echo $this->makeListItem($key, $langlink); ?>
261
262 <?php } ?>
263 </ul>
264 </div>
265 </div>
266 <?php
267 }
268 }
269
270 /*************************************************************************************************/
271 /**
272 * @param $bar string
273 * @param $cont array|string
274 */
275 function customBox( $bar, $cont ) {
276 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ) );
277 $tooltip = Linker::titleAttrib( "p-$bar" );
278 if ( $tooltip !== false ) {
279 $portletAttribs['title'] = $tooltip;
280 }
281 echo ' ' . Html::openElement( 'div', $portletAttribs );
282 ?>
283
284 <h5><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></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