Beispiel #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)
 {
     $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;
 }
 /**
  * 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);
 }
Beispiel #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', 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;
 }