| 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__)."/cppreference/resourcemodules.php"); |
| 16 |
|
| 17 |
/** |
| 18 |
* SkinTemplate class for Cppreference skin |
| 19 |
* @ingroup Skins |
| 20 |
*/ |
| 21 |
class SkinCppreference extends SkinTemplate { |
| 22 |
|
| 23 |
var $skinname = 'cppreference', $stylename = 'cppreference', |
| 24 |
$template = 'CppreferenceTemplate', $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.cppreference' ); |
| 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.cppreference' ); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* QuickTemplate class for Cppreference skin |
| 61 |
* @ingroup Skins |
| 62 |
*/ |
| 63 |
class CppreferenceTemplate 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 |
<div id="cpp-page-base"> |
| 136 |
<!-- header --> |
| 137 |
<div id="mw-head" class="noprint"> |
| 138 |
<div id="cpp-head-first"> |
| 139 |
<h5><a href="/"><?php global $wgSitename; echo $wgSitename;?></a></h5> |
| 140 |
<div id="cpp-head-search"> |
| 141 |
<?php $this->renderNavigation( 'SEARCH' ); ?> |
| 142 |
</div> |
| 143 |
<div id="cpp-head-personal"> |
| 144 |
<?php $this->renderNavigation( 'PERSONAL' ); ?> |
| 145 |
</div> |
| 146 |
|
| 147 |
</div> |
| 148 |
<div id="cpp-head-second"> |
| 149 |
<div id="cpp-head-tools-left"> |
| 150 |
<?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?> |
| 151 |
</div> |
| 152 |
<div id="cpp-head-tools-right"> |
| 153 |
<?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS' ) ); ?> |
| 154 |
</div> |
| 155 |
</div> |
| 156 |
</div> |
| 157 |
<!-- /header --> |
| 158 |
<!-- content --> |
| 159 |
<div id="content"> |
| 160 |
<a id="top"></a> |
| 161 |
<div id="mw-js-message" style="display:none;"<?php $this->html( 'userlangattributes' ) ?>></div> |
| 162 |
<?php if ( $this->data['sitenotice'] ): ?> |
| 163 |
<!-- sitenotice --> |
| 164 |
<div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div> |
| 165 |
<!-- /sitenotice --> |
| 166 |
<?php endif; ?> |
| 167 |
<!-- firstHeading --> |
| 168 |
<h1 id="firstHeading" class="firstHeading"><?php $this->html( 'title' ) ?></h1> |
| 169 |
<!-- /firstHeading --> |
| 170 |
<!-- bodyContent --> |
| 171 |
<div id="bodyContent"> |
| 172 |
<?php if ( $this->data['isarticle'] ): ?> |
| 173 |
<!-- tagline --> |
| 174 |
<div id="siteSub"><?php $this->msg( 'tagline' ) ?></div> |
| 175 |
<!-- /tagline --> |
| 176 |
<?php endif; ?> |
| 177 |
<!-- subtitle --> |
| 178 |
<div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' ) ?></div> |
| 179 |
<!-- /subtitle --> |
| 180 |
<?php if ( $this->data['undelete'] ): ?> |
| 181 |
<!-- undelete --> |
| 182 |
<div id="contentSub2"><?php $this->html( 'undelete' ) ?></div> |
| 183 |
<!-- /undelete --> |
| 184 |
<?php endif; ?> |
| 185 |
<?php if( $this->data['newtalk'] ): ?> |
| 186 |
<!-- newtalk --> |
| 187 |
<div class="usermessage"><?php $this->html( 'newtalk' ) ?></div> |
| 188 |
<!-- /newtalk --> |
| 189 |
<?php endif; ?> |
| 190 |
<!-- bodycontent --> |
| 191 |
<?php $this->html( 'bodycontent' ) ?> |
| 192 |
<!-- /bodycontent --> |
| 193 |
<?php if ( $this->data['printfooter'] ): ?> |
| 194 |
<!-- printfooter --> |
| 195 |
<div class="printfooter"> |
| 196 |
<?php $this->html( 'printfooter' ); ?> |
| 197 |
</div> |
| 198 |
<!-- /printfooter --> |
| 199 |
<?php endif; ?> |
| 200 |
<?php if ( $this->data['catlinks'] ): ?> |
| 201 |
<!-- catlinks --> |
| 202 |
<?php $this->html( 'catlinks' ); ?> |
| 203 |
<!-- /catlinks --> |
| 204 |
<?php endif; ?> |
| 205 |
<?php if ( $this->data['dataAfterContent'] ): ?> |
| 206 |
<!-- dataAfterContent --> |
| 207 |
<?php $this->html( 'dataAfterContent' ); ?> |
| 208 |
<!-- /dataAfterContent --> |
| 209 |
<?php endif; ?> |
| 210 |
<div class="visualClear"></div> |
| 211 |
<!-- debughtml --> |
| 212 |
<?php $this->html( 'debughtml' ); ?> |
| 213 |
<!-- /debughtml --> |
| 214 |
</div> |
| 215 |
<!-- /bodyContent --> |
| 216 |
</div> |
| 217 |
<!-- /content --> |
| 218 |
<!-- footer --> |
| 219 |
<div id="footer"<?php $this->html( 'userlangattributes' ) ?>> |
| 220 |
<?php $this->renderBottomNavigation();?> |
| 221 |
<?php $this->renderToolbox(); ?> |
| 222 |
<?php $this->renderFooter(); ?> |
| 223 |
</div> |
| 224 |
<!-- /footer --> |
| 225 |
</div> |
| 226 |
<?php $this->printTrail(); ?> |
| 227 |
</body> |
| 228 |
</html> |
| 229 |
<?php |
| 230 |
} |
| 231 |
|
| 232 |
private function renderToolbox() |
| 233 |
{ |
| 234 |
$name = 'tb'; |
| 235 |
|
| 236 |
$content = $this->getToolbox(); |
| 237 |
|
| 238 |
$msg = 'toolbox'; |
| 239 |
$msg_obj = wfMessage( $msg ); |
| 240 |
$message = htmlspecialchars($msg_obj->exists() ? $msg_obj->text() : $msg); |
| 241 |
|
| 242 |
?> |
| 243 |
<div id="cpp-toolbox"> |
| 244 |
<h5><span><?php echo $message; ?></span><a href="#"></a></h5> |
| 245 |
<ul> |
| 246 |
<?php foreach( $content as $key => $val ): |
| 247 |
echo $this->makeListItem( $key, $val ); |
| 248 |
endforeach; |
| 249 |
wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true )); |
| 250 |
?> |
| 251 |
</ul> |
| 252 |
</div> |
| 253 |
<?php |
| 254 |
} |
| 255 |
|
| 256 |
private function renderBottomNavigation() |
| 257 |
{ |
| 258 |
$content = $this->data['sidebar']['navigation']; |
| 259 |
|
| 260 |
$msg = 'navigation'; |
| 261 |
$msg_obj = wfMessage( $msg ); |
| 262 |
$message = htmlspecialchars($msg_obj->exists() ? $msg_obj->text() : $msg); |
| 263 |
|
| 264 |
?> |
| 265 |
<div id="cpp-navigation"> |
| 266 |
<h5><?php echo $message; ?></h5> |
| 267 |
<ul> |
| 268 |
<?php foreach( $content as $key => $val ): |
| 269 |
echo $this->makeListItem( $key, $val ); |
| 270 |
endforeach; ?> |
| 271 |
</ul> |
| 272 |
</div> |
| 273 |
<?php |
| 274 |
} |
| 275 |
|
| 276 |
private function renderLanguages() |
| 277 |
{ |
| 278 |
$content = $this->data['language_urls']; |
| 279 |
|
| 280 |
$msg = 'otherlanguages'; |
| 281 |
$msg_obj = wfMessage( $msg ); |
| 282 |
$message = htmlspecialchars($msg_obj->exists() ? $msg_obj->text() : $msg); |
| 283 |
|
| 284 |
?> |
| 285 |
<div id="cpp-languages"> |
| 286 |
<div><ul><li><?php echo $message; ?></li></ul></div> |
| 287 |
<div><ul> |
| 288 |
<?php foreach( $content as $key => $val ): |
| 289 |
echo $this->makeListItem( $key, $val ); |
| 290 |
endforeach; ?> |
| 291 |
</ul></div> |
| 292 |
</div> |
| 293 |
<?php |
| 294 |
} |
| 295 |
|
| 296 |
private function renderFooter() |
| 297 |
{ |
| 298 |
if ( $this->data['language_urls'] ) { $this->renderLanguages(); } |
| 299 |
foreach( $this->getFooterLinks() as $category => $links ): ?> |
| 300 |
<ul id="footer-<?php echo $category ?>"> |
| 301 |
<?php foreach( $links as $link ): ?> |
| 302 |
<li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li> |
| 303 |
<?php endforeach; ?> |
| 304 |
</ul> |
| 305 |
<?php endforeach; ?> |
| 306 |
<?php $footericons = $this->getFooterIcons("icononly"); |
| 307 |
if ( count( $footericons ) > 0 ): ?> |
| 308 |
<ul id="footer-icons" class="noprint"> |
| 309 |
<?php foreach ( $footericons as $blockName => $footerIcons ): ?> |
| 310 |
<li id="footer-<?php echo htmlspecialchars( $blockName ); ?>ico"> |
| 311 |
<?php foreach ( $footerIcons as $icon ): ?> |
| 312 |
<?php echo $this->skin->makeFooterIcon( $icon ); ?> |
| 313 |
<?php endforeach; ?> |
| 314 |
</li> |
| 315 |
<?php endforeach; ?> |
| 316 |
</ul> |
| 317 |
<?php endif; ?> |
| 318 |
<div style="clear:both"> |
| 319 |
</div> |
| 320 |
<?php |
| 321 |
} |
| 322 |
|
| 323 |
/** |
| 324 |
* Render one or more navigations elements by name, automatically reveresed |
| 325 |
* when UI is in RTL mode |
| 326 |
*/ |
| 327 |
private function renderNavigation( $elements ) { |
| 328 |
global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser, $wgLang; |
| 329 |
|
| 330 |
// If only one element was given, wrap it in an array, allowing more |
| 331 |
// flexible arguments |
| 332 |
if ( !is_array( $elements ) ) { |
| 333 |
$elements = array( $elements ); |
| 334 |
// If there's a series of elements, reverse them when in RTL mode |
| 335 |
} elseif ( $wgLang->isRTL() ) { |
| 336 |
$elements = array_reverse( $elements ); |
| 337 |
} |
| 338 |
// Render elements |
| 339 |
foreach ( $elements as $name => $element ) { |
| 340 |
echo "\n<!-- {$name} -->\n"; |
| 341 |
switch ( $element ) { |
| 342 |
case 'NAMESPACES': |
| 343 |
?> |
| 344 |
<div id="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>"> |
| 345 |
<h5><?php $this->msg( 'namespaces' ) ?></h5> |
| 346 |
<ul<?php $this->html( 'userlangattributes' ) ?>> |
| 347 |
<?php foreach ( $this->data['namespace_urls'] as $link ): ?> |
| 348 |
<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> |
| 349 |
<?php endforeach; ?> |
| 350 |
</ul> |
| 351 |
</div> |
| 352 |
<?php |
| 353 |
break; |
| 354 |
case 'VARIANTS': |
| 355 |
?> |
| 356 |
<div id="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>"> |
| 357 |
<?php if ( $wgVectorShowVariantName ): ?> |
| 358 |
<h4> |
| 359 |
<?php foreach ( $this->data['variant_urls'] as $link ): ?> |
| 360 |
<?php if ( stripos( $link['attributes'], 'selected' ) !== false ): ?> |
| 361 |
<?php echo htmlspecialchars( $link['text'] ) ?> |
| 362 |
<?php endif; ?> |
| 363 |
<?php endforeach; ?> |
| 364 |
</h4> |
| 365 |
<?php endif; ?> |
| 366 |
<h5><span><?php $this->msg( 'variants' ) ?></span><a href="#"></a></h5> |
| 367 |
<div class="menu"> |
| 368 |
<ul<?php $this->html( 'userlangattributes' ) ?>> |
| 369 |
<?php foreach ( $this->data['variant_urls'] as $link ): ?> |
| 370 |
<li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li> |
| 371 |
<?php endforeach; ?> |
| 372 |
</ul> |
| 373 |
</div> |
| 374 |
</div> |
| 375 |
<?php |
| 376 |
break; |
| 377 |
case 'VIEWS': |
| 378 |
?> |
| 379 |
<div id="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>"> |
| 380 |
<h5><?php $this->msg('views') ?></h5> |
| 381 |
<ul<?php $this->html('userlangattributes') ?>> |
| 382 |
<?php foreach ( $this->data['view_urls'] as $link ): ?> |
| 383 |
<li<?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php |
| 384 |
// $link['text'] can be undefined - bug 27764 |
| 385 |
if ( array_key_exists( 'text', $link ) ) { |
| 386 |
echo array_key_exists( 'img', $link ) ? '<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] ); |
| 387 |
} |
| 388 |
?></a></span></li> |
| 389 |
<?php endforeach; ?> |
| 390 |
</ul> |
| 391 |
</div> |
| 392 |
<?php |
| 393 |
break; |
| 394 |
case 'ACTIONS': |
| 395 |
?> |
| 396 |
<div id="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>"> |
| 397 |
<h5><span><?php $this->msg( 'actions' ) ?></span><a href="#"></a></h5> |
| 398 |
<div class="menu"> |
| 399 |
<ul<?php $this->html( 'userlangattributes' ) ?>> |
| 400 |
<?php foreach ( $this->data['action_urls'] as $link ): ?> |
| 401 |
<li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li> |
| 402 |
<?php endforeach; ?> |
| 403 |
</ul> |
| 404 |
</div> |
| 405 |
</div> |
| 406 |
<?php |
| 407 |
break; |
| 408 |
case 'PERSONAL': |
| 409 |
?> |
| 410 |
<div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>"> |
| 411 |
<?php |
| 412 |
$tools = $this->getPersonalTools(); |
| 413 |
$item = reset($tools); |
| 414 |
$key = key($tools); |
| 415 |
array_shift($tools); |
| 416 |
|
| 417 |
echo $this->makeListItem( $key, $item, array( 'tag' => 'span' ) ); |
| 418 |
if ( count( $tools ) > 0 ) { |
| 419 |
?> |
| 420 |
<div class="menu"> |
| 421 |
<ul<?php $this->html( 'userlangattributes' ) ?>> |
| 422 |
<?php foreach( $tools as $key => $item ) { |
| 423 |
echo $this->makeListItem( $key, $item ); |
| 424 |
} ?> |
| 425 |
</ul> |
| 426 |
</div> |
| 427 |
<?php } ?> |
| 428 |
</div> |
| 429 |
<?php |
| 430 |
break; |
| 431 |
case 'SEARCH': |
| 432 |
?> |
| 433 |
<div id="p-search"> |
| 434 |
<h5<?php $this->html( 'userlangattributes' ) ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5> |
| 435 |
<form action="<?php $this->text( 'wgScript' ) ?>" id="searchform"> |
| 436 |
<input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/> |
| 437 |
<?php if ( true ): ?> |
| 438 |
<div id="simpleSearch"> |
| 439 |
<?php if ( $this->data['rtl'] ): ?> |
| 440 |
<?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->skin->getSkinStylePath( 'images/search-rtl.png' ) ) ); ?> |
| 441 |
<?php endif; ?> |
| 442 |
<?php echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?> |
| 443 |
<?php if ( !$this->data['rtl'] ): ?> |
| 444 |
<?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->skin->getSkinStylePath( 'images/search-ltr.png' ) ) ); ?> |
| 445 |
<?php endif; ?> |
| 446 |
</div> |
| 447 |
<?php else: ?> |
| 448 |
<?php echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?> |
| 449 |
<?php echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?> |
| 450 |
<?php echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?> |
| 451 |
<?php endif; ?> |
| 452 |
</form> |
| 453 |
</div> |
| 454 |
<?php |
| 455 |
|
| 456 |
break; |
| 457 |
} |
| 458 |
echo "\n<!-- /{$name} -->\n"; |
| 459 |
} |
| 460 |
} |
| 461 |
} |