Implement $wgFooterIcons to replace copyrightico and poweredbyico with a flexible...
[lhc/web/wiklou.git] / skins / Modern.php
1 <?php
2 /**
3 * Modern skin, derived from monobook template.
4 *
5 * @todo document
6 * @file
7 * @ingroup Skins
8 */
9
10 if( !defined( 'MEDIAWIKI' ) )
11 die( -1 );
12
13 require( dirname(__FILE__) . '/MonoBook.php' );
14
15 /**
16 * Inherit main code from SkinTemplate, set the CSS and template filter.
17 * @todo document
18 * @ingroup Skins
19 */
20 class SkinModern extends SkinTemplate {
21 var $skinname = 'modern', $stylename = 'modern',
22 $template = 'ModernTemplate', $useHeadElement = true;
23
24 function setupSkinUserCss( OutputPage $out ){
25 // Do not call parent::setupSkinUserCss(), we have our own print style
26 $out->addStyle( 'common/shared.css', 'screen' );
27 $out->addStyle( 'modern/main.css', 'screen' );
28 $out->addStyle( 'modern/print.css', 'print' );
29 $out->addStyle( 'modern/rtl.css', 'screen', '', 'rtl' );
30 }
31 }
32
33 /**
34 * @todo document
35 * @ingroup Skins
36 */
37 class ModernTemplate extends MonoBookTemplate {
38 var $skin;
39 /**
40 * Template filter callback for Modern skin.
41 * Takes an associative array of data set from a SkinTemplate-based
42 * class, and a wrapper for MediaWiki's localization database, and
43 * outputs a formatted page.
44 *
45 * @access private
46 */
47 function execute() {
48 global $wgRequest;
49 $this->skin = $skin = $this->data['skin'];
50 $action = $wgRequest->getText( 'action' );
51
52 // Suppress warnings to prevent notices about missing indexes in $this->data
53 wfSuppressWarnings();
54
55 // Generate additional footer links
56 $footerlinks = $this->data["footerlinks"];
57 // fold footerlinks into a single array using a bit of trickery
58 $footerlinks = call_user_func_array('array_merge', array_values($footerlinks));
59 // Generate additional footer icons
60 $footericons = $this->data["footericons"];
61 // Unset copyright.copyright since we don't need the icon and already output a copyright from footerlinks
62 unset($footericons["copyright"]["copyright"]);
63 if ( count($footericons["copyright"]) <= 0 ) {
64 unset($footericons["copyright"]);
65 }
66
67 $this->html( 'headelement' );
68 ?>
69
70 <!-- heading -->
71 <div id="mw_header"><h1 id="firstHeading"><?php $this->html('title') ?></h1></div>
72
73 <div id="mw_main">
74 <div id="mw_contentwrapper">
75 <!-- navigation portlet -->
76 <div id="p-cactions" class="portlet">
77 <h5><?php $this->msg('views') ?></h5>
78 <div class="pBody">
79 <ul>
80 <?php foreach($this->data['content_actions'] as $key => $tab) {
81 echo '
82 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
83 if( $tab['class'] ) {
84 echo ' class="'.htmlspecialchars($tab['class']).'"';
85 }
86 echo'><a href="'.htmlspecialchars($tab['href']).'"';
87 # We don't want to give the watch tab an accesskey if the
88 # page is being edited, because that conflicts with the
89 # accesskey on the watch checkbox. We also don't want to
90 # give the edit tab an accesskey, because that's fairly su-
91 # perfluous and conflicts with an accesskey (Ctrl-E) often
92 # used for editing in Safari.
93 if( in_array( $action, array( 'edit', 'submit' ) )
94 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
95 echo $skin->tooltip( "ca-$key" );
96 } else {
97 echo $skin->tooltipAndAccesskey( "ca-$key" );
98 }
99 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
100 } ?>
101 </ul>
102 </div>
103 </div>
104
105 <!-- content -->
106 <div id="mw_content">
107 <!-- contentholder does nothing by default, but it allows users to style the text inside
108 the content area without affecting the meaning of 'em' in #mw_content, which is used
109 for the margins -->
110 <div id="mw_contentholder" <?php $this->html("specialpageattributes") ?>>
111 <div class='mw-topboxes'>
112 <div id="mw-js-message" style="display:none;"<?php $this->html('userlangattributes')?>></div>
113 <div class="mw-topbox" id="siteSub"><?php $this->msg('tagline') ?></div>
114 <?php if($this->data['newtalk'] ) {
115 ?><div class="usermessage mw-topbox"><?php $this->html('newtalk') ?></div>
116 <?php } ?>
117 <?php if($this->data['sitenotice']) {
118 ?><div class="mw-topbox" id="siteNotice"><?php $this->html('sitenotice') ?></div>
119 <?php } ?>
120 </div>
121
122 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
123
124 <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
125 <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#mw_portlets"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?>
126
127 <?php $this->html('bodytext') ?>
128 <div class='mw_clear'></div>
129 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
130 <?php $this->html ('dataAfterContent') ?>
131 </div><!-- mw_contentholder -->
132 </div><!-- mw_content -->
133 </div><!-- mw_contentwrapper -->
134
135 <div id="mw_portlets"<?php $this->html("userlangattributes") ?>>
136
137 <!-- portlets -->
138 <?php
139 $sidebar = $this->data['sidebar'];
140 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
141 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
142 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
143
144 foreach ($sidebar as $boxName => $cont) {
145 if ( $boxName == 'SEARCH' ) {
146 $this->searchBox();
147 } elseif ( $boxName == 'TOOLBOX' ) {
148 $this->toolbox();
149 } elseif ( $boxName == 'LANGUAGES' ) {
150 $this->languageBox();
151 } else {
152 $this->customBox( $boxName, $cont );
153 }
154 }
155 ?>
156
157 </div><!-- mw_portlets -->
158
159
160 </div><!-- main -->
161
162 <div class="mw_clear"></div>
163
164 <!-- personal portlet -->
165 <div class="portlet" id="p-personal">
166 <h5><?php $this->msg('personaltools') ?></h5>
167 <div class="pBody">
168 <ul>
169 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
170 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
171 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
172 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
173 if(!empty($item['class'])) { ?> class="<?php
174 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
175 echo htmlspecialchars($item['text']) ?></a></li>
176 <?php } ?>
177 </ul>
178 </div>
179 </div>
180
181
182 <!-- footer -->
183 <div id="footer"<?php $this->html('userlangattributes') ?>>
184 <ul id="f-list">
185 <?php
186 foreach( $footerlinks as $aLink ) {
187 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
188 ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li>
189 <?php }
190 }
191 ?>
192 </ul>
193 <?php
194 foreach ( $footericons as $blockName => $footerIcons ) { ?>
195 <div id="mw_<?php echo htmlspecialchars($blockName); ?>">
196 <?php
197 foreach ( $footerIcons as $icon ) {
198 if ( is_string($icon) ) {
199 $html = $icon;
200 } else {
201 $html = htmlspecialchars($icon["alt"]);
202 if ( $icon["url"] ) {
203 $html = Html::element( 'a', array( "href" => $icon["url"] ), $html );
204 }
205 }
206 echo " $html\n";
207 } ?>
208 </div>
209 <?php
210 }
211 ?>
212 </div>
213
214 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
215 <?php $this->html('reporttime') ?>
216 <?php if ( $this->data['debug'] ): ?>
217 <!-- Debug output:
218 <?php $this->text( 'debug' ); ?>
219 -->
220 <?php endif; ?>
221 </body></html>
222 <?php
223 wfRestoreWarnings();
224 } // end of execute() method
225 } // end of class
226
227