Foreground.skin.php 11 KB

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