Foreground.skin.php 8.5 KB

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