/** * Generate class for columns * * @param int $col * @param bool $for_grid * * @return array */ static function process_column_width($col = 0, $for_grid = true) { $dargs = PT_CV_Functions::get_global_variable('dargs'); // Get column span $columns = $col ? $col : (int) $dargs['number-columns']; if (!$columns) { $columns = 1; } $span_width_last = $span_width = (int) (12 / $columns); // Get span for the last column on row if (12 % $columns) { $span_width_last = $span_width + 12 % $columns; } // Get span class $span_class = apply_filters(PT_CV_PREFIX_ . 'span_class', 'col-md-'); // Mark as using grid system if ($for_grid) { PT_CV_Functions::set_global_variable('use_grid', 1); } return array($columns, $span_width_last, $span_width, $span_class, ''); }
/** * 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; }
/** * Get display parameters of View * * @param string $view_type The view type of View * * @return array */ static function view_display_settings($view_type, &$dargs = null) { $dargs = array(); $dargs['view-type'] = $view_type; // Field settings of a item PT_CV_Functions::view_get_display_settings($dargs); // Other settings PT_CV_Functions::view_get_other_settings($dargs); // View type settings $dargs['view-type-settings'] = PT_CV_Functions::settings_values_by_prefix(PT_CV_PREFIX . $view_type . '-'); PT_CV_Functions::set_global_variable('dargs', $dargs); return $dargs; }
/** * 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; }