Guest User

Untitled

a guest
Jun 15th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.96 KB | None | 0 0
  1. <?php
  2. /**
  3. * this is the default block template
  4. * Class td_block_header_1
  5. */
  6. class td_block_template_1 {
  7.  
  8. /**
  9. * @var string the template data, it's set on construct
  10. */
  11. var $template_data_array = '';
  12.  
  13. /**
  14. * @param $template_data_array array - all the data for the template
  15. */
  16. function __construct($template_data_array) {
  17. $this->template_data_array = $template_data_array;
  18. }
  19.  
  20. /**
  21. * renders the CSS for each block, each template may require a different css generated by the theme
  22. * @return string CSS the rendered css and <style> block
  23. */
  24. function get_css() {
  25. $header_color = $this->template_data_array['atts']['header_color'];
  26. $header_text_color = $this->template_data_array['atts']['header_text_color'];
  27.  
  28.  
  29.  
  30. // check if we have a header color, do nothing if we don't have a header_color or header_text_color
  31. if ((empty($header_color) or $header_color == '#') and (empty($header_text_color) or $header_text_color == '#')) {
  32. return '';
  33. }
  34.  
  35. // $unique_block_class - the unique class that is on the block. use this to target the specific instance via css
  36. $unique_block_class = $this->template_data_array['unique_block_class'];
  37.  
  38. // the css that will be compiled by the block, <style> - will be removed by the compiler
  39. $raw_css = "
  40. <style>
  41.  
  42. /* @header_color */
  43. .$unique_block_class .td_module_wrap:hover .entry-title a,
  44. .$unique_block_class .td-load-more-wrap a:hover,
  45. .$unique_block_class .td_quote_on_blocks,
  46. .$unique_block_class .td-wrapper-pulldown-filter .td-pulldown-filter-display-option:hover,
  47. .$unique_block_class .td-wrapper-pulldown-filter a.td-pulldown-filter-link:hover,
  48. .$unique_block_class .td-instagram-user a {
  49. color: @header_color;
  50. }
  51.  
  52. .$unique_block_class .td-next-prev-wrap a:hover i {
  53. background-color: @header_color;
  54. border-color: @header_color;
  55. }
  56.  
  57. .$unique_block_class .td_module_wrap .td-post-category:hover,
  58. .$unique_block_class .td-trending-now-title,
  59. .$unique_block_class .block-title span,
  60. .$unique_block_class .td-weather-information:before,
  61. .$unique_block_class .td-weather-week:before,
  62. .$unique_block_class .td-exchange-header:before,
  63. .$unique_block_class .block-title a {
  64. background-color: @header_color;
  65. }
  66.  
  67. /* @header_text_color */
  68. .$unique_block_class .td-trending-now-title,
  69. .$unique_block_class .block-title span,
  70. .$unique_block_class .block-title a {
  71. color: @header_text_color;
  72. }
  73.  
  74. </style>
  75. ";
  76.  
  77. $td_css_compiler = new td_css_compiler($raw_css);
  78. $td_css_compiler->load_setting_raw('header_color', $header_color);
  79. $td_css_compiler->load_setting_raw('header_text_color', $header_text_color);
  80.  
  81. $compiled_style = $td_css_compiler->compile_css();
  82.  
  83.  
  84. return $compiled_style;
  85. }
  86.  
  87.  
  88. /**
  89. * renders the block title
  90. * @return string HTML
  91. */
  92. function get_block_title() {
  93.  
  94.  
  95. $custom_title = $this->template_data_array['atts']['custom_title'];
  96. $custom_url = $this->template_data_array['atts']['custom_url'];
  97.  
  98.  
  99. if (empty($custom_title)) {
  100. if (empty($this->template_data_array['td_pull_down_items'])) {
  101. //no title selected and we don't have pulldown items
  102. return '';
  103. }
  104. // we don't have a title selected BUT we have pull down items! we cannot render pulldown items without a block title
  105. $custom_title = 'Block title';
  106. }
  107.  
  108.  
  109.  
  110. // there is a custom title
  111. $buffy = '';
  112. $buffy .= '<h4 class="block-title">';
  113. if (!empty($custom_url)) {
  114. $buffy .= '<a href="' . esc_url($custom_url) . '">' . esc_html($custom_title) . '</a>';
  115. } else {
  116. $buffy .= '<span>' . esc_html($custom_title) . '</span>';
  117. }
  118.  
  119. $buffy .= '<div id="main">';
  120. $buffy .= '<div class="arrowblock">';
  121. $buffy .= '<div class="arrowright"></div>';
  122. $buffy .= '<div class="rectcontainer">';
  123. $buffy .= '<div class="rect"></div>';
  124. $buffy .= '<div class="rect" style="background-color:#008000">';
  125. $buffy .= '</div><div class="rect">';
  126. $buffy .= '</div>';
  127. $buffy .= '</div>';
  128. $buffy .= '</h4>';
  129.  
  130.  
  131. return $buffy;
  132. }
  133.  
  134.  
  135. /**
  136. * renders the filter of the block
  137. * @return string
  138. */
  139. function get_pull_down_filter() {
  140. $buffy = '';
  141.  
  142. if (empty($this->template_data_array['td_pull_down_items'])) {
  143. return '';
  144. }
  145.  
  146. $buffy .= '<div class="td-wrapper-pulldown-filter">';
  147. $buffy .= '<div class="td-pulldown-filter-display-option">';
  148.  
  149.  
  150. //show the default display value
  151. $buffy .= '<div id="td-pulldown-' . $this->template_data_array['block_uid'] . '-val"><span>';
  152. $buffy .= $this->template_data_array['td_pull_down_items'][0]['name'] . ' </span><i class="td-icon-menu-down"></i>';
  153. $buffy .= '</div>';
  154.  
  155. //builde the dropdown
  156. $buffy .= '<ul class="td-pulldown-filter-list">';
  157. foreach ($this->template_data_array['td_pull_down_items'] as $item) {
  158. $buffy .= '<li class="td-pulldown-filter-item"><a class="td-pulldown-filter-link" id="' . td_global::td_generate_unique_id() . '" data-td_filter_value="' . $item['id'] . '" data-td_block_id="' . $this->template_data_array['block_uid'] . '" href="#">' . $item['name'] . '</a></li>';
  159. }
  160. $buffy .= '</ul>';
  161.  
  162. $buffy .= '</div>'; // /.td-pulldown-filter-display-option
  163. $buffy .= '</div>';
  164.  
  165. return $buffy;
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment