Foreground.skin.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. /**
  3. * Skin file for Foreground
  4. *
  5. * @file
  6. * @ingroup Skins
  7. */
  8. class Skinforeground extends SkinTemplate {
  9. public $skinname = 'foreground', $stylename = 'foreground', $template = 'foregroundTemplate', $useHeadElement = true;
  10. public function setupSkinUserCss(OutputPage $out) {
  11. parent::setupSkinUserCss($out);
  12. global $wgForegroundFeatures;
  13. $wgForegroundFeaturesDefaults = array(
  14. 'showActionsForAnon' => true,
  15. 'NavWrapperType' => 'divonly',
  16. 'showHelpUnderTools' => true,
  17. 'showRecentChangesUnderTools' => true,
  18. 'IeEdgeCode' => 1
  19. );
  20. foreach ($wgForegroundFeaturesDefaults as $fgOption => $fgOptionValue) {
  21. if ( !isset($wgForegroundFeatures[$fgOption]) ) {
  22. $wgForegroundFeatures[$fgOption] = $fgOptionValue;
  23. }
  24. }
  25. switch ($wgForegroundFeatures['IeEdgeCode']) {
  26. case 1:
  27. $out->addHeadItem('ie-meta', '<meta http-equiv="X-UA-Compatible" content="IE=edge" />');
  28. break;
  29. case 2:
  30. if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
  31. header('X-UA-Compatible: IE=edge');
  32. break;
  33. }
  34. $out->addModuleStyles('skins.foreground');
  35. }
  36. public function initPage( OutputPage $out ) {
  37. global $wgLocalStylePath;
  38. parent::initPage($out);
  39. $viewport_meta = 'width=device-width, user-scalable=yes, initial-scale=1.0';
  40. $out->addMeta('viewport', $viewport_meta);
  41. $out->addModuleScripts('skins.foreground');
  42. }
  43. }
  44. class foregroundTemplate extends BaseTemplate {
  45. public function execute() {
  46. global $wgUser;
  47. global $wgForegroundFeatures;
  48. wfSuppressWarnings();
  49. $this->html('headelement');
  50. switch ($wgForegroundFeatures['NavWrapperType']) {
  51. case '0':
  52. break;
  53. case 'divonly':
  54. echo "<div id='navwrapper'>";
  55. break;
  56. default:
  57. echo "<div id='navwrapper' class='". $wgForegroundFeatures['NavWrapperType']. "'>";
  58. break;
  59. }
  60. ?>
  61. <!-- START FOREGROUNDTEMPLATE -->
  62. <nav class="top-bar">
  63. <ul class="title-area">
  64. <li class="name"><h1><a href="<?php echo $this->data['nav_urls']['mainpage']['href']; ?>"><?php echo $this->text('sitename'); ?></a></h1></li>
  65. <li class="toggle-topbar menu-icon"><a href="#"><span><?php echo wfMessage( 'foreground-menutitle' )->text(); ?></span></a></li>
  66. </ul>
  67. <section class="top-bar-section">
  68. <ul id="top-bar-left" class="left">
  69. <li class="divider"></li>
  70. <?php foreach ( $this->getSidebar() as $boxName => $box ) { if ( ($box['header'] != wfMessage( 'toolbox' )->text()) ) { ?>
  71. <li class="has-dropdown active" id='<?php echo Sanitizer::escapeId( $box['id'] ) ?>'<?php echo Linker::tooltip( $box['id'] ) ?>>
  72. <a href="#"><?php echo htmlspecialchars( $box['header'] ); ?></a>
  73. <?php if ( is_array( $box['content'] ) ) { ?>
  74. <ul class="dropdown">
  75. <?php foreach ( $box['content'] as $key => $item ) { echo $this->makeListItem( $key, $item ); } ?>
  76. </ul>
  77. <?php } } ?>
  78. <?php } ?>
  79. </ul>
  80. <ul id="top-bar-right" class="right">
  81. <li class="has-form">
  82. <form action="<?php $this->text( 'wgScript' ); ?>" id="searchform" class="mw-search">
  83. <div class="row collapse">
  84. <div class="small-8 columns">
  85. <?php echo $this->makeSearchInput(array('placeholder' => wfMessage('searchsuggest-search')->text(), 'id' => 'searchInput') ); ?>
  86. </div>
  87. <div class="small-4 columns">
  88. <button type="submit" class="button search"><?php echo wfMessage( 'search' )->text() ?></button>
  89. </div>
  90. </div>
  91. </form>
  92. </li>
  93. <li class="divider show-for-small"></li>
  94. <li class="has-form">
  95. <li class="has-dropdown active"><a href="#"><i class="fa fa-cogs"></i></a>
  96. <ul id="toolbox-dropdown" class="dropdown">
  97. <?php foreach ( $this->getToolbox() as $key => $item ) { echo $this->makeListItem($key, $item); } ?>
  98. <?php if ($wgForegroundFeatures['showRecentChangesUnderTools']): ?><li id="n-recentchanges"><?php echo Linker::specialLink('Recentchanges') ?></li><?php endif; ?>
  99. <?php if ($wgForegroundFeatures['showHelpUnderTools']): ?><li id="n-help" <?php echo Linker::tooltip('help') ?>><a href="/wiki/Help:Contents"><?php echo wfMessage( 'help' )->text() ?></a></li><?php endif; ?>
  100. </ul>
  101. </li>
  102. <?php if ($wgUser->isLoggedIn()): ?>
  103. <li id="personal-tools-dropdown" class="has-dropdown active"><a href="#"><i class="fa fa-user"></i></a>
  104. <ul class="dropdown">
  105. <?php foreach ( $this->getPersonalTools() as $key => $item ) { echo $this->makeListItem($key, $item); } ?>
  106. </ul>
  107. </li>
  108. <?php else: ?>
  109. <li>
  110. <?php if (isset($this->data['personal_urls']['anonlogin'])): ?>
  111. <a href="<?php echo $this->data['personal_urls']['anonlogin']['href']; ?>"><?php echo wfMessage( 'login' )->text() ?></a>
  112. <?php elseif (isset($this->data['personal_urls']['login'])): ?>
  113. <a href="<?php echo htmlspecialchars($this->data['personal_urls']['login']['href']); ?>"><?php echo wfMessage( 'login' )->text() ?></a>
  114. <?php else: ?>
  115. <?php echo Linker::link(Title::newFromText('Special:UserLogin'), wfMessage( 'login' )->text()); ?>
  116. <?php endif; ?>
  117. </li>
  118. <?php endif; ?>
  119. </ul>
  120. </section>
  121. </nav>
  122. <?php if ($wgForegroundFeatures['NavWrapperType'] != '0') echo "</div>"; ?>
  123. <div id="page-content">
  124. <div class="row">
  125. <div class="large-12 columns">
  126. <!--[if lt IE 9]>
  127. <div id="siteNotice" class="sitenotice panel radius"><?php echo $this->text('sitename') . ' '. wfMessage( 'foreground-browsermsg' )->text(); ?></div>
  128. <![endif]-->
  129. <?php if ( $this->data['sitenotice'] ) { ?><div id="siteNotice" class="sitenotice panel radius"><?php $this->html( 'sitenotice' ); ?></div><?php } ?>
  130. <?php if ( $this->data['newtalk'] ) { ?><div id="usermessage" class="newtalk panel radius"><?php $this->html( 'newtalk' ); ?></div><?php } ?>
  131. </div>
  132. </div>
  133. <div id="mw-js-message" style="display:none;"></div>
  134. <div class="row">
  135. <div id="p-cactions" class="large-12 columns">
  136. <?php if ($wgUser->isLoggedIn() || $wgForegroundFeatures['showActionsForAnon']): ?>
  137. <a href="#" data-dropdown="drop1" class="button dropdown small secondary radius"><i class="fa fa-cog"><span class="show-for-medium-up">&nbsp;<?php echo wfMessage( 'actions' )->text() ?></span></i></a>
  138. <ul id="drop1" class="views large-12 columns f-dropdown">
  139. <?php foreach( $this->data['content_actions'] as $key => $item ) { echo preg_replace(array('/\sprimary="1"/','/\scontext="[a-z]+"/','/\srel="archives"/'),'',$this->makeListItem($key, $item)); } ?>
  140. <?php wfRunHooks( SkinTemplateToolboxEnd, array( &$this, true ) ); ?>
  141. </ul>
  142. <?php if ($wgUser->isLoggedIn()): ?>
  143. <div id="echo-notifications"></div>
  144. <?php endif; ?>
  145. <?php endif;
  146. $namespace = str_replace('_', ' ', $this->getSkin()->getTitle()->getNsText());
  147. $displaytitle = $this->data['title'];
  148. if (!empty($namespace)) {
  149. $pagetitle = $this->getSkin()->getTitle();
  150. $newtitle = str_replace($namespace.':', '', $pagetitle);
  151. $displaytitle = str_replace($pagetitle, $newtitle, $displaytitle);
  152. ?><h4 class="namespace label"><?php print $namespace; ?></h4><?php } ?>
  153. <h2 class="title"><?php print $displaytitle; ?></h2>
  154. <?php if ( $this->data['isarticle'] ) { ?><h3 id="tagline"><?php $this->msg( 'tagline' ) ?></h3><?php } ?>
  155. <h5 class="subtitle"><?php $this->html('subtitle') ?></h5>
  156. <div class="clear_both"></div>
  157. <?php $this->html('bodytext') ?>
  158. <div class="group"><?php $this->html('catlinks'); ?></div>
  159. <?php $this->html('dataAfterContent'); ?>
  160. </div>
  161. </div>
  162. <footer class="row">
  163. <ul class="large-12 columns">
  164. <?php foreach ( $this->getFooterLinks( "flat" ) as $key ) { ?>
  165. <li id="footer-<?php echo $key ?>"><?php $this->html( $key ) ?></li>
  166. <?php } ?>
  167. </ul>
  168. <ul> <?php foreach ( $this->getFooterIcons( "nocopyright" ) as $blockName => $footerIcons ) { ?>
  169. <li class="<?php echo $blockName ?>"><?php foreach ( $footerIcons as $icon ) { ?>
  170. <?php echo $this->getSkin()->makeFooterIcon( $icon, 'withoutImage' ); ?>
  171. <?php } ?>
  172. </li>
  173. <?php } ?>
  174. </ul>
  175. </footer>
  176. </div>
  177. <?php $this->printTrail(); ?>
  178. </body>
  179. </html>
  180. <?php
  181. wfRestoreWarnings();
  182. }
  183. }
  184. ?>