Foreground.skin.php 10 KB

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