Guest User

Untitled

a guest
Jun 23rd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.81 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * @file
  5. * NewsFlash template.php
  6. *
  7. */
  8.  
  9. // get setted color style and save it in a cookie
  10. function get_newsflash_style() {
  11. $style = theme_get_setting('newsflash_style');
  12. if (!$style) {
  13. $style = 'blue';
  14. }
  15. if (theme_get_setting('newsflash_pickstyle')) {
  16. if (isset($_COOKIE["newsflashstyle"])) {
  17. $style = $_COOKIE["newsflashstyle"];
  18. }
  19. }
  20. return $style;
  21. }
  22.  
  23. /**
  24. * Implements hook_preprocess_html()
  25. *
  26. */
  27. function newsflash_preprocess_html(&$variables) {
  28. // set the color style themes
  29. $style = get_newsflash_style();
  30. drupal_add_css(path_to_theme() . '/style.css'); //is not settet in info file because it's loades to late
  31. drupal_add_css(path_to_theme() . '/css/' . $style . '.css');
  32.  
  33. if (theme_get_setting('newsflash_suckerfish')) {
  34. drupal_add_css(path_to_theme() . '/css/suckerfish_' . $style . '.css');
  35. }
  36. else {
  37. drupal_add_css(path_to_theme() . '/css/nosuckerfish.css');
  38. }
  39.  
  40. // set for custome css
  41. if (theme_get_setting('newsflash_uselocalcontent')) {
  42. $local_content = theme_get_setting('newsflash_localcontentfile');
  43. if (file_exists($local_content)) {
  44. drupal_add_css($local_content);
  45. }
  46. }
  47.  
  48. // add ie css fixing some px settings in css
  49. drupal_add_css
  50. (
  51. path_to_theme() . '/css/ie.css',
  52. array
  53. (
  54. 'group' => CSS_THEME,
  55. 'browsers' => array
  56. (
  57. 'IE' => 'lte IE 7',
  58. '!IE' => FALSE
  59. ),
  60. 'preprocess' => FALSE
  61. )
  62. );
  63. if (theme_get_setting('newsflash_pickstyle')) {
  64. drupal_add_js(path_to_theme() . '/js/pickstyle.js');
  65. }
  66. }
  67. /**
  68. * Implements hook_preprocess_page()
  69. */
  70. function newsflash_preprocess_page(&$variables) {
  71. if (theme_get_setting('newsflash_themelogo')) {
  72. $variables['logo'] = base_path() . path_to_theme() . '/images/' . get_newsflash_style() . '/logo.png';
  73. }
  74. }
  75. // in sukerfishmenu, searchbox. and header region visually hide block titles.
  76. function newsflash_preprocess_block(&$variables) {
  77. // In the suckerfishmenu region visually hide block titles if use suckerfish enabled.
  78. if (theme_get_setting('newsflash_suckerfish') && $variables['block']->region == 'suckerfish') {
  79. $variables['title_attributes_array']['class'][] = 'element-invisible';
  80. }
  81. if ($variables['block']->region == 'header') {
  82. $variables['title_attributes_array']['class'][] = 'element-invisible';
  83. }
  84. //adds in blocks title the class .title
  85. $variables['title_attributes_array']['class'][] = 'title';
  86. }
  87.  
  88. /**
  89. * Implements hook_process_html()
  90. */
  91. function newsflash_process_html(&$variables) {
  92. $variables['styles'] .= '<script type="text/javascript">'/* Needed to avoid Flash of Unstyle Content in IE */ . '</script>';
  93. // here are the witdh calculatings and some scrips addings
  94. if (theme_get_setting('newsflash_width')) {
  95. $variables['styles'] .= '<style type="text/css">
  96. #page
  97. {
  98. width : ' . theme_get_setting('newsflash_width') . ';
  99. }
  100. </style>';
  101. }
  102. else {
  103. $variables['styles'] .= '<style type="text/css">
  104. #page
  105. {
  106. width: 95%;
  107. }
  108. </style>';
  109. }
  110.  
  111. if ($left_sidebar_width = theme_get_setting('newsflash_leftsidebarwidth')) {
  112. $variables['styles'] .= '<style type="text/css">
  113. body.sidebar-first #main
  114. {
  115. margin-left: -' . $left_sidebar_width . 'px;
  116. }
  117. body.two-sidebars #main
  118. {
  119. margin-left: -' . $left_sidebar_width . 'px;
  120. }
  121. body.sidebar-first #squeeze
  122. {
  123. margin-left: ' . $left_sidebar_width . 'px;
  124. }
  125. body.two-sidebars #squeeze
  126. {
  127. margin-left: ' . $left_sidebar_width . 'px;
  128. }
  129. #sidebar-left
  130. {
  131. width: ' . $left_sidebar_width . 'px;
  132. }
  133. </style>';
  134. }
  135.  
  136. if ($right_sidebar_width = theme_get_setting('newsflash_rightsidebarwidth')) {
  137. $variables['styles'] .= '<style type="text/css">
  138. body.sidebar-second #main
  139. {
  140. margin-right: -' . $right_sidebar_width . 'px;
  141. }
  142. body.two-sidebars #main
  143. {
  144. margin-right: -' . $right_sidebar_width . 'px;
  145. }
  146. body.sidebar-second #squeeze
  147. {
  148. margin-right: ' . $right_sidebar_width . 'px;
  149. }
  150. body.two-sidebars #squeeze
  151. {
  152. margin-right: ' . $right_sidebar_width . 'px;
  153. }
  154. #sidebar-right
  155. {
  156. width: ' . $right_sidebar_width . 'px;
  157. }
  158. </style>';
  159. }
  160.  
  161. if (theme_get_setting('newsflash_fontfamily') != 'Custom') {
  162. $variables['styles'] .= '<style type="text/css">
  163. body
  164. {
  165. font-family : ' . theme_get_setting('newsflash_fontfamily') . ';
  166. }
  167. </style>';
  168. }
  169. elseif (theme_get_setting('newsflash_customfont')) {
  170. $variables['styles'] .= '<style type="text/css">
  171. body
  172. {
  173. font-family : ' . theme_get_setting('newsflash_customfont') . ';
  174. }
  175. </style>';
  176. }
  177.  
  178. if (theme_get_setting('newsflash_usecustomlogosize')) {
  179. $variables['styles'] .= '<style type="text/css">
  180. img#logo
  181. {
  182. width : ' . theme_get_setting('newsflash_logowidth') . 'px;
  183. height: ' . theme_get_setting('newsflash_logoheight') . 'px;
  184. }
  185. </style>';
  186. }
  187. if (theme_get_setting('newsflash_suckerfish')) {
  188. $variables['styles'] .= '<style type="text/css">
  189. #suckerfishmenu div .contextual-links-wrapper {
  190. display:none;
  191. }
  192. </style>';
  193. }
  194.  
  195. if (theme_get_setting('newsflash_suckerfish')) {
  196. $variables['scripts'] .= '<!--[if lte IE 6]>
  197. <script type="text/javascript" src="' . path_to_theme() . '/js/suckerfish.js"></script>
  198. <![endif]-->';
  199. }
  200.  
  201. $variables['styles'] .= '<!--[if lte IE 6]>
  202. <style type="text/css">
  203. #primarymenu {
  204. float:none;
  205. }
  206. </style>
  207. <![endif]-->';
  208. }
Add Comment
Please, Sign In to add comment