From 4060b31ee034887cb31e8c91dee55556c8798b18 Mon Sep 17 00:00:00 2001 From: robtotoreb Date: Sat, 25 Feb 2012 14:53:10 -0700 Subject: Update views/default/forms/photos/admin/settings.php --- views/default/forms/photos/admin/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/default/forms/photos/admin/settings.php b/views/default/forms/photos/admin/settings.php index f4bafce78..16d5eb0ce 100644 --- a/views/default/forms/photos/admin/settings.php +++ b/views/default/forms/photos/admin/settings.php @@ -42,7 +42,7 @@ echo elgg_view('input/dropdown', array( echo ''; echo '
'; echo elgg_echo('tidypics:settings:im_path') . ' '; -echo elgg_view("input/text", array('name' => 'params[im_path]', 'value' => $$plugin->im_path)); +echo elgg_view("input/text", array('name' => 'params[im_path]', 'value' => $plugin->im_path)); echo '
'; -- cgit v1.2.3 From 2245c9d883959db535f5380ea8d5278982c05b5b Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Fri, 9 Mar 2012 16:03:39 -0800 Subject: Fixes #20. Removed space after FIELD in order by FIELD call. --- classes/TidypicsAlbum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/TidypicsAlbum.php b/classes/TidypicsAlbum.php index 3d7d12b32..ea9b5deef 100644 --- a/classes/TidypicsAlbum.php +++ b/classes/TidypicsAlbum.php @@ -190,7 +190,7 @@ class TidypicsAlbum extends ElggObject { $guidsString = implode(',', $list); $options = array( 'wheres' => array("e.guid IN ($guidsString)"), - 'order_by' => "FIELD (e.guid, $guidsString)", + 'order_by' => "FIELD(e.guid, $guidsString)", 'callback' => 'tp_guid_callback', 'limit' => ELGG_ENTITIES_NO_VALUE ); -- cgit v1.2.3 From 51f020d059980aaa391d90cb9aedbb89286dd620 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Fri, 9 Mar 2012 18:03:58 -0800 Subject: Fixes #19. Handling offset and limit in SQL to avoid pagination problems. --- lib/tidypics.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tidypics.php b/lib/tidypics.php index 38c6b31a8..1b230cbe2 100644 --- a/lib/tidypics.php +++ b/lib/tidypics.php @@ -167,7 +167,9 @@ function tidypics_list_photos(array $options = array()) { $album = get_entity($options['container_guid']); if ($album) { $guids = $album->getImageList(); - $guids = array_slice($guids, $options['offset'], $options['limit']); + // need to pass all the guids and handle the limit / offset in sql + // to avoid problems with the navigation + //$guids = array_slice($guids, $options['offset'], $options['limit']); $options['guids'] = $guids; unset($options['container_guid']); } @@ -187,6 +189,10 @@ function tidypics_list_photos(array $options = array()) { } } + // for this function count means the total number of entities + // and is required for pagination + $options['count'] = $count; + return elgg_view_entity_list($sorted_entities, $options); } -- cgit v1.2.3 From e6e33ca1a7afb00a855f57df5a5263674b23c93c Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Fri, 16 Mar 2012 13:27:03 -0700 Subject: Fixes #21, #22. Using TidypicsAlbum->viewImages() instead of tidypics_list_photos for listing photos. --- classes/TidypicsAlbum.php | 34 +++++++++++++++++++++++++++------- lib/tidypics.php | 17 +++++++++++++++++ views/default/object/album/full.php | 10 ++-------- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/classes/TidypicsAlbum.php b/classes/TidypicsAlbum.php index ea9b5deef..ad1a357de 100644 --- a/classes/TidypicsAlbum.php +++ b/classes/TidypicsAlbum.php @@ -110,21 +110,41 @@ class TidypicsAlbum extends ElggObject { /** * View a list of images * - * @param int $limit - * @param int $offset + * @param array $options Options to pass to elgg_view_entity_list() * @return string */ - public function viewImages($limit, $offset = 0) { - $images = $this->getImages($limit, $offset); - if (count($images) == 0) { + public function viewImages(array $options = array()) { + $count = $this->getSize(); + + if ($count == 0) { return ''; } - $count = $this->getSize(); + $defaults = array( + 'count' => $count, + 'limit' => 16, + 'offset' => max(get_input('offset'), 0), + 'full_view' => false, + 'list_type' => 'gallery', + 'list_type_toggle' => false, + 'pagination' => true, + 'gallery_class' => 'tidypics-gallery', + ); + + $options = array_merge($defaults, (array) $options); + $images = $this->getImages($options['limit'], $options['offset']); - return elgg_view_entity_list($images, $count, $offset, $limit, false, false, true); + if (count($images) == 0) { + return ''; + } + + return elgg_view_entity_list($images, $options); } + /** + * Returns the cover image entity + * @return TidypicsImage + */ public function getCoverImage() { return get_entity($this->getCoverImageGuid()); } diff --git a/lib/tidypics.php b/lib/tidypics.php index 1b230cbe2..16773f982 100644 --- a/lib/tidypics.php +++ b/lib/tidypics.php @@ -59,6 +59,12 @@ function tp_get_img_dir() { return $file->getFilenameOnFilestore() . 'image/'; } +/** + * Prepare vars for a form, pulling from an entity or sticky forms. + * + * @param type $entity + * @return type + */ function tidypics_prepare_form_vars($entity = null) { // input names => defaults $values = array( @@ -91,6 +97,11 @@ function tidypics_prepare_form_vars($entity = null) { return $values; } +/** + * Returns available image libraries. + * + * @return string + */ function tidypics_get_image_libraries() { $options = array(); if (extension_loaded('gd')) { @@ -144,6 +155,11 @@ function tidypics_is_upgrade_available() { /** * This lists the photos in an album as sorted by metadata * + * @todo this only supports a single album. The only case for use a + * procedural function like this instead of TidypicsAlbum::viewImgaes() is to + * fetch images across albums as a helper to elgg_get_entities(). + * This should function be deprecated or fixed to work across albums. + * * @param array $options * @return string */ @@ -180,6 +196,7 @@ function tidypics_list_photos(array $options = array()) { foreach ($entities as $entity) { $keys[] = $entity->guid; } + var_dump($options); $entities = array_combine($keys, $entities); $sorted_entities = array(); diff --git a/views/default/object/album/full.php b/views/default/object/album/full.php index ceb8b97aa..7b273c66e 100644 --- a/views/default/object/album/full.php +++ b/views/default/object/album/full.php @@ -48,14 +48,8 @@ if ($album->description) { 'class' => 'mbm', )); } -$body .= tidypics_list_photos(array( - 'container_guid' => $album->getGUID(), - 'limit' => 16, - 'full_view' => false, - 'list_type' => 'gallery', - 'list_type_toggle' => false, - 'gallery_class' => 'tidypics-gallery', -)); + +$body .= $album->viewImages(); echo elgg_view('object/elements/full', array( 'entity' => $album, -- cgit v1.2.3