Guest User

Untitled

a guest
Sep 10th, 2015
59
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. * @package Balance
  4. * @author YOOtheme http://www.yootheme.com
  5. * @copyright Copyright (C) YOOtheme GmbH
  6. * @license http://www.gnu.org/licenses/gpl.html GNU/GPL
  7. */
  8.  
  9. // generate css for layout
  10. $css[] = sprintf('body { min-width: %dpx; }', $this['config']->get('template_width'));
  11. $css[] .= sprintf('.wrapper { width: %dpx; }', $this['config']->get('template_width'));
  12.  
  13. // generate css for 3-column-layout
  14. $sidebar_a = '';
  15. $sidebar_b = '';
  16. $maininner_width = intval($this['config']->get('template_width'));
  17. $sidebar_a_width = intval($this['config']->get('sidebar-a_width'));
  18. $sidebar_b_width = intval($this['config']->get('sidebar-b_width'));
  19. $rtl = $this['config']->get('direction') == 'rtl';
  20. $body_config = array();
  21.  
  22. // set widths
  23. if ($this['modules']->count('sidebar-a')) {
  24. $sidebar_a = $this['config']->get('sidebar-a');
  25. $maininner_width -= $sidebar_a_width;
  26. $css[] = sprintf('#sidebar-a { width: %dpx; }', $sidebar_a_width);
  27. }
  28.  
  29. if ($this['modules']->count('sidebar-b')) {
  30. $sidebar_b = $this['config']->get('sidebar-b');
  31. $maininner_width -= $sidebar_b_width;
  32. $css[] = sprintf('#sidebar-b { width: %dpx; }', $sidebar_b_width);
  33. }
  34.  
  35. $css[] = sprintf('#maininner { width: %dpx; }', $maininner_width);
  36.  
  37. // all sidebars right
  38. if (($sidebar_a == 'right' || !$sidebar_a) && ($sidebar_b == 'right' || !$sidebar_b)) {
  39. $sidebar_classes = 'sidebar-a-right sidebar-b-right';
  40.  
  41. // all sidebars left
  42. } else if (($sidebar_a == 'left' || !$sidebar_a) && ($sidebar_b == 'left' || !$sidebar_b)) {
  43. $sidebar_classes = 'sidebar-a-left sidebar-b-left';
  44. $css[] = sprintf('#maininner { float: %s; }', $rtl ? 'left' : 'right');
  45.  
  46. // sidebar-a left and not sidebar-b
  47. } else if ($sidebar_a == 'left') {
  48. $sidebar_classes = 'sidebar-a-left sidebar-b-right';
  49. $css[] = '#maininner, #sidebar-a { position: relative; }';
  50. $css[] = sprintf('#maininner { %s: %dpx; }', $rtl ? 'right' : 'left', $sidebar_a_width);
  51. $css[] = sprintf('#sidebar-a { %s: -%dpx; }', $rtl ? 'right' : 'left', $maininner_width);
  52.  
  53. // sidebar-b left and not sidebar-a
  54. } else if ($sidebar_b == 'left') {
  55. $sidebar_classes = 'sidebar-a-right sidebar-b-left';
  56. $css[] = '#maininner, #sidebar-a, #sidebar-b { position: relative; }';
  57. $css[] = sprintf('#maininner, #sidebar-a { %s: %dpx; }', $rtl ? 'right' : 'left', $sidebar_b_width);
  58. $css[] = sprintf('#sidebar-b { %s: -%dpx; }', $rtl ? 'right' : 'left', $maininner_width + $sidebar_a_width);
  59. }
  60.  
  61. // generate css for dropdown menu
  62. foreach (array(1 => '.dropdown', 2 => '.columns2', 3 => '.columns3', 4 => '.columns4') as $i => $class) {
  63. $css[] = sprintf('#menu %s { width: %dpx; }', $class, $i * intval($this['config']->get('menu_width')));
  64. }
  65.  
  66. // load css
  67. $this['asset']->addFile('css', 'css:base.css');
  68. $this['asset']->addFile('css', 'css:layout.css');
  69. $this['asset']->addFile('css', 'css:menus.css');
  70. $this['asset']->addString('css', implode("\n", $css));
  71. $this['asset']->addFile('css', 'css:modules.css');
  72. $this['asset']->addFile('css', 'css:tools.css');
  73. $this['asset']->addFile('css', 'css:system.css');
  74. $this['asset']->addFile('css', 'css:extensions.css');
  75. $this['asset']->addFile('css', 'css:custom.css');
  76. if ($this['config']->get('animations')) $this['asset']->addFile('css', 'css:animations.css');
  77. if (($background = $this['config']->get('background')) && $this['path']->path("css:/background/$background.css")) { $this['asset']->addFile('css', "css:/background/$background.css"); }
  78. if (($font = $this['config']->get('font1')) && $this['path']->path("css:/font1/$font.css")) { $this['asset']->addFile('css', "css:/font1/$font.css"); }
  79. if (($font = $this['config']->get('font2')) && $this['path']->path("css:/font2/$font.css")) { $this['asset']->addFile('css', "css:/font2/$font.css"); }
  80. if (($font = $this['config']->get('font3')) && $this['path']->path("css:/font3/$font.css")) { $this['asset']->addFile('css', "css:/font3/$font.css"); }
  81. $this['asset']->addFile('css', 'css:style.css');
  82. if ($this['config']->get('direction') == 'rtl') $this['asset']->addFile('css', 'css:rtl.css');
  83. $this['asset']->addFile('css', 'css:print.css');
  84.  
  85. // load fonts
  86. $http = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
  87. $fonts = array(
  88. 'bebas' => 'template:fonts/bebas.css',
  89. 'droidsans' => 'template:fonts/droidsans.css',
  90. 'yanonekaffeesatz' => $http.'://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,light',
  91. 'kreon' => $http.'://fonts.googleapis.com/css?family=Kreon:400,300',
  92. 'mavenpro' => $http.'://fonts.googleapis.com/css?family=Maven+Pro:400,500,700',
  93. 'metrophobic' => 'template:fonts/metrophobic.css',
  94. 'nobile' => $http.'://fonts.googleapis.com/css?family=Nobile:400,700italic,700,400italic',
  95. 'aldrich' => $http.'://fonts.googleapis.com/css?family=Aldrich');
  96.  
  97. foreach (array_unique(array($this['config']->get('font1'), $this['config']->get('font2'), $this['config']->get('font3'))) as $font) {
  98. if (isset($fonts[$font])) {
  99. $this['asset']->addFile('css', $fonts[$font]);
  100. }
  101. }
  102.  
  103. // set body css classes
  104. $body_classes = $sidebar_classes.' ';
  105. $body_classes .= $this['system']->isBlog() ? 'isblog ' : 'noblog ';
  106. $body_classes .= $this['config']->get('page_class');
  107.  
  108. $this['config']->set('body_classes', $body_classes);
  109.  
  110. // add social buttons
  111. $body_config['twitter'] = (int) $this['config']->get('twitter', 0);
  112. $body_config['plusone'] = (int) $this['config']->get('plusone', 0);
  113. $body_config['facebook'] = (int) $this['config']->get('facebook', 0);
  114.  
  115. // add javascripts
  116. $this['asset']->addFile('js', 'js:warp.js');
  117. $this['asset']->addFile('js', 'js:accordionmenu.js');
  118. $this['asset']->addFile('js', 'js:dropdownmenu.js');
  119. $this['asset']->addFile('js', 'js:template.js');
  120.  
  121. // internet explorer
  122. if ($this['useragent']->browser() == 'msie') {
  123.  
  124. $filters = array('CSSImportResolver', 'CSSRewriteURL', 'CSSCompressor');
  125.  
  126. // prepare assets
  127. $assets['ie.css'] = $this['asset']->cache('ie.css', $this['asset']->createFile('css:ie.css'), $filters);
  128. $assets['ie7.css'] = $this['asset']->cache('ie7.css', $this['asset']->createFile('css:ie7.css'), $filters);
  129. $assets['ie8.css'] = $this['asset']->cache('ie8.css', $this['asset']->createFile('css:ie8.css'), $filters);
  130.  
  131. // add conditional comments
  132. $head[] = sprintf('<!--[if lte IE 8]>%s<script src="%s"></script><![endif]-->', ($url = $assets['ie.css']->getUrl()) ? sprintf('<link rel="stylesheet" href="%s" />', $url) : sprintf('<style>%s</style>', $assets['ie.css']->getContent($this['assetfilter']->create($filters))), $this['path']->url('js:html5.js'));
  133. $head[] = sprintf('<!--[if IE 7]>%s<![endif]-->', ($url = $assets['ie7.css']->getUrl()) ? sprintf('<link rel="stylesheet" href="%s" />', $url) : sprintf('<style>%s</style>', $assets['ie7.css']->getContent($this['assetfilter']->create($filters))));
  134. $head[] = sprintf('<!--[if IE 8]>%s<![endif]-->', ($url = $assets['ie8.css']->getUrl()) ? sprintf('<link rel="stylesheet" href="%s" />', $url) : sprintf('<style>%s</style>', $assets['ie8.css']->getContent($this['assetfilter']->create($filters))));
  135.  
  136. }
  137.  
  138. // add $head
  139. if (isset($head)) {
  140. $this['template']->set('head', implode("\n", $head));
  141. }
  142.  
  143. $body_config["style"] = $this['config']->get('style');
  144.  
  145. $this['config']->set('body_config', json_encode($body_config));
RAW Paste Data