Clean up the Image and Slideshow views.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 3 Aug 2009 18:12:46 +0000 (14:12 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 3 Aug 2009 18:27:17 +0000 (14:27 -0400)
Have Ansel_View_Slideshow extend Ansel_View_Image to get rid of duplicate code.

ansel/lib/View/Image.php
ansel/lib/View/Slideshow.php
ansel/templates/view/image.inc
ansel/templates/view/slideshow.inc

index dbc1a57..88b862c 100644 (file)
  */
 class Ansel_View_Image extends Ansel_View_Base
 {
+
+    protected $_slug;
+    protected $_page;
+    protected $_date;
+    protected $_mode;
+    protected $_style;
+    protected $_geometry;
+    protected $_imageList;
+    protected $_revList;
+    protected $_urls = array();
+
     /**
      * Const'r
      *
@@ -20,11 +31,8 @@ class Ansel_View_Image extends Ansel_View_Base
     {
         parent::__construct($params);
 
-        /* Get the image */
-        $image_id = $params['image_id'];
-
         /* Get the Ansel_Image */
-        $image = &$GLOBALS['ansel_storage']->getImage($image_id);
+        $image = &$GLOBALS['ansel_storage']->getImage($params['image_id']);
 
         /* Get the Ansel_Gallery */
         $this->gallery = $this->getGallery();
@@ -82,7 +90,6 @@ class Ansel_View_Image extends Ansel_View_Base
             exit;
         }
 
-
         /* Any script files we may need if not calling via the api */
         if (empty($this->_params['api'])) {
             Horde::addScriptFile('effects.js', 'horde', true);
@@ -113,134 +120,160 @@ class Ansel_View_Image extends Ansel_View_Base
      */
     public function html()
     {
-        global $browser, $conf, $prefs, $registry;
-
-        if (is_a($this->gallery, 'PEAR_Error')) {
-            echo htmlspecialchars($this->gallery->getMessage());
-            return;
-        }
+        $this->_prepare();
+        return $this->_html();
+    }
 
-        $page = isset($this->_params['page']) ? $this->_params['page'] : 0;
-        $galleryId = $this->gallery->id;
-        $gallerySlug = $this->gallery->get('slug');
-        $imageId = $this->resource->id;
-        $galleryOwner = $this->gallery->get('owner');
-        $date = $this->gallery->getDate();
+    /**
+     * Build variables needed to output the html
+     *
+     * @return void
+     */
+    protected function _prepare()
+    {
+        global $browser;
 
-        /* Allow overriding the configured view_mode */
-        if (isset($this->_params['mode'])) {
-            $mode = $this->_params['mode'];
-        } else {
-            $mode = $this->_params['mode'] = $this->gallery->get('view_mode');
-        }
+        /* Gallery slug and the page this image is one, if specified */
+        $this->_page = isset($this->_params['page']) ? $this->_params['page'] : 0;
+        $this->_slug = $this->gallery->get('slug');
 
-        /* Get any date infor the gallery has */
-        $date = $this->gallery->getDate();
+        /* Get any date info the gallery has */
+        $this->_date = $this->gallery->getDate();
 
-        $style = (empty($this->_params['style']) ?
+        $this->_style = (empty($this->_params['style']) ?
              $this->gallery->getStyle() :
              Ansel::getStyleDefinition($this->_params['style']));
 
         /* Make sure the screen view is loaded and get the geometry */
-        $geometry = $this->resource->getDimensions('screen');
-        if (is_a($geometry, 'PEAR_Error')) {
-            Horde::logMessage($geometry->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
-            $geometry = $conf['screen'];
-        }
-
-        /* Get comments before any output in sent. */
-        if (($conf['comments']['allow'] == 'all' || ($conf['comments']['allow'] == 'authenticated' && Horde_Auth::getAuth())) &&
-            $registry->hasMethod('forums/doComments')) {
-            $hasComments = true;
-            $url = empty($this->_params['comment_url']) ? null : $this->_params['comment_url'];
-            $comments = $registry->call('forums/doComments',
-                                        array('ansel', $imageId,
-                                              'commentCallback', true, null,
-                                              $url));
-            if (is_a($comments, 'PEAR_Error')) {
-                Horde::logMessage($comments, __FILE__, __LINE__, PEAR_LOG_DEBUG);
-                $comments = array();
-            }
-        } else {
-            $comments = array();
-            $hasComments = false;
+        try {
+            $this->_geometry = $this->resource->getDimensions('screen');
+        } catch (Horde_Exception $e) {
+            Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
+            $this->_geometry = $conf['screen'];
         }
 
-        /* Get the index of the starting image */
-        $imageList = $this->gallery->listImages();
-        $revList = array_flip($imageList);
-        $imageIndex = $revList[$imageId];
+        /* Get the image lists */
+        $this->_imageList = $this->gallery->listImages();
+        $this->_revList = array_flip($this->_imageList);
 
         /* Not needed when being called via api */
         if (empty($this->_params['api'])) {
-            $ecardurl = Horde::applicationUrl(
+            $this->_urls['ecard'] = Horde::applicationUrl(
                 Horde_Util::addParameter('img/ecard.php', array_merge(
-                                   array('gallery' => $galleryId,
-                                         'image' => $imageId),
-                                   $date)),
+                                   array('gallery' => $this->gallery->id,
+                                         'image' => $this->resource->id),
+                                   $this->_date)),
                 true);
 
+            /* Build the various urls */
             $imageActionUrl = Horde_Util::addParameter(
                 'image.php', array_merge(
-                array('gallery' => $galleryId,
-                      'image' => $imageId,
-                      'page' => $page),
-                $date));
+                array('gallery' => $this->gallery->id,
+                      'image' => $this->resource->id,
+                      'page' => $this->_page),
+                $this->_date));
+
+            /* Create the popup code seperately to avoid encoding issues */
+            $this->_urls['prop_popup'] = Horde::popupJs(
+              Horde::applicationUrl($imageActionUrl),
+              array('params' => array('actionID' => 'modify',
+                                      'ret' => 'image',
+                                      'gallery' => $this->gallery->id,
+                                      'image' => $this->resource->id,
+                                      'page' => $this->_page),
+                    'urlencode' => true));
+
+            $this->_urls['edit'] = Horde::applicationUrl(Horde_Util::addParameter($imageActionUrl, 'actionID', 'editimage'));
+            $this->_urls['delete'] = Horde::applicationUrl(Horde_Util::addParameter($imageActionUrl, 'actionID', 'delete'));
+            $this->_urls['download'] = Horde::applicationUrl(Horde_Util::addParameter('img/download.php', 'image', $this->resource->id), true);
+            $this->_urls['report'] = Horde_Util::addParameter( Horde::applicationUrl('report.php'),
+                                                               array('gallery' =>  $this->gallery->id,
+                                                                     'image' => $this->resource->id));
         }
 
+
+
         /* Check for an explicit gallery view url to use */
         if (!empty($this->_params['gallery_view_url'])) {
-            $galleryurl = str_replace(
-                array('%g', '%s'),
-                array($galleryId, $gallerySlug),
-                urldecode($this->_params['gallery_view_url']));
-                Horde_Util::addParameter($galleryurl, $date);
+            $this->_urls['gallery'] = Horde_Util::addParameter(
+                str_replace(array('%g', '%s'),
+                            array($this->gallery->id, $this->_slug),
+                            urldecode($this->_params['gallery_view_url'])), $this->_date);
         } else {
-            $galleryurl = Ansel::getUrlFor('view', array_merge(
-                                           array('gallery' => $galleryId,
-                                                 'slug' => $gallerySlug,
-                                                 'page' => $page,
+            $this->_urls['gallery'] = Ansel::getUrlFor('view', array_merge(
+                                           array('gallery' => $this->gallery->id,
+                                                 'slug' => $this->_slug,
+                                                 'page' => $this->_page,
                                                  'view' => 'Gallery'),
-                                           $date),
+                                           $this->_date),
                                            true);
         }
 
         /* Get the image src url */
-        $imageUrl = Ansel::getImageUrl($imageId, 'screen', true, $style['name']);
+        $this->_urls['imgsrc'] = Ansel::getImageUrl($this->resource->id, 'screen', true, $this->_style['name']);
 
         /* And a self url. Can't use Horde::selfUrl() since that would ignore
          * pretty urls. */
-        $selfUrl = Ansel::getUrlFor('view', array_merge(
-                                    array('gallery' => $galleryId,
-                                          'slug' => $gallerySlug,
-                                          'image' => $imageId,
+        $this->_urls['self'] = Ansel::getUrlFor('view', array_merge(
+                                    array('gallery' => $this->gallery->id,
+                                          'slug' => $this->_slug,
+                                          'image' => $this->resource->id,
                                           'view' => 'Image',
-                                          'page' => $page),
-                                    $date));
+                                          'page' => $this->_page),
+                                    $this->_date));
+    }
+
+    /**
+     * Image view specific HTML - done so we can extend View_Image for things
+     * like the slideshow view etc...
+     */
+    protected function _html()
+    {
+        global $conf, $registry, $prefs;
+
+        /* Starting image */
+        $imageIndex = $this->_revList[$this->resource->id];
 
+        /* Get comments before any output in sent. */
+        if (($conf['comments']['allow'] == 'all' || ($conf['comments']['allow'] == 'authenticated' && Horde_Auth::getAuth())) &&
+            $registry->hasMethod('forums/doComments')) {
+            $hasComments = true;
+            $url = empty($this->_params['comment_url']) ? null : $this->_params['comment_url'];
+            $comments = $registry->call('forums/doComments',
+                                        array('ansel', $this->resource->id,
+                                              'commentCallback', true, null,
+                                              $url));
+            if (is_a($comments, 'PEAR_Error')) {
+                Horde::logMessage($comments, __FILE__, __LINE__, PEAR_LOG_DEBUG);
+                $comments = array();
+            }
+        } else {
+            $comments = array();
+            $hasComments = false;
+        }
         /* Get the next and previous image ids */
-        if (isset($imageList[$imageIndex + 1])) {
-            $next = $imageList[$imageIndex + 1];
+        if (isset($this->_imageList[$imageIndex + 1])) {
+            $next = $this->_imageList[$imageIndex + 1];
         } else {
-            $next = $imageList[0];
+            $next = $this->_imageList[0];
         }
-        if (isset($imageList[$imageIndex - 1])) {
-            $prev = $imageList[$imageIndex - 1];
+        if (isset($this->_imageList[$imageIndex - 1])) {
+            $prev = $this->_imageList[$imageIndex - 1];
         } else {
-            $prev = $imageList[count($imageList) - 1];
+            $prev = $this->_imageList[count($this->_imageList) - 1];
         }
 
         /** Calculate the page number of the next/prev images */
         $perpage = $prefs->getValue('tilesperpage');
-        $pagestart = $page * $perpage;
-        $pageend = min(count($imageList), $pagestart + $perpage - 1);
-        $page_next = $page;
+        $pagestart = $this->_page * $perpage;
+        $pageend = min(count($this->_imageList), $pagestart + $perpage - 1);
+        $page_next = $this->_page;
 
-        if ($revList[$imageId] + 1 > $pageend) {
+        if ($this->_revList[$this->resource->id] + 1 > $pageend) {
             $page_next++;
         }
-        $page_prev = $page;
-        if ($revList[$imageId] - 1 < $pagestart) {
+        $page_prev = $this->_page;
+        if ($this->_revList[$this->resource->id] - 1 < $pagestart) {
             $page_prev--;
         }
 
@@ -248,48 +281,48 @@ class Ansel_View_Image extends Ansel_View_Base
         if (!empty($this->_params['image_view_url'])) {
             $prev_url = str_replace(
                 array('%i', '%g', '%s'),
-                array($prev, $galleryId, $gallerySlug),
+                array($prev, $this->gallery->id, $this->_slug),
                 urldecode($this->_params['image_view_url']));
         } else {
             $prev_url = Ansel::getUrlFor('view', array_merge(
-                array('gallery' => $galleryId,
-                      'slug' => $gallerySlug,
+                array('gallery' => $this->gallery->id,
+                      'slug' => $this->_slug,
                       'image' => $prev,
                       'view' => 'Image',
                       'page' => $page_prev),
-                $date));
+                $this->_date));
         }
-        $prvImgUrl = Ansel::getImageUrl($prev, 'screen', false, $style['name']);
+        $prvImgUrl = Ansel::getImageUrl($prev, 'screen', false, $this->_style['name']);
 
         /* Next image link */
         if (!empty($this->_params['image_view_url'])) {
             $next_url = str_replace(
                 array('%i', '%g', '%s'),
-                array($prev, $galleryId, $gallerySlug),
+                array($prev, $this->gallery->id, $this->_slug),
                 urldecode($this->_params['image_view_url']));
         } else {
             $next_url = Ansel::getUrlFor('view', array_merge(
-                array('gallery' => $galleryId,
-                      'slug' => $gallerySlug,
+                array('gallery' => $this->gallery->id,
+                      'slug' => $this->_slug,
                       'image' => $next,
                       'view' => 'Image',
                       'page' => $page_next),
-                $date));
+                $this->_date));
         }
-        $nextImgUrl = Ansel::getImageUrl($next, 'screen', false, $style['name']);
+        $nextImgUrl = Ansel::getImageUrl($next, 'screen', false, $this->_style['name']);
 
         /* Slideshow link */
         if (!empty($this->_params['slideshow_link'])) {
-            $slideshow_url = str_replace(array('%i', '%g'),
-                                         array($imageId, $galleryId),
+            $this->_urls['slideshow'] = str_replace(array('%i', '%g'),
+                                         array($this->resource->id, $this->gallery->id),
                                          urldecode($this->_params['slideshow_link']));
         } else {
-            $slideshow_url = Horde::applicationUrl(
+            $this->_urls['slideshow'] = Horde::applicationUrl(
                 Horde_Util::addParameter('view.php', array_merge(
-                                   array('gallery' => $galleryId,
-                                         'image' => $imageId,
+                                   array('gallery' => $this->gallery->id,
+                                         'image' => $this->resource->id,
                                          'view' => 'Slideshow'),
-                                   $date)));
+                                   $this->_date)));
         }
 
         $commentHtml = '';
@@ -326,7 +359,7 @@ class Ansel_View_Image extends Ansel_View_Base
 
             // Faces
             if ($conf['faces']['driver']) {
-                $this->addWidget(Ansel_Widget::factory('ImageFaces', array('selfUrl' => $selfUrl)));
+                $this->addWidget(Ansel_Widget::factory('ImageFaces', array('selfUrl' => $this->_urls['self'])));
             }
 
             // Links
@@ -335,7 +368,7 @@ class Ansel_View_Image extends Ansel_View_Base
             /* In line caption editing */
             if ($this->gallery->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT)) {
                 $imple = Horde_Ajax_Imple::factory(array('ansel', 'EditCaption'),
-                                                array('id' => $imageId,
+                                                array('id' => $this->resource->id,
                                                       'domid' => "Caption",
                                                       'cols' => 120));
                 $imple->attach();
index 7ebd00c..605c839 100644 (file)
  * @author  Michael J. Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
-class Ansel_View_Slideshow extends Ansel_View_Base
+class Ansel_View_Slideshow extends Ansel_View_Image
 {
     /**
-     * @static
+     * const'r
      *
-     * @return Ansel_View_Slidshow  The view object.
-     *
-     * @TODO use exceptions from the constructor instead of static
-     * instance-getting.
      */
     public function __construct($params = array())
     {
         parent::__construct($params);
-        if (empty($params['image_id'])) {
-            $image_id = Horde_Util::getFormData('image');
-        } else {
-            $image_id = $params['image_id'];
-        }
-        $image = $GLOBALS['ansel_storage']->getImage($image_id);
-        $this->gallery = $this->getGallery($image->gallery);
-        $this->image = $image;
-
-        // Check user age
-        if (!$this->gallery->isOldEnough()) {
-           $date = Ansel::getDateParameter(
-                array('year' => !empty($this->_params['year']) ? $this->_params['year'] : 0,
-                      'month' => !empty($this->_params['month']) ? $this->_params['month'] : 0,
-                      'day' => !empty($this->_params['day']) ? $this->_params['day'] : 0));
-
-                $url = Ansel::getUrlFor('view', array_merge(
-                    array('gallery' => $this->gallery->id,
-                          'slug' => empty($params['slug']) ? '' : $params['slug'],
-                          'page' => empty($params['page']) ? 0 : $params['page'],
-                          'view' => 'Slideshow',
-                          'image' => $image->id),
-                    $date),
-                    true);
-
-            $params = array('gallery' => $this->gallery->id, 'url' => $url);
-
-            header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('disclamer.php'), $params, null, false));
-            exit;
-        }
-
-       // Check password
-        if ($this->gallery->hasPasswd()) {
-           $date = Ansel::getDateParameter(
-                array('year' => isset($this->_params['year']) ? $this->_params['year'] : 0,
-                      'month' => isset($this->_params['month']) ? $this->_params['month'] : 0,
-                      'day' => isset($this->_params['day']) ? $this->_params['day'] : 0));
-
-                $url = Ansel::getUrlFor('view', array_merge(
-                    array('gallery' => $this->gallery->id,
-                          'slug' => empty($params['slug']) ? '' : $params['slug'],
-                          'page' => empty($params['page']) ? 0 : $params['page'],
-                          'view' => 'Slideshow',
-                          'image' => $image->id),
-                    $date),
-                    true);
-
-            $params = array('gallery' => $this->gallery->id, 'url' => $url);
-
-            header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('protect.php'), $params, null, false));
-            exit;
-        }
-
-
-        Horde::addScriptFile('effects.js', 'horde', true);
-        Horde::addScriptFile('stripe.js', 'horde', true);
         Horde::addScriptFile('slideshow.js', 'ansel', true);
     }
 
-    /**
-     * Get the title for this view.
-     *
-     * @return string  The title.
-     */
-    public function getTitle()
+    protected function _html()
     {
-        return $this->resource->filename;
-    }
-
-    /**
-     * Get the HTML representing this view.
-     *
-     * @return string  The HTML.
-     */
-    public function html()
-    {
-        global $browser, $conf, $prefs, $registry;
-
-        $page = Horde_Util::getFormData('page', 0);
-        $galleryId = $this->gallery->id;
-        $imageId = $this->resource->id;
-        $galleryOwner = $this->gallery->get('owner');
-        $style = $this->gallery->getStyle();
-
-        /* Get date info to pass along the links */
-        if (!empty($this->_params['year'])) {
-            $date = Ansel::getDateParameter(
-                array('year' => $this->_params['year'],
-                      'month' => $this->_params['month'],
-                      'day' => $this->_params['day']));
-        } else {
-            $date = array();
-        }
-
-        /* Get the index of the starting image */
-        $imageList = $this->gallery->listImages();
-
-        $style = $this->gallery->getStyle();
-        $revList = array_flip($imageList);
-        $imageIndex = $revList[$imageId];
-        if (isset($imageList[$imageIndex - 1])) {
-            $prev = $imageList[$imageIndex - 1];
-        } else {
-            $prev = $imageList[count($imageList) - 1];
-        }
-
-        $ecardurl = Horde_Util::addParameter('img/ecard.php',
-                                       array('gallery' => $galleryId,
-                                             'image' => $imageId));
-        $galleryurl = Horde_Util::addParameter('view.php', array_merge(
-            array('gallery' => $galleryId,
-                  'page' => $page),
-            $date));
-        $imageActionUrl = Horde_Util::addParameter('image.php', array_merge(
-            array('gallery' => $galleryId,
-                  'image' => $imageId,
-                  'page' => $page),
-            $date));
-        $imageUrl = Ansel::getImageUrl($imageId, 'screen', false, $style['name']);
-
+        global $registry, $prefs;
+        $imageIndex = $this->_revList[$this->resource->id];
         ob_start();
         require ANSEL_TEMPLATES . '/view/slideshow.inc';
         return ob_get_clean();
+
     }
 
     public function viewType()
index ca28593..ef5c965 100644 (file)
@@ -8,12 +8,12 @@ document.observe('dom:loaded', function() {
                                                    afterFinish: function() {$$('.imgloading').each(function(n) { n.setStyle({visibility: 'hidden'});});
                                                                             new Effect.Appear($('Caption'), { duration: 0.5 });
                                                                              }});
-                nextImg = new Image();
-                prvImg = new Image();
+                var nextImg = new Image();
+                var prvImg = new Image();
                 nextImg.src = "<?php echo $nextImgUrl ?>";
                 prvImg.src = "<?php echo $prvImgUrl ?>";
         });
-        new Effect.Opacity('photodiv', {to: 0, duration: 0.5, afterFinish: function() {$('photodiv').src = "<?php echo $imageUrl ?>"} });
+        new Effect.Opacity('photodiv', {to: 0, duration: 0.5, afterFinish: function() {$('photodiv').src = "<?php echo $this->_urls['imgsrc'] ?>"} });
 
         // Arrow keys for navigation
         document.observe('keydown', arrowHandler);
@@ -50,35 +50,30 @@ function arrowHandler(e)
 <h1 class="header" id="PhotoName"><?php echo Ansel::getBreadCrumbs(); ?></h1>
 <table style="width: 100%; border-collapse: collapse">
  <tr>
-  <td valign="top" style="background-color:<?php echo $style['background']; ?>;">
+  <td valign="top" style="background-color:<?php echo $this->_style['background']; ?>;">
     <?php
         $needSeperator = false;
         $actionHTML = '';
         if ($this->gallery->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT) && empty($this->_params['api'])) {
             $needSeperator = true;
-            $actionHTML .= Horde::link('#', '', '', '_blank', Horde::popupJs(Horde::applicationUrl($imageActionUrl), array('params' => array('actionID' => 'modify', 'ret' => 'image'), 'urlencode' => true)) . 'return false;', '', '', array('id' => 'image_properties_link')) . _("Properties") . '</a>';
-            $actionHTML .= ' | ' . Horde::link(Horde::applicationUrl(Horde_Util::addParameter($imageActionUrl, 'actionID', 'editimage')), '', '', '', '', '', '', array('id' => 'image_edit_link')) . _("Edit") . '</a>';
+            $actionHTML .= Horde::link('#', '', '', '_blank', $this->_urls['prop_popup'] . 'return false;', '', '', array('id' => 'image_properties_link')) . _("Properties") . '</a>';
+            $actionHTML .= ' | ' . Horde::link($this->_urls['edit'], '', '', '', '', '', '', array('id' => 'image_edit_link')) . _("Edit") . '</a>';
         }
         if ($this->gallery->hasPermission(Horde_Auth::getAuth(), PERMS_DELETE) && empty($this->_params['api'])) {
-            $actionHTML .= ' | ' . Horde::link(Horde::applicationUrl(Horde_Util::addParameter($imageActionUrl, 'actionID', 'delete')), '', '', '', 'return window.confirm(\'' . addslashes(sprintf(_("Do you want to permanently delete ''%s''?"), $this->resource->filename)) . '\');', '', '', array('id' => 'image_delete_link')) . _("Delete") . '</a>';
+            $actionHTML .= ' | ' . Horde::link($this->_urls['delete'], '', '', '', 'return window.confirm(\'' . addslashes(sprintf(_("Do you want to permanently delete ''%s''?"), $this->resource->filename)) . '\');', '', '', array('id' => 'image_delete_link')) . _("Delete") . '</a>';
         }
-        if (!empty($conf['ecard']['enable']) && !empty($ecardurl)) {
-            $actionHTML .= (empty($this->_params['api']) && $needSeperator ? ' | ' : '') . Horde::link($ecardurl, '', '', '_blank', '', '', '', array('id' => 'image_ecard_link')) . _("Send an Ecard"); $needSeperator = true . '</a>';
+        if (!empty($conf['ecard']['enable']) && !empty($this->_urls['ecard'])) {
+            $actionHTML .= (empty($this->_params['api']) && $needSeperator ? ' | ' : '') . Horde::link($this->_urls['ecard'], '', '', '_blank', '', '', '', array('id' => 'image_ecard_link')) . _("Send an Ecard"); $needSeperator = true . '</a>';
         }
         if ($this->gallery->canDownload()) {
-            $actionHTML .= (empty($this->_params['api']) && $needSeperator ? ' | ' : '') . Horde::link(Horde::applicationUrl(Horde_Util::addParameter('img/download.php', 'image', $imageId), true), '', '', '', '', '', '', array('id' => 'image_download_link')) . _("Download Original Photo"); $needSeperator = true . '</a>';
+            $actionHTML .= (empty($this->_params['api']) && $needSeperator ? ' | ' : '') . Horde::link($this->_urls['download'], '', '', '', '', '', '', array('id' => 'image_download_link')) . _("Download Original Photo"); $needSeperator = true . '</a>';
         }
         if (empty($this->_params['api']) && $this->gallery->get('owner') != Horde_Auth::getAuth() &&
             !empty($GLOBALS['conf']['report_content']['driver']) &&
             (($conf['report_content']['allow'] == 'authenticated' && Horde_Auth::isAuthenticated()) ||
              $conf['report_content']['allow'] == 'all')) {
 
-            $reporturl = Horde_Util::addParameter(
-                Horde::applicationUrl('report.php'),
-                                      array('gallery' =>  $this->gallery->id,
-                                      'image' => $imageId));
-
-            $actionHTML .=  ($needSeperator ? ' | ' : '' ) . Horde::link($reporturl) . _("Report") . '</a>';
+            $actionHTML .=  ($needSeperator ? ' | ' : '' ) . Horde::link($this->_urls['report']) . _("Report") . '</a>';
         }
         if (strlen($actionHTML)) {
             echo '<div class="control anselActions" style="text-align:center;">' . $actionHTML . '</div>';
@@ -88,24 +83,24 @@ function arrowHandler(e)
      <?php echo Horde::fullSrcImg('loading.gif', array('dir' => $registry->getImageDir('horde'), 'attr' => 'class="imgloading"'));?>
      <?php
      if (empty($this->_params['hide_slideshow'])) {
-         echo '<a style="display:none;" href="' . $slideshow_url . '" class="ssPlay" title="' . _("Start Slideshow") . '">' .
+         echo '<a style="display:none;" href="' . $this->_urls['slideshow'] . '" class="ssPlay" title="' . _("Start Slideshow") . '">' .
                Horde::fullSrcImg('slideshow_play.png', array('attr' => 'alt="' .  _("Play") . '"')) . '</a>';
      }
      echo '<a href="' . $prev_url . '" alt="<" id="PrevLink" title="' . _("Previous") . '">' .
            Horde::fullSrcImg('slideshow_prev.png', array('attr' => 'alt="' . _("Previous") . '"')) . '</a>';
      echo '<a href="' . $next_url . '" alt=">" id="NextLink"  title="' . _("Next") . '">' .
            Horde::fullSrcImg('slideshow_next.png', array('attr' => 'alt="' . _("Next") . '"')) . '</a>';
-     echo '<a href="' . $galleryurl . '" id="GalleryLink" title="' . _("Back to gallery") . '">' .
+     echo '<a href="' . $this->_urls['gallery'] . '" id="GalleryLink" title="' . _("Back to gallery") . '">' .
            Horde::fullSrcImg('galleries.png', array('attr' => 'alt="' . _("Back to gallery") . '"')) . '</a>';
      ?>
 
     </div>
     <div id="Container">
      <noscript>
-      <?php echo '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($this->resource->filename) . '" />' ?>
+      <?php echo '<img src="' . $this->_urls['imgsrc'] . '" alt="' . htmlspecialchars($this->resource->filename) . '" />' ?>
      </noscript>
-     <?php echo Horde::img('blank.gif', '', array('id' => 'photodiv', 'width' => $geometry['width'], 'height' => $geometry['height']), $registry->getImageDir('horde')) ?>
-     <div id="CaptionContainer" style="width:<?php echo $geometry['width']?>px;">
+     <?php echo Horde::img('blank.gif', '', array('id' => 'photodiv', 'width' => $this->_geometry['width'], 'height' => $this->_geometry['height']), $registry->getImageDir('horde')) ?>
+     <div id="CaptionContainer" style="width:<?php echo $this->_geometry['width']?>px;">
      <p id="Caption" style="display:none;">
        <?php echo Horde_Text_Filter::filter($this->resource->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO)) ?>
      </p>
@@ -115,14 +110,14 @@ function arrowHandler(e)
      <?php echo Horde::fullSrcImg('loading.gif', array('dir' => $registry->getImageDir('horde'), 'attr' => 'class="imgloading"'));?>
      <?php
      if (empty($this->_params['hide_slideshow'])) {
-         echo '<a style="display:none;" href="' . $slideshow_url . '" class="ssPlay" title="' . _("Start Slideshow") . '">' .
+         echo '<a style="display:none;" href="' . $this->_urls['slideshow'] . '" class="ssPlay" title="' . _("Start Slideshow") . '">' .
                Horde::fullSrcImg('slideshow_play.png', array('attr' => 'alt="' .  _("Play") . '"')) . '</a>';
      }
      echo '<a href="' . $prev_url . '" alt="<" id="PrevLink" title="' . _("Previous") . '">' .
            Horde::fullSrcImg('slideshow_prev.png', array('attr' => 'alt="' . _("Previous") . '"')) . '</a>';
      echo '<a href="' . $next_url . '" alt=">" id="NextLink"  title="' . _("Next") . '">' .
            Horde::fullSrcImg('slideshow_next.png', array('attr' => 'alt="' . _("Next") . '"')) . '</a>';
-     echo '<a href="' . $galleryurl . '" id="GalleryLink" title="' . _("Back to gallery") . '">' .
+     echo '<a href="' . $this->_urls['gallery'] . '" id="GalleryLink" title="' . _("Back to gallery") . '">' .
            Horde::fullSrcImg('galleries.png', array('attr' => 'alt="' . _("Back to gallery") . '"')) . '</a>';
      ?>
     </div>
index 559e9ef..60b0a91 100644 (file)
@@ -5,7 +5,7 @@ SlideController.initialize(<?php echo $this->json() ?>, <?php echo $imageIndex ?
 
 function stopSlideShow()
 {
-    location.href = "<?php echo Horde::applicationUrl($galleryurl, true) ?>&image=" + SlideController.photos[SlideController.photoId][3] + "&view=Image&page=" + SlideController.photos[SlideController.photoId][4];
+    location.href = "<?php echo Horde::applicationUrl($this->_urls['gallery'], true) ?>?image=" + SlideController.photos[SlideController.photoId][3] + "&view=Image&page=" + SlideController.photos[SlideController.photoId][4];
 }
 </script>
 
@@ -14,23 +14,23 @@ function stopSlideShow()
  <tr class="control">
   <td>
     <?php if ($this->gallery->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT)): ?>
-        <?php echo Horde::link(Horde::applicationUrl(Horde_Util::addParameter($imageActionUrl, array('actionID' => 'modify', 'share' => $this->gallery->getName(), 'ret' => 'image'))), '', '', '_blank', 'SlideController.pause();' . Horde::popupJs(Horde::applicationUrl($imageActionUrl), array('params' => array('actionID' => 'modify', 'share' => $this->gallery->getName(), 'ret' => 'image'), 'urlencode' => true)) . 'return false;', '', '', array('id' => 'image_properties_link')) . _("Properties") ?></a>
-      | <?php echo Horde::link(Horde::applicationUrl(Horde_Util::addParameter($imageActionUrl, 'actionID', 'editimage')), '', '', '', '', '', '', array('id' => 'image_edit_link')) . _("Edit") ?></a>
+        <?php echo Horde::link('#', '', '', '_blank', 'SlideController.pause();' . $this->_urls['prop_popup'], '', '', array('id' => 'image_properties_link')) . _("Properties") ?></a>
+      | <?php echo Horde::link(Horde::applicationUrl($this->_urls['edit']), '', '', '', '', '', '', array('id' => 'image_edit_link')) . _("Edit") ?></a>
     <?php endif; ?>
     <?php if ($this->gallery->hasPermission(Horde_Auth::getAuth(), PERMS_DELETE)): ?>
-      | <?php echo Horde::link(Horde::applicationUrl(Horde_Util::addParameter($imageActionUrl, 'actionID', 'delete')), '', '', '', 'return window.confirm(\'' . addslashes(sprintf(_("Do you want to permanently delete \"%s\"?"), $this->image->filename)) . '\');', '', '', array('id' => 'image_delete_link')) . _("Delete") ?></a>
+      | <?php echo Horde::link($this->_urls['delete'], '', '', '', 'return window.confirm(\'' . addslashes(sprintf(_("Do you want to permanently delete \"%s\"?"), $this->resource->filename)) . '\');', '', '', array('id' => 'image_delete_link')) . _("Delete") ?></a>
     <?php endif; ?>
   </td>
   <td class="rightAlign">
 
 <?php if (!empty($conf['ecard']['enable'])): ?>
-    <?php echo Horde::link($ecardurl, '', '', '_blank', 'SlideController.pause();' . Horde::popupJs($ecardurl, array('urlencode' => true)) . 'return false;', '', '', array('id' => 'image_ecard_link')) . _("Send an Ecard") ?></a> |
+    <?php echo Horde::link($this->_urls['ecard'], '', '', '_blank', 'SlideController.pause();' . Horde::popupJs($ecardurl, array('urlencode' => true)) . 'return false;', '', '', array('id' => 'image_ecard_link')) . _("Send an Ecard") ?></a> |
 <?php endif; ?>
-    <?php echo Horde::link(Horde::applicationUrl(Horde_Util::addParameter('img/download.php', 'image', $imageId)), '', '', '', 'SlideController.pause();', '', '', array('id' => 'image_download_link')) . _("Download Original Photo") ?></a>
+    <?php echo Horde::link($this->_urls['download'], '', '', '', 'SlideController.pause();', '', '', array('id' => 'image_download_link')) . _("Download Original Photo") ?></a>
   </td>
  </tr>
 </table>
-<table width="100%" cellpadding="0" cellspacing="0" style="background-color:<?php echo $style['background']; ?>;">
+<table width="100%" cellpadding="0" cellspacing="0" style="background-color:<?php echo $this->_style['background']; ?>;">
  <tr>
   <td>
     <div class="slideControls">
@@ -48,7 +48,7 @@ function stopSlideShow()
   <tr>
    <td style="margin:5px;height:<?php echo $GLOBALS['conf']['screen']['height'] ?>px;vertical-align:top;">
      <div id="Container">
-      <?php echo Horde::img('blank.gif', '', array('id' => 'Photo', 'style' => 'display:none;'), $registry->getImageDir('horde')) ?>
+      <?php echo Horde::img('blank.gif', '', array('id' => 'Photo', 'style' => 'display:none;', 'width' => $this->_geometry['width'], 'height' => $this->_geometry['height']), $registry->getImageDir('horde')) ?>
      </div>
    </td>
   </tr>