aboutsummaryrefslogtreecommitdiff
path: root/lib/tidypics.php
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2012-01-02 21:00:16 -0500
committercash <cash.costello@gmail.com>2012-01-02 21:00:16 -0500
commit83cbd76b2e11b7d832e212ce1ffc77da7a3dd2a6 (patch)
treee77fc18ea6b9402be0a653aeaf152b9231bad153 /lib/tidypics.php
parentbe94a34e652571eb61c3e306abfb7cce673823d7 (diff)
downloadelgg-83cbd76b2e11b7d832e212ce1ffc77da7a3dd2a6.tar.gz
elgg-83cbd76b2e11b7d832e212ce1ffc77da7a3dd2a6.tar.bz2
sorting albums added back
Diffstat (limited to 'lib/tidypics.php')
-rw-r--r--lib/tidypics.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/tidypics.php b/lib/tidypics.php
index 4e56ae829..7426a048e 100644
--- a/lib/tidypics.php
+++ b/lib/tidypics.php
@@ -141,6 +141,56 @@ function tidypics_is_upgrade_available() {
}
}
+/**
+ * This lists the photos in an album as sorted by metadata
+ *
+ * @param array $options
+ * @return string
+ */
+function tidypics_list_photos(array $options = array()) {
+ global $autofeed;
+ $autofeed = true;
+
+ $defaults = array(
+ 'offset' => (int) max(get_input('offset', 0), 0),
+ 'limit' => (int) max(get_input('limit', 10), 0),
+ 'full_view' => true,
+ 'list_type_toggle' => false,
+ 'pagination' => true,
+ );
+
+ $options = array_merge($defaults, $options);
+
+ $options['count'] = true;
+ $count = elgg_get_entities($options);
+
+ $album = get_entity($options['container_guid']);
+ if ($album) {
+ $guids = $album->getImageList();
+ $guids = array_slice($guids, $options['offset'], $options['limit']);
+ $options['guids'] = $guids;
+ unset($options['container_guid']);
+ }
+ $options['count'] = false;
+ $entities = elgg_get_entities($options);
+
+ $keys = array();
+ foreach ($entities as $entity) {
+ $keys[] = $entity->guid;
+ }
+ $entities = array_combine($keys, $entities);
+
+ $sorted_entities = array();
+ foreach ($guids as $guid) {
+ if (isset($entities[$guid])) {
+ $sorted_entities[] = $entities[$guid];
+ }
+ }
+
+ return elgg_view_entity_list($sorted_entities, $options);
+}
+
+
/*********************************************************************
* the functions below replace broken core functions or add functions
* that could/should exist in the core