diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-18 13:34:58 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-18 13:34:58 +0000 |
commit | 269386b9cfa0e1558edde89442c6f571ef32c645 (patch) | |
tree | 8714e84ec6bcfca99bf3ee560024090d36cc6543 /engine/lib/entities.php | |
parent | c3a4bafc3f3f0984e8751e00e024ab8c09e0ff1b (diff) | |
download | elgg-269386b9cfa0e1558edde89442c6f571ef32c645.tar.gz elgg-269386b9cfa0e1558edde89442c6f571ef32c645.tar.bz2 |
Added generic listing and pagination functions
git-svn-id: https://code.elgg.org/elgg/trunk@964 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r-- | engine/lib/entities.php | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index e9f795d11..c57a13d46 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1016,7 +1016,7 @@ * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false. * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites. */ - function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "time_created desc", $limit = 10, $offset = 0, $count = false, $site_guid = 0) + function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { global $CONFIG; @@ -1025,7 +1025,8 @@ $type = sanitise_string($type); $subtype = get_subtype_id($type, $subtype); - +
+ if ($order_by == "") $order_by = "time_created desc"; $order_by = sanitise_string($order_by); $limit = (int)$limit; $offset = (int)$offset; @@ -1072,6 +1073,27 @@ return $total->total; } } +
+ /**
+ * Returns a viewable list of entities
+ *
+ * @see elgg_view_entity_list
+ *
+ * @param string $type The type of entity (eg "user", "object" etc)
+ * @param string $subtype The arbitrary subtype of the entity
+ * @param int $owner_guid The GUID of the owning user
+ * @param int $limit The number of entities to display per page (default: 10)
+ * @return string A viewable list of entities
+ */
+ function list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10) {
+
+ $offset = (int) get_input('offset');
+ $count = get_entities($type, $subtype, $owner_guid, "", $limit, $offset, true);
+ $entities = get_entities($type, $subtype, $owner_guid, "", $limit, $offset);
+
+ return elgg_view_entity_list($entities, $count, $offset, $limit);
+
+ }
/** * Delete a given entity. |