]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #21, #22. Using TidypicsAlbum->viewImages() instead of tidypics_list_photos...
authorBrett Profitt <brett.profitt@gmail.com>
Fri, 16 Mar 2012 20:27:03 +0000 (13:27 -0700)
committerBrett Profitt <brett.profitt@gmail.com>
Fri, 16 Mar 2012 20:27:03 +0000 (13:27 -0700)
classes/TidypicsAlbum.php
lib/tidypics.php
views/default/object/album/full.php

index ea9b5deef5c9c996e588be3cda98df30b003cc09..ad1a357de97ec4170375990f60545432e8c0ba93 100644 (file)
@@ -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());
        }
index 1b230cbe250b86414865100f85864c4da80e9679..16773f98253c399f6a465c8ecfca5b3916699b6c 100644 (file)
@@ -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();
index ceb8b97aa16a5f6fd4e467556c91131e2c0281e4..7b273c66eb59ff1a6cfc24fdb3b1fd0279a262a1 100644 (file)
@@ -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,