예제 #1
0
 /**
  * Wrap content of all items
  *
  * @param array $content_items The array of Raw HTML output (is not wrapped) of each item
  * @param int   $current_page  The current page
  * @param int   $post_per_page The number of posts per page
  * @param int   $id            ID of View
  *
  * @return string Full HTML output for Content View
  */
 static function content_items_wrap($content_items, $current_page, $post_per_page, $id)
 {
     global $pt_cv_glb, $pt_cv_id;
     $dargs = PT_CV_Functions::get_global_variable('dargs');
     if (empty($content_items)) {
         return 'empty content_items';
     }
     // Assign as global variable
     $pt_cv_glb[$pt_cv_id]['content_items'] = $content_items;
     $display = PT_CV_Functions::is_pagination($dargs, $current_page);
     // 1. Before output
     $before_output = $display ? apply_filters(PT_CV_PREFIX_ . 'before_output_html', '') : '';
     // 2. Output content
     $content = array();
     $view_type = $dargs['view-type'];
     // Separate items by row, column
     switch ($view_type) {
         // Grid
         case 'grid':
             PT_CV_Html_ViewType::grid_wrapper($content_items, $content);
             break;
             // Collapsible List
         // Collapsible List
         case 'collapsible':
             PT_CV_Html_ViewType::collapsible_wrapper($content_items, $content);
             break;
             // Scrollable List
         // Scrollable List
         case 'scrollable':
             PT_CV_Html_ViewType::scrollable_wrapper($content_items, $content);
             break;
         default:
             foreach ($content_items as $post_id => $content_item) {
                 // Wrap content of item
                 $content[] = PT_CV_Html::content_item_wrap($content_item, '', $post_id);
             }
             $content = apply_filters(PT_CV_PREFIX_ . 'content_items_wrap', $content, $content_items, $current_page, $post_per_page);
             break;
     }
     // Join content
     $content_list = balanceTags(implode("\n", $content));
     // Custom attribute of a page
     $page_attr_ = apply_filters(PT_CV_PREFIX_ . 'page_attr', '', $view_type, $content_items);
     $page_attr = strip_tags($page_attr_);
     // Wrap items in 'page' wrapper
     $wrap_in_page = apply_filters(PT_CV_PREFIX_ . 'wrap_in_page', true);
     if ($wrap_in_page) {
         // Wrap in page wrapper
         $html = sprintf('<div id="%s" class="%s" %s>%s</div>', esc_attr(PT_CV_PREFIX . 'page' . '-' . $current_page), esc_attr(PT_CV_PREFIX . 'page'), $page_attr, $content_list);
         // Remove page attribute value
         $page_attr = '';
     } else {
         $html = $content_list;
     }
     if ($display) {
         // Get wrapper class of a view
         $view_class = apply_filters(PT_CV_PREFIX_ . 'view_class', array(PT_CV_PREFIX . 'view', PT_CV_PREFIX . $view_type));
         // ID for the wrapper
         $view_id = PT_CV_PREFIX . 'view-' . $id;
         $output = sprintf('<div class="%s" id="%s" %s>%s</div>', esc_attr(implode(' ', array_filter($view_class))), esc_attr($view_id), $page_attr, $html);
         do_action(PT_CV_PREFIX_ . 'store_view_data', $view_id);
     } else {
         $output = $html;
     }
     return balanceTags($before_output) . balanceTags($output);
 }
 /**
  * HTML output of item in Scrollable List
  *
  * @param array $content_items The array of Raw HTML output (is not wrapped) of each item
  *
  * @return array
  */
 static function scrollable_content($content_items)
 {
     $dargs = PT_CV_Functions::get_global_variable('dargs');
     // Store content of a Scrollable list
     $scrollable_content = array();
     $rows = $dargs['number-rows'] ? (int) $dargs['number-rows'] : 1;
     list($columns, $span_width_last, $span_width, $span_class, $row_class) = self::process_column_width();
     // Get wrapper class of a scrollable slide
     $slide_class = apply_filters(PT_CV_PREFIX_ . 'scrollable_slide_class', 'item');
     // Split items to slide
     $slides_item = array_chunk($content_items, $columns * $rows);
     foreach ($slides_item as $s_idx => $slide) {
         // Store content of a slide
         $slide_html = array();
         // Split items to rows
         $columns_item = array_chunk($slide, $columns);
         // Get HTML of each row
         foreach ($columns_item as $items_per_row) {
             $row_html = array();
             foreach ($items_per_row as $idx => $content_item) {
                 $_span_width = $idx == count($items_per_row) - 1 ? $span_width_last : $span_width;
                 // Wrap content of item
                 $item_classes = apply_filters(PT_CV_PREFIX_ . 'item_col_class', array($span_class . $_span_width), $_span_width);
                 $item_class = implode(' ', array_filter($item_classes));
                 $row_html[] = PT_CV_Html::content_item_wrap($content_item, $item_class);
             }
             $slide_html[] = sprintf('<div class="%1$s">%2$s</div>', esc_attr($row_class), implode("\n", $row_html));
         }
         // Show first slide
         $this_class = $slide_class . ($s_idx == 0 ? ' active' : '');
         $scrollable_content[] = sprintf('<div class="%s">%s</div>', esc_attr($this_class), implode("\n", $slide_html));
     }
     // Get class of wrapper of content of scrollable list
     $content_class = apply_filters(PT_CV_PREFIX_ . 'scrollable_content_class', 'carousel-inner');
     $content = sprintf('<div class="%s">%s</div>', esc_attr($content_class), implode("\n", $scrollable_content));
     return array('scrollable_content' => $content, 'count_slides' => count($slides_item));
 }
