Debian Codegraph @

skins/Cppreference2.php

raw
1 <?php
2 /**
3 * Vector - Modern version of MonoBook with fresh look and many usability
4 * improvements.
5 *
6 * @todo document
7 * @file
8 * @ingroup Skins
9 */
10
11 if( !defined( 'MEDIAWIKI' ) ) {
12 die( -1 );
13 }
14
15 #require_once(dirname(__FILE__)."/cppreference2/resourcemodules.php");
16
17 /**
18 * SkinTemplate class for Cppreference2 skin
19 * @ingroup Skins
20 */
21 class SkinCppreference2 extends SkinTemplate {
22
23 var $skinname = 'cppreference2', $stylename = 'cppreference2',
24 $template = 'Cppreference2Template', $useHeadElement = true;
25
26 /**
27 * Initializes output page and sets up skin-specific parameters
28 * @param $out OutputPage object to initialize
29 */
30 public function initPage( OutputPage $out ) {
31 global $wgLocalStylePath, $wgRequest;
32
33 parent::initPage( $out );
34
35 // Append CSS which includes IE only behavior fixes for hover support -
36 // this is better than including this in a CSS fille since it doesn't
37 // wait for the CSS file to load before fetching the HTC file.
38 $min = $wgRequest->getFuzzyBool( 'debug' ) ? '' : '.min';
39 $out->addHeadItem( 'csshover',
40 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
41 htmlspecialchars( $wgLocalStylePath ) .
42 "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
43 );
44
45 $out->addModuleScripts( 'skins.cppreference2' );
46 }
47
48 /**
49 * Load skin and user CSS files in the correct order
50 * fixes bug 22916
51 * @param $out OutputPage object
52 */
53 function setupSkinUserCss( OutputPage $out ){
54 parent::setupSkinUserCss( $out );
55 $out->addModuleStyles( 'skins.cppreference2' );
56 }
57 }
58
59 /**
60 * QuickTemplate class for Cppreference2 skin
61 * @ingroup Skins
62 */
63 class Cppreference2Template extends BaseTemplate {
64
65 /* Members */
66
67 /**
68 * @var Skin Cached skin object
69 */
70 var $skin;
71
72 /* Functions */
73
74 /**
75 * Outputs the entire contents of the (X)HTML page
76 */
77 public function execute() {
78 global $wgLang, $wgVectorUseIconWatch;
79
80 $this->skin = $this->data['skin'];
81
82 // Build additional attributes for navigation urls
83 //$nav = $this->skin->buildNavigationUrls();
84 $nav = $this->data['content_navigation'];
85
86 if ( $wgVectorUseIconWatch ) {
87 $mode = $this->skin->getTitle()->userIsWatching() ? 'unwatch' : 'watch';
88 if ( isset( $nav['actions'][$mode] ) ) {
89 $nav['views'][$mode] = $nav['actions'][$mode];
90 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
91 $nav['views'][$mode]['primary'] = true;
92 unset( $nav['actions'][$mode] );
93 }
94 }
95
96 $xmlID = '';
97 foreach ( $nav as $section => $links ) {
98 foreach ( $links as $key => $link ) {
99 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) {
100 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' );
101 }
102
103 $xmlID = isset( $link['id'] ) ? $link['id'] : 'ca-' . $xmlID;
104 $nav[$section][$key]['attributes'] =
105 ' id="' . Sanitizer::escapeId( $xmlID ) . '"';
106 if ( $link['class'] ) {
107 $nav[$section][$key]['attributes'] .=
108 ' class="' . htmlspecialchars( $link['class'] ) . '"';
109 unset( $nav[$section][$key]['class'] );
110 }
111 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
112 $nav[$section][$key]['key'] =
113 Linker::tooltip( $xmlID );
114 } else {
115 $nav[$section][$key]['key'] =
116 Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( $xmlID ) );
117 }
118 }
119 }
120 $this->data['namespace_urls'] = $nav['namespaces'];
121 $this->data['view_urls'] = $nav['views'];
122 $this->data['action_urls'] = $nav['actions'];
123 $this->data['variant_urls'] = $nav['variants'];
124
125 // Reverse horizontally rendered navigation elements
126 if ( $wgLang->isRTL() ) {
127 $this->data['view_urls'] =
128 array_reverse( $this->data['view_urls'] );
129 $this->data['namespace_urls'] =
130 array_reverse( $this->data['namespace_urls'] );
131 }
132 // Output HTML Page
133 $this->html( 'headelement' );
134
135 global $Cppreference2SkinRootLink;
136 $root_link = '/';
137 if (isset($Cppreference2SkinRootLink)) {
138 $root_link = htmlspecialchars($Cppreference2SkinRootLink);
139 }
140 ?>
141 <!-- header -->
142 <div id="mw-head" class="noprint">
143 <div id="cpp-head-first-base">
144 <div id="cpp-head-first">
145 <h5><a href="<?php echo $root_link; ?>">
146 <?php global $wgSitename; echo $wgSitename;?>
147 </a></h5>
148 <div id="cpp-head-search">
149 <?php $this->renderNavigation( 'SEARCH' ); ?>
150 </div>
151 <div id="cpp-head-personal">
152 <?php $this->renderNavigation( 'PERSONAL' ); ?>
153 </div>
154
155 </div>
156 </div>
157 <div id="cpp-head-second-base">
158 <div id="cpp-head-second">
159 <div id="cpp-head-tools-left">
160 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?>
161 </div>
162 <div id="cpp-head-tools-right">
163 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS' ) ); ?>
164 </div>
165 </div>
166 </div>
167 </div>
168 <!-- /header -->
169 <!-- content -->
170 <div id="cpp-content-base">
171 <div id="content">
172 <a id="top"></a>
173 <div id="mw-js-message" style="display:none;"<?php $this->html( 'userlangattributes' ) ?>></div>
174 <?php if ( $this->data['sitenotice'] ): ?>
175 <!-- sitenotice -->
176 <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div>
177 <!-- /sitenotice -->
178 <?php endif; ?>
179 <!-- firstHeading -->
180 <h1 id="firstHeading" class="firstHeading"><?php $this->html( 'title' ) ?></h1>
181 <!-- /firstHeading -->
182 <!-- bodyContent -->
183 <div id="bodyContent">
184 <?php if ( $this->data['isarticle'] ): ?>
185 <!-- tagline -->
186 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
187 <!-- /tagline -->
188 <?php endif; ?>
189 <!-- subtitle -->
190 <div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' ) ?></div>
191 <!-- /subtitle -->
192 <?php if ( $this->data['undelete'] ): ?>
193 <!-- undelete -->
194 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
195 <!-- /undelete -->
196 <?php endif; ?>
197 <?php if( $this->data['newtalk'] ): ?>
198 <!-- newtalk -->
199 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
200 <!-- /newtalk -->
201 <?php endif; ?>
202 <!-- bodycontent -->
203 <?php $this->html( 'bodycontent' ) ?>
204 <!-- /bodycontent -->
205 <?php if ( $this->data['printfooter'] ): ?>
206 <!-- printfooter -->
207 <div class="printfooter">
208 <?php $this->html( 'printfooter' ); ?>
209 </div>
210 <!-- /printfooter -->
211 <?php endif; ?>
212 <?php if ( $this->data['catlinks'] ): ?>
213 <!-- catlinks -->
214 <?php $this->html( 'catlinks' ); ?>
215 <!-- /catlinks -->
216 <?php endif; ?>
217 <?php if ( $this->data['dataAfterContent'] ): ?>
218 <!-- dataAfterContent -->
219 <?php $this->html( 'dataAfterContent' ); ?>
220 <!-- /dataAfterContent -->
221 <?php endif; ?>
222 <div class="visualClear"></div>
223 <!-- debughtml -->
224 <?php $this->html( 'debughtml' ); ?>
225 <!-- /debughtml -->
226 </div>
227 <!-- /bodyContent -->
228 </div>
229 </div>
230 <!-- /content -->
231 <!-- footer -->
232 <div id="cpp-footer-base" class="noprint">
233 <div id="footer"<?php $this->html( 'userlangattributes' ) ?>>
234 <?php $this->renderBottomNavigation();?>
235 <?php $this->renderToolbox(); ?>
236 <?php $this->renderFooter(); ?>
237 </div>
238 </div>
239 <!-- /footer -->
240 <?php $this->printTrail(); ?>
241
242 </body>
243 </html>
244 <?php
245 }
246
247 private function renderToolbox()
248 {
249 $name = 'tb';
250
251 $content = $this->getToolbox();
252
253 $msg = 'toolbox';
254 $msg_obj = wfMessage( $msg );
255 $message = htmlspecialchars($msg_obj->exists() ? $msg_obj->text() : $msg);
256
257 ?>
258 <div id="cpp-toolbox">
259 <h5><span><?php echo $message; ?></span><a href="#"></a></h5>
260 <ul>
261 <?php foreach( $content as $key => $val ):
262 echo $this->makeListItem( $key, $val );
263 endforeach;
264 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ));
265 ?>
266 </ul>
267 </div>
268 <?php
269 }
270
271 private function renderBottomNavigation()
272 {
273 $content = $this->data['sidebar']['navigation'];
274
275 $msg = 'navigation';
276 $msg_obj = wfMessage( $msg );
277 $message = htmlspecialchars($msg_obj->exists() ? $msg_obj->text() : $msg);
278
279 ?>
280 <div id="cpp-navigation">
281 <h5><?php echo $message; ?></h5>
282 <ul>
283 <?php foreach( $content as $key => $val ):
284 echo $this->makeListItem( $key, $val );
285 endforeach; ?>
286 </ul>
287 </div>
288 <?php
289 }
290
291 private function renderLanguages()
292 {
293 $content = $this->data['language_urls'];
294
295 $msg = 'otherlanguages';
296 $msg_obj = wfMessage( $msg );
297 $message = htmlspecialchars($msg_obj->exists() ? $msg_obj->text() : $msg);
298
299 ?>
300 <div id="cpp-languages">
301 <div><ul><li><?php echo $message; ?></li></ul></div>
302 <div><ul>
303 <?php foreach( $content as $key => $val ):
304 echo $this->makeListItem( $key, $val );
305 endforeach; ?>
306 </ul></div>
307 </div>
308 <?php
309 }
310
311 private function renderFooter()
312 {
313 if ( $this->data['language_urls'] ) { $this->renderLanguages(); }
314 foreach( $this->getFooterLinks() as $category => $links ): ?>
315 <ul id="footer-<?php echo $category ?>">
316 <?php foreach( $links as $link ): ?>
317 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li>
318 <?php endforeach; ?>
319 </ul>
320 <?php endforeach; ?>
321 <?php $footericons = $this->getFooterIcons("icononly");
322 if ( count( $footericons ) > 0 ): ?>
323 <ul id="footer-icons" class="noprint">
324 <?php foreach ( $footericons as $blockName => $footerIcons ): ?>
325 <li id="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
326 <?php foreach ( $footerIcons as $icon ): ?>
327 <?php echo $this->skin->makeFooterIcon( $icon ); ?>
328 <?php endforeach; ?>
329 </li>
330 <?php endforeach; ?>
331 </ul>
332 <?php endif; ?>
333 <div style="clear:both">
334 </div>
335 <?php
336 }
337
338 /**
339 * Render one or more navigations elements by name, automatically reveresed
340 * when UI is in RTL mode
341 */
342 private function renderNavigation( $elements ) {
343 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser, $wgLang;
344
345 // If only one element was given, wrap it in an array, allowing more
346 // flexible arguments
347 if ( !is_array( $elements ) ) {
348 $elements = array( $elements );
349 // If there's a series of elements, reverse them when in RTL mode
350 } elseif ( $wgLang->isRTL() ) {
351 $elements = array_reverse( $elements );
352 }
353 // Render elements
354 foreach ( $elements as $name => $element ) {
355 echo "\n<!-- {$name} -->\n";
356 switch ( $element ) {
357 case 'NAMESPACES':
358 ?>
359 <div id="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
360 <h5><?php $this->msg( 'namespaces' ) ?></h5>
361 <ul<?php $this->html( 'userlangattributes' ) ?>>
362 <?php foreach ( $this->data['namespace_urls'] as $link ): ?>
363 <li <?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></span></li>
364 <?php endforeach; ?>
365 </ul>
366 </div>
367 <?php
368 break;
369 case 'VARIANTS':
370 ?>
371 <div id="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
372 <?php if ( $wgVectorShowVariantName ): ?>
373 <h4>
374 <?php foreach ( $this->data['variant_urls'] as $link ): ?>
375 <?php if ( stripos( $link['attributes'], 'selected' ) !== false ): ?>
376 <?php echo htmlspecialchars( $link['text'] ) ?>
377 <?php endif; ?>
378 <?php endforeach; ?>
379 </h4>
380 <?php endif; ?>
381 <h5><span><?php $this->msg( 'variants' ) ?></span><a href="#"></a></h5>
382 <div class="menu">
383 <ul<?php $this->html( 'userlangattributes' ) ?>>
384 <?php foreach ( $this->data['variant_urls'] as $link ): ?>
385 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
386 <?php endforeach; ?>
387 </ul>
388 </div>
389 </div>
390 <?php
391 break;
392 case 'VIEWS':
393 ?>
394 <div id="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
395 <h5><?php $this->msg('views') ?></h5>
396 <ul<?php $this->html('userlangattributes') ?>>
397 <?php foreach ( $this->data['view_urls'] as $link ): ?>
398 <li<?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php
399 // $link['text'] can be undefined - bug 27764
400 if ( array_key_exists( 'text', $link ) ) {
401 echo array_key_exists( 'img', $link ) ? '<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
402 }
403 ?></a></span></li>
404 <?php endforeach; ?>
405 </ul>
406 </div>
407 <?php
408 break;
409 case 'ACTIONS':
410 ?>
411 <div id="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
412 <h5><span><?php $this->msg( 'actions' ) ?></span><a href="#"></a></h5>
413 <div class="menu">
414 <ul<?php $this->html( 'userlangattributes' ) ?>>
415 <?php foreach ( $this->data['action_urls'] as $link ): ?>
416 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
417 <?php endforeach; ?>
418 </ul>
419 </div>
420 </div>
421 <?php
422 break;
423 case 'PERSONAL':
424 ?>
425 <div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
426 <?php
427 $tools = $this->getPersonalTools();
428 $item = reset($tools);
429 $key = key($tools);
430 array_shift($tools);
431
432 echo $this->makeListItem( $key, $item, array( 'tag' => 'span' ) );
433 if ( count( $tools ) > 0 ) {
434 ?>
435 <div class="menu">
436 <ul<?php $this->html( 'userlangattributes' ) ?>>
437 <?php foreach( $tools as $key => $item ) {
438 echo $this->makeListItem( $key, $item );
439 } ?>
440 </ul>
441 </div>
442 <?php } ?>
443 </div>
444 <?php
445 break;
446 case 'SEARCH':
447 ?>
448 <div id="p-search">
449 <h5<?php $this->html( 'userlangattributes' ) ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
450 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
451 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
452 <?php if ( true ): ?>
453 <div id="simpleSearch">
454 <?php if ( $this->data['rtl'] ): ?>
455 <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->skin->getSkinStylePath( 'images/search-rtl.png' ) ) ); ?>
456 <?php endif; ?>
457 <?php echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?>
458 <?php if ( !$this->data['rtl'] ): ?>
459 <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->skin->getSkinStylePath( 'images/search-ltr.png' ) ) ); ?>
460 <?php endif; ?>
461 </div>
462 <?php else: ?>
463 <?php echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?>
464 <?php echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?>
465 <?php echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?>
466 <?php endif; ?>
467 </form>
468 </div>
469 <?php
470
471 break;
472 }
473 echo "\n<!-- /{$name} -->\n";
474 }
475 }
476 }