diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-03 01:05:34 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-03 01:05:34 +0000 |
commit | 08b8b7d630b1958e7b363c3794f8b67f667a9128 (patch) | |
tree | 81b7e3b1d5f931dae7d517500c2762ccdcc4b736 /engine/lib/entities.php | |
parent | b8688c6c4f82c5eb3ec3f9744a0ba2e348cb45ba (diff) | |
download | elgg-08b8b7d630b1958e7b363c3794f8b67f667a9128.tar.gz elgg-08b8b7d630b1958e7b363c3794f8b67f667a9128.tar.bz2 |
Fixes #2606: Abstracted elgg_list_entities. Takes an optional second argument for the 'getter', defaulting to 'elgg_get_entities'. Converted current elgg_list_entities* functions to use it
git-svn-id: http://code.elgg.org/elgg/trunk@7212 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r-- | engine/lib/entities.php | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 1fe657808..4a971eb57 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1314,35 +1314,38 @@ function elgg_get_entity_site_where_sql($table, $site_guids) { * * @tip Pagination is handled automatically. * - * @param array $options Any elgg_get_entity() options plus: - * - * full_view => BOOL Display full view entities - * - * view_type_toggle => BOOL Display gallery / list switch - * - * pagination => BOOL Display pagination links + * @param array $options Any options from $getter options plus: + * full_view => BOOL Display full view entities + * view_type_toggle => BOOL Display gallery / list switch + * pagination => BOOL Display pagination links + * + * @param mixed $getter The entity getter function to use to fetch the entities * - * @return str - * @since 1.7.0 - * @see elgg_view_entity_list() + * @return string + * @since 1.7 * @see elgg_get_entities() + * @see elgg_view_entity_list() * @link http://docs.elgg.org/Entities/Output */ -function elgg_list_entities($options) { +function elgg_list_entities(array $options = array(), $getter = 'elgg_get_entities') { $defaults = array( 'offset' => (int) max(get_input('offset', 0), 0), 'limit' => (int) max(get_input('limit', 10), 0), 'full_view' => TRUE, 'view_type_toggle' => FALSE, - 'pagination' => TRUE + 'pagination' => TRUE, ); + $options = array_merge($defaults, $options); - $count = elgg_get_entities(array_merge(array('count' => TRUE), $options)); - $entities = elgg_get_entities($options); + $options['count'] = TRUE; + $count = $getter($options); + + $options['count'] = FALSE; + $entities = $getter($options); - return elgg_view_entity_list($entities, $count, $options['offset'], - $options['limit'], $options['full_view'], $options['view_type_toggle'], $options['pagination']); + return elgg_view_entity_list($entities, $count, $options['offset'], $options['limit'], + $options['full_view'], $options['view_type_toggle'], $options['pagination']); } /** |