예제 #3
0
 /**
  * Wrap content of all items
  *
  * @param array $content_items The array of Raw HTML output (is not wrapped) of each item
  * @param int   $current_page  The current page
  * @param int   $post_per_page The number of posts per page
  * @param int   $id            ID of View
  *
  * @return string Full HTML output for Content View
  */
 static function content_items_wrap($content_items, $current_page, $post_per_page, $id)
 {
     $dargs = PT_CV_Functions::get_global_variable('dargs');
     if (empty($content_items)) {
         return PT_CV_Functions::debug_output('empty content_items', 'No posts found!');
     }
     // Assign as global variable
     PT_CV_Functions::set_global_variable('content_items', $content_items);
     $nonpaging_or_firstpage = PT_CV_Functions::nonpaging_or_firstpage($dargs, $current_page);
     // 1. Before output
     $before_output = $nonpaging_or_firstpage ? apply_filters(PT_CV_PREFIX_ . 'before_output_html', '') : '';
     // 2. Output content
     $content = array();
     $view_type = $dargs['view-type'];
     // Separate items by row, column
     switch ($view_type) {
         // Grid
         case 'grid':
             PT_CV_Html_ViewType::grid_wrapper($content_items, $content);
             break;
             // Collapsible List
         // Collapsible List
         case 'collapsible':
             PT_CV_Html_ViewType::collapsible_wrapper($content_items, $content);
             break;
             // Scrollable List
         // Scrollable List
         case 'scrollable':
             PT_CV_Html_ViewType::scrollable_wrapper($content_items, $content);
             break;
         default:
             foreach ($content_items as $post_id => $content_item) {
                 // Wrap content of item
                 $content[] = PT_CV_Html::content_item_wrap($content_item, '', $post_id);
             }
             $content = apply_filters(PT_CV_PREFIX_ . 'content_items_wrap', $content, $content_items, $current_page, $post_per_page);
             break;
     }
     // Join content
     $content_list = implode("\n", $content);
     // Custom attribute of a page
     $col_count = sprintf('data-cvc="%s"', (int) $dargs['number-columns']);
     $page_attr_ = apply_filters(PT_CV_PREFIX_ . 'page_attr', $col_count, $view_type, $content_items, $dargs);
     $page_attr = strip_tags($page_attr_);
     if (apply_filters(PT_CV_PREFIX_ . 'wrap_in_page', true)) {
         // Wrap items in 'page' wrapper
         $html = sprintf('<div id="%s" class="%s" %s>%s</div>', esc_attr(PT_CV_PREFIX . 'page' . '-' . $current_page), esc_attr(PT_CV_PREFIX . 'page'), $page_attr, $content_list);
         // Remove page attribute value
         $page_attr = '';
     } else {
         $html = $content_list;
     }
     if ($nonpaging_or_firstpage) {
         // Get wrapper class of View
         $view_class = apply_filters(PT_CV_PREFIX_ . 'view_class', array(PT_CV_PREFIX . 'view', PT_CV_PREFIX . $view_type));
         // ID for the wrapper
         $view_id = PT_CV_PREFIX . 'view-' . $id;
         $output = sprintf('<div class="%s" id="%s" %s>%s</div>', esc_attr(implode(' ', array_filter($view_class))), esc_attr($view_id), $page_attr, $html);
         do_action(PT_CV_PREFIX_ . 'store_view_data', $view_id);
     } else {
         $output = $html;
     }
     return $before_output . $output;
 }
