Foreground.skin.php 10 KB

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