baliniz

Block_3_View.php

Feb 4th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.14 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @author : Jegtheme
  4.  */
  5. namespace JNews\Module\Block;
  6.  
  7. Class Block_3_View extends BlockViewAbstract
  8. {
  9.     public function render_block_type_1($post, $image_size)
  10.     {
  11.         $thumbnail = $this->get_thumbnail($post->ID, $image_size);
  12.  
  13.         $output =
  14.             "<article " . jnews_post_class("jeg_post jeg_pl_md_2", $post->ID) . ">
  15.                <div class=\"jeg_thumb\">
  16.                    " . jnews_edit_post( $post->ID ) . "
  17.                    <a href=\"" . get_the_permalink($post) . "\">" . $thumbnail . "</a>
  18.                </div>
  19.                <div class=\"jeg_postblock_content\">
  20.                    <h2 class=\"jeg_post_title\">
  21.                        <a href=\"" . get_the_permalink($post) . "\">" . get_the_title($post) . "</a>
  22.                    </h2>
  23.                    " . $this->post_meta_1($post) . "
  24.                    <div class=\"jeg_post_excerpt\">
  25.                        <p>" . $this->get_excerpt($post) . "</p>
  26.                    </div>
  27.                </div>
  28.            </article>";
  29.  
  30.         return $output;
  31.     }
  32.  
  33.  
  34.     public function build_column_1($results)
  35.     {
  36.         $first_block   = '';
  37.         $ads_position  = $this->random_ads_position(sizeof($results));
  38.  
  39.         for ( $i = 0; $i < sizeof($results); $i++ )
  40.         {
  41.             if ( $i == $ads_position )
  42.             {
  43.                 $first_block .= $this->render_module_ads();
  44.             }
  45.  
  46.             $first_block .= $this->render_block_type_1($results[$i], 'jnews-120x86');
  47.         }
  48.  
  49.         $output =
  50.             "<div class=\"jeg_posts jeg_load_more_flag\">
  51.                {$first_block}
  52.            </div>";
  53.  
  54.         return $output;
  55.     }
  56.  
  57.     public function build_column_2($results)
  58.     {
  59.         $first_block  = '';
  60.         $ads_position = $this->random_ads_position(sizeof($results));
  61.  
  62.         for ( $i = 0; $i < sizeof($results); $i++ )
  63.         {
  64.             if ( $i == $ads_position )
  65.             {
  66.                 $first_block .= $this->render_module_ads();
  67.             }
  68.  
  69.             $first_block .= $this->render_block_type_1($results[$i], 'jnews-350x250');
  70.         }
  71.  
  72.         $output =
  73.             "<div class=\"jeg_posts jeg_load_more_flag\">
  74.                {$first_block}
  75.            </div>";
  76.  
  77.         return $output;
  78.     }
  79.  
  80.     public function build_column_1_alt($results)
  81.     {
  82.         $first_block   = '';
  83.         $ads_position  = $this->random_ads_position(sizeof($results));
  84.  
  85.         for ( $i = 0; $i < sizeof($results); $i++ )
  86.         {
  87.             if ( $i == $ads_position )
  88.             {
  89.                 $first_block .= $this->render_module_ads('jeg_ajax_loaded anim_' . $i);
  90.             }
  91.  
  92.             $first_block .= $this->render_block_type_1($results[$i], 'jnews-120x86');
  93.         }
  94.  
  95.         $output = $first_block;
  96.  
  97.         return $output;
  98.     }
  99.  
  100.     public function build_column_2_alt($results)
  101.     {
  102.         $first_block   = '';
  103.         $ads_position  = $this->random_ads_position(sizeof($results));
  104.  
  105.         for ( $i = 0; $i < sizeof($results); $i++ )
  106.         {
  107.             if ( $i == $ads_position )
  108.             {
  109.                 $first_block .= $this->render_module_ads('jeg_ajax_loaded anim_' . $i);
  110.             }
  111.  
  112.             $first_block .= $this->render_block_type_1($results[$i], 'jnews-350x250');
  113.         }
  114.  
  115.         $output = $first_block;
  116.  
  117.         return $output;
  118.     }
  119.  
  120.     public function render_output($attr, $column_class)
  121.     {
  122.         $results    = $this->build_query($attr);
  123.         $navigation = $this->render_navigation($attr, $results['next'], $results['prev'], $results['total_page']);
  124.  
  125.         if(!empty($results['result'])) {
  126.             $content = $this->render_column($results['result'], $column_class);
  127.         } else {
  128.             $content = $this->empty_content();
  129.         }
  130.  
  131.         return
  132.             "<div class=\"jeg_posts jeg_block_container\">
  133.                {$this->get_content_before($attr)}
  134.                {$content}
  135.                {$this->get_content_after($attr)}
  136.            </div>
  137.            <div class=\"jeg_block_navigation\">
  138.                {$this->get_navigation_before($attr)}
  139.                {$navigation}
  140.                {$this->get_navigation_after($attr)}
  141.            </div>";
  142.     }
  143.  
  144.     public function render_column($result, $column_class)
  145.     {
  146.         switch($column_class)
  147.         {
  148.             case "jeg_col_1o3" :
  149.                 $content = $this->build_column_1($result);
  150.                 break;
  151.             case "jeg_col_3o3" :
  152.             case "jeg_col_2o3" :
  153.             default :
  154.                 $content = $this->build_column_2($result);
  155.                 break;
  156.         }
  157.  
  158.         return $content;
  159.     }
  160.  
  161.     public function render_column_alt($result, $column_class)
  162.     {
  163.         switch($column_class)
  164.         {
  165.             case "jeg_col_1o3" :
  166.                 $content = $this->build_column_1_alt($result);
  167.                 break;
  168.             case "jeg_col_3o3" :
  169.             case "jeg_col_2o3" :
  170.             default :
  171.                 $content = $this->build_column_2_alt($result);
  172.                 break;
  173.         }
  174.  
  175.         return $content;
  176.     }
  177. }
Add Comment
Please, Sign In to add comment