예제 #4
0
 /**
  * Wrap content of all items
  *
  * @param array $content_items The array of Raw HTML output (is not wrapped) of each item
  * @param int   $current_page  The current page
  * @param int   $post_per_page The number of posts per page
  * @param int   $id            ID of View
  *
  * @return string Full HTML output for Content View
  */
 static function content_items_wrap($content_items, $current_page, $post_per_page, $id)
 {
     $dargs = PT_CV_Functions::get_global_variable('dargs');
     if (empty($content_items)) {
         return PT_CV_Functions::debug_output('empty content_items', self::no_post_found());
     }
     // Assign as global variable
     PT_CV_Functions::set_global_variable('content_items', $content_items);
     $full_output = !defined('PT_CV_DOING_PAGINATION');
     // 1. Before output
     $before_output = $full_output ? apply_filters(PT_CV_PREFIX_ . 'before_output_html', '') : '';
     // 2. Output content
     $content = array();
     $view_type = $dargs['view-type'];
     // Separate items by row, column
     switch ($view_type) {
         // Grid
         case 'grid':
             PT_CV_Html_ViewType::grid_wrapper($content_items, $content);
             break;
             // Collapsible List
         // Collapsible List
         case 'collapsible':
             PT_CV_Html_ViewType::collapsible_wrapper($content_items, $content);
             break;
             // Scrollable List
         // Scrollable List
         case 'scrollable':
             PT_CV_Html_ViewType::scrollable_wrapper($content_items, $content);
             break;
         default:
             foreach ($content_items as $post_id => $content_item) {
                 $content[] = PT_CV_Html::content_item_wrap($content_item, '', $post_id);
             }
             $content = apply_filters(PT_CV_PREFIX_ . 'content_items_wrap', $content, $content_items, $current_page, $post_per_page);
             break;
     }
     // Join content
     $content_list = implode("\n", $content);
     // Wrap in Page
     if (apply_filters(PT_CV_PREFIX_ . 'wrap_in_page', true)) {
         $cols = sprintf('data-cvc="%s"', (int) $dargs['number-columns']);
         $page_attr = apply_filters(PT_CV_PREFIX_ . 'page_attr', $cols, $view_type, $content_items);
         $html = sprintf('<div id="%s" class="%s" %s>%s</div>', PT_CV_PREFIX . 'page' . '-' . $current_page, PT_CV_PREFIX . 'page', $page_attr, $content_list);
     } else {
         $html = $content_list;
     }
     // Wrap in View
     if ($full_output) {
         $use_grid = PT_CV_Functions::get_global_variable('use_grid', true);
         $view_class = apply_filters(PT_CV_PREFIX_ . 'view_class', array(PT_CV_PREFIX . 'view', PT_CV_PREFIX . $view_type, $use_grid ? PT_CV_PREFIX . 'colsys' : ''));
         $view_id = PT_CV_PREFIX . 'view-' . $id;
         $output = sprintf('<div class="%s" id="%s">%s</div>', esc_attr(implode(' ', array_filter($view_class))), $view_id, $html);
         // Keep this action for CVP < 3.5
         do_action(PT_CV_PREFIX_ . 'store_view_data', $view_id);
     } else {
         $output = $html;
     }
     return $before_output . $output;
 }