Make it possible to set tilesperrow and tilesperpage through the API
authorChuck Hagenbuch <chuck@horde.org>
Mon, 9 Aug 2010 05:01:59 +0000 (01:01 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Mon, 9 Aug 2010 05:01:59 +0000 (01:01 -0400)
ansel/lib/View/GalleryRenderer/Base.php
ansel/lib/View/GalleryRenderer/GalleryLightbox.php

index 77e248b..aaaf4f2 100644 (file)
@@ -21,7 +21,7 @@ abstract class Ansel_View_GalleryRenderer_Base
 
     /**
      * The gallery id for this view's gallery
-     * (Convienience instead of $this->view->gallery->id)
+     * (Convenience instead of $this->view->gallery->id)
      *
      * @var integer
      */
@@ -128,8 +128,12 @@ abstract class Ansel_View_GalleryRenderer_Base
         $this->page = $this->view->page;
 
         /* Number perpage from prefs or config */
-        $this->perpage = min($prefs->getValue('tilesperpage'),
-                             $conf['thumbnail']['perpage']);
+        if ($this->view->tilesperpage) {
+            $this->perpage = $this->view->tilesperpage;
+        } else {
+            $this->perpage = min($prefs->getValue('tilesperpage'),
+                                 $conf['thumbnail']['perpage']);
+        }
 
         /* Calculate the starting and ending images on this page */
         $this->pagestart = ($this->page * $this->perpage) + 1;
index 8cf874d..9624990 100644 (file)
@@ -61,7 +61,7 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende
         }
 
         /* Don't bother if we are being called from the api */
-        if (empty($this->view->api)) {
+        if (!$this->view->api) {
             $option_edit = $this->view->gallery->hasPermission($GLOBALS['registry']->getAuth(),
                                                          Horde_Perms::EDIT);
             $option_select = $option_delete = $this->view->gallery->hasPermission(
@@ -91,11 +91,9 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende
             $pagerurl = new Horde_Url(str_replace(array('%g', '%s'), array($this->galleryId, $this->gallerySlug), urldecode($this->view->gallery_view_url)));
             $pagerurl->add($date_params)->setRaw(true);
         } else {
-            /*
-             * Build the pager url. Add the needed variables directly to the
-             * url instead of passing it as a preserved variable to the pager
-             * since the logic to build the URL is already in getUrlFor()
-             */
+            // Build the pager url. Add the needed variables directly to the
+            // url instead of passing it as a preserved variable to the pager
+            // since the logic to build the URL is already in getUrlFor()
             $pager_params =  array_merge(
                 array('gallery' => $this->galleryId,
                       'view' => 'Gallery',
@@ -129,7 +127,7 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende
             $jsvars['gallery_url'] = $pagerurl . '&';
         }
         /* Output js/css here if we are calling via the api */
-        if (!empty($this->view->api)) {
+        if ($this->view->api) {
             Ansel::attachStylesheet('lightbox.css', true);
             $includes = $GLOBALS['injector']->createInstance('Horde_Script_Files');
             $includes->add('accesskeys.js', 'horde', true, true);
@@ -139,7 +137,7 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende
         }
 
         /* Needed in the template files */
-        $tilesperrow = $prefs->getValue('tilesperrow');
+        $tilesperrow = $this->view->tilesperrow ? $this->view->tilesperrow : $prefs->getValue('tilesperrow');
         $cellwidth = round(100 / $tilesperrow);
         $count = 0;