/** * Core function to calculate View multi entries (directory) based on a set of arguments ($args): * $id - View id * $page_size - Page * $sort_field - form field id to sort * $sort_direction - ASC / DESC * $start_date - Ymd * $end_date - Ymd * $class - assign a html class to the view * $offset (optional) - This is the start point in the current data set (0 index based). * * * * @uses gravityview_get_entries() * @access public * @param array $args\n * - $id - View id * - $page_size - Page * - $sort_field - form field id to sort * - $sort_direction - ASC / DESC * - $start_date - Ymd * - $end_date - Ymd * - $class - assign a html class to the view * - $offset (optional) - This is the start point in the current data set (0 index based). * @param int $form_id Gravity Forms Form ID * @return array Associative array with `count`, `entries`, and `paging` keys. `count` has the total entries count, `entries` is an array with Gravity Forms full entry data, `paging` is an array with `offset` and `page_size` keys */ public static function get_view_entries($args, $form_id) { do_action('gravityview_log_debug', '[get_view_entries] init'); // start filters and sorting /** * Process search parameters * @var array */ $search_criteria = self::get_search_criteria($args, $form_id); // Paging & offset $page_size = !empty($args['page_size']) ? intval($args['page_size']) : apply_filters('gravityview_default_page_size', 25); if (-1 === $page_size) { $page_size = PHP_INT_MAX; } if (isset($args['offset'])) { $offset = intval($args['offset']); } else { $curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']); $offset = ($curr_page - 1) * $page_size; } $paging = array('offset' => $offset, 'page_size' => $page_size); do_action('gravityview_log_debug', '[get_view_entries] Paging: ', $paging); // Sorting $sorting = self::updateViewSorting($args, $form_id); $parameters = array('search_criteria' => $search_criteria, 'sorting' => $sorting, 'paging' => $paging, 'cache' => isset($args['cache']) ? $args['cache'] : true); /** * @filter `gravityview_get_entries` Filter get entries criteria * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. * @param array $args View configuration args. { * @type int $id View id * @type int $page_size Number of entries to show per page * @type string $sort_field Form field id to sort * @type string $sort_direction Sorting direction ('ASC' or 'DESC') * @type string $start_date - Ymd * @type string $end_date - Ymd * @type string $class - assign a html class to the view * @type string $offset (optional) - This is the start point in the current data set (0 index based). * } * @param int $form_id ID of Gravity Forms form */ $parameters = apply_filters('gravityview_get_entries', $parameters, $args, $form_id); /** * @filter `gravityview_get_entries_{View ID}` Filter get entries criteria * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. * @param array $args View configuration args. */ $parameters = apply_filters('gravityview_get_entries_' . $args['id'], $parameters, $args, $form_id); do_action('gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters); //fetch entries $count = 0; $entries = gravityview_get_entries($form_id, $parameters, $count); do_action('gravityview_log_debug', sprintf('[get_view_entries] Get Entries. Found: %s entries', $count), $entries); /** * @filter `gravityview_view_entries` Filter the entries output to the View * @deprecated since 1.5.2 * @param array $args View settings associative array * @var array */ $entries = apply_filters('gravityview_view_entries', $entries, $args); /** * @filter `gravityview/view/entries` Filter the entries output to the View * @param array $criteria associative array containing count, entries & paging * @param array $args View settings associative array * @since 1.5.2 */ return apply_filters('gravityview/view/entries', compact('count', 'entries', 'paging'), $args); }
/** * Core function to calculate View multi entries (directory) based on a set of arguments ($args): * $id - View id * $page_size - Page * $sort_field - form field id to sort * $sort_direction - ASC / DESC * $start_date - Ymd * $end_date - Ymd * $class - assign a html class to the view * $offset (optional) - This is the start point in the current data set (0 index based). * * * * @uses gravityview_get_entries() * @access public * @param mixed $args * @param int $form_id Gravity Forms Form ID * @return array Associative array with `count`, `entries`, and `paging` keys. `count` has the total entries count, `entries` is an array with Gravity Forms full entry data, `paging` is an array with `offset` and `page_size` keys */ public static function get_view_entries($args, $form_id) { do_action('gravityview_log_debug', '[get_view_entries] init'); // start filters and sorting /** * Process search parameters * @var array */ $search_criteria = self::get_search_criteria($args, $form_id); // Paging & offset $page_size = !empty($args['page_size']) ? intval($args['page_size']) : apply_filters('gravityview_default_page_size', 25); if (-1 === $page_size) { $page_size = PHP_INT_MAX; } if (isset($args['offset'])) { $offset = intval($args['offset']); } else { $curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']); $offset = ($curr_page - 1) * $page_size; } $paging = array('offset' => $offset, 'page_size' => $page_size); do_action('gravityview_log_debug', '[get_view_entries] Paging: ', $paging); // Sorting $sorting = self::updateViewSorting($args, $form_id); $parameters = array('search_criteria' => $search_criteria, 'sorting' => $sorting, 'paging' => $paging, 'cache' => isset($args['cache']) ? $args['cache'] : true); /** * Filter get entries criteria * * Passes and returns array with `search_criteria`, `sorting` and `paging` keys. * * @var array */ $parameters = apply_filters('gravityview_get_entries', apply_filters('gravityview_get_entries_' . $args['id'], $parameters, $args, $form_id), $args, $form_id); do_action('gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters); //fetch entries $count = 0; $entries = gravityview_get_entries($form_id, $parameters, $count); do_action('gravityview_log_debug', sprintf('[get_view_entries] Get Entries. Found: %s entries', $count), $entries); /** * Filter the entries output to the View * @deprecated since 1.5.2 * @param array $args View settings associative array * @var array */ $entries = apply_filters('gravityview_view_entries', $entries, $args); /** * Filter the entries output to the View * * @param array associative array containing count, entries & paging * @param array $args View settings associative array * * @since 1.5.2 */ return apply_filters('gravityview/view/entries', compact('count', 'entries', 'paging'), $args); }