Guest User

Untitled

a guest
May 9th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | None | 0 0
  1. <?php
  2.  
  3. class td_block_17 extends td_block {
  4.  
  5. static function cssMedia( $res_ctx ) {
  6.  
  7. // fonts
  8. $res_ctx->load_font_settings( 'f_header' );
  9. $res_ctx->load_font_settings( 'f_ajax' );
  10. $res_ctx->load_font_settings( 'f_more' );
  11.  
  12. // module 4 fonts
  13. $res_ctx->load_font_settings( 'm4f_title' );
  14. $res_ctx->load_font_settings( 'm4f_cat' );
  15. $res_ctx->load_font_settings( 'm4f_meta' );
  16. $res_ctx->load_font_settings( 'm4f_ex' );
  17. // module 8 fonts
  18. $res_ctx->load_font_settings( 'm8f_title' );
  19. $res_ctx->load_font_settings( 'm8f_cat' );
  20. $res_ctx->load_font_settings( 'm8f_meta' );
  21.  
  22. }
  23.  
  24. public function get_custom_css() {
  25. // $unique_block_class - the unique class that is on the block. use this to target the specific instance via css
  26. $unique_block_class = $this->block_uid . '_rand';
  27.  
  28. $compiled_css = '';
  29.  
  30. $raw_css =
  31. "<style>
  32.  
  33. /* @f_header */
  34. .$unique_block_class .td-block-title a,
  35. .$unique_block_class .td-block-title span {
  36. @f_header
  37. }
  38. /* @f_ajax */
  39. .$unique_block_class .td-subcat-list a,
  40. .$unique_block_class .td-subcat-dropdown span,
  41. .$unique_block_class .td-subcat-dropdown a {
  42. @f_ajax
  43. }
  44. /* @f_more */
  45. .$unique_block_class .td-load-more-wrap a {
  46. @f_more
  47. }
  48. /* @m4f_title */
  49. .$unique_block_class .td_module_4 .entry-title {
  50. @m4f_title
  51. }
  52. /* @m4f_cat */
  53. .$unique_block_class .td_module_4 .td-post-category {
  54. @m4f_cat
  55. }
  56. /* @m4f_meta */
  57. .$unique_block_class .td_module_4 .td-module-meta-info,
  58. .$unique_block_class .td_module_4 .td-module-comments a {
  59. @m4f_meta
  60. }
  61. /* @m4f_ex */
  62. .$unique_block_class .td_module_4 .td-excerpt {
  63. @m4f_ex
  64. }
  65. /* @m8f_title */
  66. .$unique_block_class .td_module_8 .entry-title {
  67. @m8f_title
  68. }
  69. /* @m8f_cat */
  70. .$unique_block_class .td_module_8 .td-post-category {
  71. @m8f_cat
  72. }
  73. /* @m8f_meta */
  74. .$unique_block_class .td_module_8 .td-module-meta-info,
  75. .$unique_block_class .td_module_8 .td-module-comments a {
  76. @m8f_meta
  77. }
  78. </style>";
  79.  
  80.  
  81. $td_css_res_compiler = new td_css_res_compiler( $raw_css );
  82. $td_css_res_compiler->load_settings( __CLASS__ . '::cssMedia', $this->get_all_atts() );
  83.  
  84. $compiled_css .= $td_css_res_compiler->compile_css();
  85.  
  86. return $compiled_css;
  87. }
  88.  
  89. function render($atts, $content = null) {
  90.  
  91. parent::render($atts); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
  92.  
  93. if (empty($td_column_number)) {
  94. $td_column_number = td_global::vc_get_column_number(); // get the column width of the block from the page builder API
  95. }
  96.  
  97. $limit = $this->get_att('limit');
  98.  
  99. $buffy = ''; //output buffer
  100.  
  101. $buffy .= '<div class="' . $this->get_block_classes() . ' td-column-' . $td_column_number . '" ' . $this->get_block_html_atts() . '>';
  102.  
  103. //get the block js
  104. $buffy .= $this->get_block_css();
  105.  
  106. //get the js for this block
  107. $buffy .= $this->get_block_js();
  108.  
  109. // block title wrap
  110. $buffy .= '<div class="td-block-title-wrap">';
  111. $buffy .= $this->get_block_title(); //get the block title
  112. $buffy .= $this->get_pull_down_filter(); //get the sub category filter for this block
  113. $buffy .= '</div>';
  114.  
  115. $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner td-column-' . $td_column_number . '">';
  116. $buffy .= $this->inner($this->td_query->posts, $td_column_number, $limit); //inner content of the block
  117. $buffy .= '</div>';
  118.  
  119. //get the ajax pagination for this block
  120. $buffy .= $this->get_block_pagination();
  121. $buffy .= '</div> <!-- ./block -->';
  122. return $buffy;
  123. }
  124.  
  125. function inner($posts, $td_column_number = '', $limit) {
  126.  
  127. $buffy = '';
  128.  
  129. $td_block_layout = new td_block_layout();
  130. $td_post_count = 0; // the number of posts rendered
  131.  
  132. if( $limit > 5 ) {
  133. if( $limit % 2 != 0 ) {
  134. $limit = $limit+1;
  135. }
  136. $limit = $limit / 2;
  137. }
  138.  
  139. if (!empty($posts)) {
  140. foreach ($posts as $post) {
  141.  
  142. $td_module_4 = new td_module_4($post, $this->get_all_atts());
  143. $td_module_8 = new td_module_8($post, $this->get_all_atts());
  144.  
  145. switch ($td_column_number) {
  146.  
  147. case '1': //one column layout
  148. $buffy .= $td_block_layout->open12(); //added in 010 theme - span 12 doesn't use rows
  149. if ($td_post_count == 0) { //first post
  150. $buffy .= $td_module_4->render();
  151. } else {
  152. $buffy .= $td_module_8->render();
  153. }
  154. $buffy .= $td_block_layout->close12();
  155. break;
  156.  
  157. case '2': //two column layout
  158. $buffy .= $td_block_layout->open_row();
  159. if ($td_post_count == 0) { //first post
  160. $buffy .= $td_block_layout->open6();
  161. $buffy .= $td_module_4->render();
  162. $buffy .= $td_block_layout->close6();
  163. } else { //the rest
  164. $buffy .= $td_block_layout->open6();
  165. $buffy .= $td_module_8->render();
  166. }
  167. break;
  168.  
  169. case '3': //three column layout
  170. $buffy .= $td_block_layout->open_row();
  171. if ($td_post_count == 0) { //first post
  172. $buffy .= $td_block_layout->open4();
  173. $buffy .= $td_module_4->render();
  174. $buffy .= $td_block_layout->close4();
  175. } else { //2-3 cols
  176. $buffy .= $td_block_layout->open4();
  177. $buffy .= $td_module_8->render();
  178.  
  179.  
  180. if ( $td_post_count == $limit ) { //make new column
  181. $buffy .= $td_block_layout->close4();
  182. }
  183. }
  184. break;
  185. }
  186. $td_post_count++;
  187. }
  188. }
  189. $buffy .= $td_block_layout->close_all_tags();
  190. return $buffy;
  191. }
  192. }
Advertisement
Add Comment
Please, Sign In to add comment