Foreground.skin.php 8.6 KB

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