Use injector for Ansel_Storage.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 13 Jun 2010 22:18:33 +0000 (18:18 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 13 Jun 2010 22:18:33 +0000 (18:18 -0400)
Introduces a new Ansel_Config class for setting ansel config values that
might change during runtime, such as $scope.  The Ansel_Storage factory uses
Ansel_Config from the injector to return the proper storage scope. So, to
use a scope other than the default 'ansel' scope, you need to set it as:

$GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', 'foo');

80 files changed:
ansel/disclamer.php
ansel/edit_dates.php
ansel/faces/claim.php
ansel/faces/custom.php
ansel/faces/gallery.php
ansel/faces/image.php
ansel/faces/name.php
ansel/faces/report.php
ansel/gallery.php
ansel/gallery/captions.php
ansel/gallery/delete.php
ansel/gallery/sort.php
ansel/group.php
ansel/image.php
ansel/img/download.php
ansel/img/ecard.php
ansel/img/full.php
ansel/img/index.php
ansel/img/mini.php
ansel/img/prettythumb.php
ansel/img/screen.php
ansel/img/thumb.php
ansel/img/upload.php
ansel/img/upload_preview.php
ansel/lib/Ajax/Imple/EditCaption.php
ansel/lib/Ajax/Imple/EditFaces.php
ansel/lib/Ajax/Imple/GallerySlugCheck.php
ansel/lib/Ajax/Imple/ImageSaveGeotag.php
ansel/lib/Ajax/Imple/LocationAutoCompleter.php
ansel/lib/Ajax/Imple/TagActions.php
ansel/lib/Ansel.php
ansel/lib/Api.php
ansel/lib/Application.php
ansel/lib/Block/gallery.php
ansel/lib/Block/my_galleries.php
ansel/lib/Block/random_photo.php
ansel/lib/Block/recent_comments.php
ansel/lib/Block/recently_added.php
ansel/lib/Block/recently_added_geodata.php
ansel/lib/Config.php [new file with mode: 0644]
ansel/lib/Faces/Base.php
ansel/lib/Gallery.php
ansel/lib/GalleryMode/Date.php
ansel/lib/GalleryMode/Normal.php
ansel/lib/Image.php
ansel/lib/ImageView.php
ansel/lib/ImageView/PolaroidThumb.php
ansel/lib/ImageView/PrettyThumb.php
ansel/lib/ImageView/ShadowSharpThumb.php
ansel/lib/Injector/Factory/Storage.php
ansel/lib/Storage.php
ansel/lib/Tags.php
ansel/lib/Tile/Image.php
ansel/lib/View/Base.php
ansel/lib/View/Embedded.php
ansel/lib/View/EmbeddedRenderer/GalleryLink.php
ansel/lib/View/EmbeddedRenderer/Mini.php
ansel/lib/View/GalleryRenderer/Gallery.php
ansel/lib/View/GalleryRenderer/GalleryLightbox.php
ansel/lib/View/Image.php
ansel/lib/View/List.php
ansel/lib/View/Results.php
ansel/lib/Widget/Geotag.php
ansel/lib/Widget/OtherGalleries.php
ansel/lib/Widget/OwnerFaces.php
ansel/lib/Widget/SimilarPhotos.php
ansel/map_edit.php
ansel/perms.php
ansel/preview.php
ansel/protect.php
ansel/report.php
ansel/rss.php
ansel/scripts/all_images_exif_to_tags.php
ansel/scripts/ansel.php
ansel/scripts/recursive_import.php
ansel/scripts/remote_import.php
ansel/templates/gallery/delete_confirmation.inc
ansel/templates/group/category.inc
ansel/templates/group/owner.inc
ansel/xppublish.php

index 63d3c8c..09989e9 100644 (file)
@@ -13,7 +13,7 @@ Horde_Registry::appInit('ansel');
 
 $vars = Horde_Variables::getDefaultVariables();
 try {
-    $gallery = $ansel_storage->getGallery($vars->get('gallery'));
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($vars->get('gallery'));
 } catch (Ansel_Exception $e) {
     $notification->push($gallery->getMessage());
     header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
index f2977d6..2eae395 100644 (file)
@@ -18,7 +18,7 @@ $page = Horde_Util::getFormData('page', 0);
 
 /* If we have a single gallery, check perms now */
 if (!empty($gallery_id)) {
-    $gallery = $ansel_storage->getGallery($gallery_id);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $notification->push(_("You are not allowed to edit these photos."), 'horde.error');
         echo Horde::wrapInlineScript(array(
@@ -47,10 +47,10 @@ if ($actionID == 'edit_dates') {
     $count = 0;
     foreach (array_keys($images) as $image_id) {
         try {
-            $image = $ansel_storage->getImage($image_id);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
             if (empty($gallery_id)) {
                 // Images might be from different galleries
-                $gallery = $ansel_storage->getGallery($image->gallery);
+                $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
                 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                     continue;
                 }
@@ -82,7 +82,7 @@ $html = '';
 foreach ($keys as $key) {
     $html .= '<img src="' . Ansel::getImageUrl($key, 'mini', false) . '" style="margin:2px;" alt="[thumbnail]" />';
 }
-$image = $ansel_storage->getImage(array_pop($keys));
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(array_pop($keys));
 /* Display the form */
 $vars->set('image', $images);
 $vars->set('gallery', $gallery_id);
index f32f16c..c74cdac 100644 (file)
@@ -35,7 +35,7 @@ if ($form->validate()) {
         $notification->push(_("Action was cancelled."), 'horde.warning');
     } else {
         $report = Ansel_Report::factory();
-        $gallery = $ansel_storage->getGallery($face['gallery_id']);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($face['gallery_id']);
 
         $face_link = Horde::applicationUrl('faces/custom.php', true)->add(
             array('name' => $vars->get('person'),
index 9b600d9..e6c65d9 100644 (file)
@@ -24,14 +24,14 @@ if (!empty($url)) {
 $form_post = Horde::applicationUrl('faces/savecustom.php')->add($urlparams);
 
 try {
-    $image = $ansel_storage->getImage($image_id);
+    $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
 } catch (Ansel_Exception $e) {
     $notification->push($image);
     header('Location: ' . Horde::applicationUrl('list.php'));
     exit;
 }
 
-$gallery = $ansel_storage->getGallery($image->gallery);
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
     $notification->push(_("Access denied editing the photo."));
     header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $image->gallery)));
index 7a75169..b30ddb8 100644 (file)
@@ -22,7 +22,7 @@ if (empty($gallery_id)) {
     exit;
 }
 try {
-    $gallery = $ansel_storage->getGallery($gallery_id);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
 } catch (Ansel_Exception $e) {
     $notification->push($e->getMessage(), 'horde.error');
     header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $gallery_id)));
index 3ba044e..ff88ee2 100644 (file)
@@ -24,7 +24,7 @@ $result = $faces->getImageFacesData($image_id);
 // Attempt to get faces from the picture if we don't already have results,
 // or if we were asked to explicitly try again.
 if (($reload || empty($result))) {
-    $image = $ansel_storage->getImage($image_id);
+    $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     try {
         $image->createView('screen');
         $result = $faces->getFromPicture($image_id, $autocreate);
index 0af49df..32af2a7 100644 (file)
@@ -17,8 +17,8 @@ $image_id = (int)Horde_Util::getFormData('image');
 $face_id = (int)Horde_Util::getFormData('face');
 $name = Horde_Util::getFormData('name');
 
-$image = &$ansel_storage->getImage($image_id);
-$gallery = &$ansel_storage->getGallery($image->gallery);
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
+$gallery = $$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()>getGallery($image->gallery);
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
     throw new Horde_Exception('Access denied editing the photo.');
 }
index bd1456c..59a1122 100644 (file)
@@ -39,7 +39,7 @@ if ($form->validate()) {
     } else {
         require ANSEL_BASE . '/lib/Report.php';
         $report = Ansel_Report::factory();
-        $gallery = $ansel_storage->getGallery($face['gallery_id']);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($face['gallery_id']);
 
         $face_link = Horde::applicationUrl('faces/face.php', true)->add(
                 array('name' => $vars->get('person'),
index eb6f463..33cc228 100644 (file)
@@ -45,7 +45,7 @@ case 'addchild':
     // permissions to add to it.
     $parentId = Horde_Util::getFormData('gallery');
     try {
-        $parent = $ansel_storage->getGallery($parentId);
+        $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($parentId);
     } catch (Ansel_Exception $e) {
         $notification->push($e->getMessage(), 'horde.error');
         header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
@@ -79,7 +79,7 @@ case 'addchild':
 
 case 'downloadzip':
     $galleryId = Horde_Util::getFormData('gallery');
-    $gallery = $ansel_storage->getGallery($galleryId);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
     if (!$registry->getAuth() ||
         !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
 
@@ -95,7 +95,7 @@ case 'modify':
     $galleryId = Horde_Util::getFormData('gallery');
 
     try {
-        $gallery = $ansel_storage->getGallery($galleryId);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
          // Set up the gallery attributes.
         $gallery_name = $gallery->get('name');
         $gallery_desc = $gallery->get('desc');
@@ -155,10 +155,10 @@ case 'save':
         $gallery_parent = null;
     }
     if ($galleryId &&
-        ($exists = $ansel_storage->galleryExists($galleryId)) === true) {
+        ($exists = ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) === true)) {
 
         // Modifying an existing gallery.
-        $gallery = $ansel_storage->getGallery($galleryId);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
         if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
             $notification->push(sprintf(_("Access denied saving gallery \"%s\"."), $gallery->get('name')), 'horde.error');
         } else {
@@ -189,7 +189,7 @@ case 'save':
             }
             if ($gallery_parent != $old_parent_id) {
                 if (!is_null($gallery_parent)) {
-                    $new_parent = $ansel_storage->getGallery($gallery_parent);
+                    $new_parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent);
                 } else {
                     $new_parent = null;
                 }
@@ -212,7 +212,7 @@ case 'save':
         // Is this a new subgallery?
         if ($gallery_parent) {
             try {
-                $parent = $ansel_storage->getGallery($gallery_parent);
+                $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent);
             } catch (Ansel_Exception $e) {
                 $notification->push($e->getMessage(), 'horde.error');
                 header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true)));
@@ -243,7 +243,7 @@ case 'save':
         $parent = (!empty($gallery_parent)) ? $gallery_parent : null;
 
         try {
-            $gallery = $ansel_storage->createGallery(
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery(
                     array('name' => $gallery_name,
                           'desc' => $gallery_desc,
                           'category' => $gallery_category,
@@ -293,7 +293,7 @@ case 'empty':
     $galleryId = Horde_Util::getFormData('gallery');
     if ($galleryId) {
         try {
-            $gallery = $ansel_storage->getGallery($galleryId);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
             require ANSEL_TEMPLATES . '/common-header.inc';
             require ANSEL_TEMPLATES . '/menu.inc';
             require ANSEL_TEMPLATES . '/gallery/delete_confirmation.inc';
@@ -312,7 +312,7 @@ case 'generateDefault':
     // Re-generate the default pretty gallery image.
     $galleryId = Horde_Util::getFormData('gallery');
     try {
-        $gallery = $ansel_storage->getGallery($galleryId);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
         $gallery->clearStacks();
         $notification->push(_("The gallery's default photo has successfully been reset."), 'horde.success');
         header('Location: ' . Horde::applicationUrl('view.php', true)->add('gallery', $galleryId));
@@ -327,7 +327,7 @@ case 'generateThumbs':
     // Re-generate all of this gallery's prettythumbs.
     $galleryId = Horde_Util::getFormData('gallery');
     try {
-        $gallery = $ansel_storage->getGallery($galleryId);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
     } catch (Ansel_Exception $e) {
         $notification->push($gallery->getMessage(), 'horde.error');
         header('Location: ' . Horde::applicationUrl('index.php', true));
@@ -342,7 +342,7 @@ case 'deleteCache':
     // Delete all cached image views.
     $galleryId = Horde_Util::getFormData('gallery');
     try {
-        $gallery = $ansel_storage->getGallery($galleryId);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
     } catch (Ansel_Exception $e) {
         $notification->push($gallery->getMessage(), 'horde.error');
         header('Location: ' . Horde::applicationUrl('index.php', true));
index ee17799..c4db7cd 100644 (file)
@@ -18,7 +18,7 @@ if (!$galleryId) {
     exit;
 }
 try {
-    $gallery = $ansel_storage->getGallery($galleryId);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
 } catch (Ansel_Exception $e) {
     $notification->push(sprintf(_("Error accessing %s: %s"), $galleryId, $e->getMessage()), 'horde.error');
     header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
index 7ccedd3..46a16c6 100644 (file)
@@ -17,7 +17,7 @@ $galleryId = Horde_Util::getPost('gallery');
 
 if ($galleryId) {
     try {
-        $gallery = $ansel_storage->getGallery($galleryId);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
     } catch (Ansel_Exception $e) {
         $notification->push($e->getMessage(), 'horde.error');
         // Return to the default view.
@@ -31,7 +31,7 @@ if ($galleryId) {
                                         $gallery->get('name')), 'horde.error');
         } else {
             try {
-                $ansel_storage->removeGallery($gallery);
+                $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery);
                 $notification->push(sprintf(
                     _("Successfully deleted %s."),
                     $gallery->get('name')), 'horde.success');
@@ -58,7 +58,7 @@ if ($galleryId) {
                                         $gallery->get('name')),
                                 'horde.error');
         } else {
-            $ansel_storage->emptyGallery($gallery);
+            $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->emptyGallery($gallery);
             $notification->push(sprintf(_("Successfully emptied \"%s\""), $gallery->get('name')));
         }
         header('Location: '
index 17c96f8..d9ecb7d 100644 (file)
@@ -20,7 +20,7 @@ if (!isset($galleryId)) {
     exit;
 }
 try {
-    $gallery = $ansel_storage->getGallery($galleryId);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
 } catch (Ansel_Excception $e) {
     $notification->push(_("There was an error accessing the gallery."), 'horde.error');
     header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
index accc8a1..0c900f0 100644 (file)
@@ -29,14 +29,14 @@ $groups_perpage = $prefs->getValue('groupsperpage');
 switch ($groupby) {
 case 'category':
     try {
-        $num_groups = $ansel_storage->countCategories(Horde_Perms::SHOW);
+        $num_groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countCategories(Horde_Perms::SHOW);
     } catch (Ansel_Exception $e) {
         $notification->push($num_groups);
         $num_groups = 0;
         $groups = array();
     }
     if ($num_groups) {
-        $groups = $ansel_storage->listCategories(Horde_Perms::SHOW,
+        $groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listCategories(Horde_Perms::SHOW,
                                                  $gbpage * $groups_perpage,
                                                  $groups_perpage);
     } else {
@@ -46,9 +46,9 @@ case 'category':
 
 case 'owner':
     try {
-        if ($num_groups = $ansel_storage->shares->countOwners(Horde_Perms::SHOW, null, false)) {
+        if ($num_groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->countOwners(Horde_Perms::SHOW, null, false)) {
 
-            $groups = $ansel_storage->shares->listOwners(Horde_Perms::SHOW,
+            $groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->listOwners(Horde_Perms::SHOW,
                                                          null,
                                                          false,
                                                          $gbpage * $groups_perpage,
index 52a3fa2..5c55eb8 100644 (file)
@@ -54,7 +54,7 @@ if (is_null($actionID) && is_null($tags)) {
 
 /* Get the gallery object and style information */
 try {
-    $gallery = $ansel_storage->getGallery($gallery_id);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
 } catch (Ansel_Exception $e) {
     $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error');
     header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
@@ -65,7 +65,7 @@ try {
 if (!is_null($tags) && strlen($tags)) {
     $tags = explode(',', $tags);
     if (!empty($image_id)) {
-        $resource = &$ansel_storage->getImage($image_id);
+        $resource = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     } else {
         $resource = $gallery;
     }
@@ -102,7 +102,7 @@ switch ($actionID) {
 case 'deletetags':
     $tag = Horde_Util::getFormData('tag');
     if (!empty($image_id)) {
-        $resource = &$ansel_storage->getImage($image_id);
+        $resource = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
         $page = Horde_Util::getFormData('page', 0);
         $url = Ansel::getUrlFor('view', array_merge(
                                         array('view' => 'Image',
@@ -127,7 +127,7 @@ case 'deletetags':
 
 case 'modify':
     try {
-        $image = &$ansel_storage->getImage($image_id);
+        $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
         $ret = Horde_Util::getFormData('ret', 'gallery');
     } catch (Ansel_Exception $e) {
         $notification->push(_("Photo not found."), 'horde.error');
@@ -204,7 +204,7 @@ case 'save':
             } catch (Horde_Browser_Exception $e) {}
         }
 
-        $image = &$ansel_storage->getImage($image_id);
+        $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
         $image->caption = $vars->get('image_desc');
         $image->setTags(explode(',' , $vars->get('image_tags')));
 
@@ -309,7 +309,7 @@ case 'resizeedit':
     }
 
     /* Retrieve image details. */
-    $image = $ansel_storage->getImage($image_id);
+    $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     $title = sprintf(_("Edit %s :: %s"), $gallery->get('name'),
                      $image->filename);
 
@@ -367,7 +367,7 @@ case 'watermark':
         header('Location: ' . $imageurl);
         exit;
     } else {
-        $image = &$ansel_storage->getImage($image_id);
+        $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
         $image->watermark('screen', $watermark, $watermark_halign,
                                 $watermark_valign, $watermark_font);
         $image->updateData($image->raw('screen'), 'screen');
@@ -396,7 +396,7 @@ case 'resize':
                             'horde.error');
     } else {
         try {
-            $image = $ansel_storage->getImage($image_id);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
         } catch (Ansel_Exception $e) {
             $notification->push($e->getMessage(), 'horde.error');
             header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
@@ -460,7 +460,7 @@ case 'resize':
 case 'setwatermark':
     $title = _("Watermark");
     try {
-        $image = $ansel_storage->getImage($image_id);
+        $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     } catch (Ansel_Exception $e) {
         $notification->push($image->getMessage(), 'horde.error');
         header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
@@ -507,7 +507,7 @@ case 'previewrotate270':
     $action = substr($actionID, 7);
 
     /* Retrieve image details. */
-    $image = &$ansel_storage->getImage($image_id);
+    $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     $title = sprintf(_("Preview changes for %s :: %s"),
                      $gallery->get('name'),
                      $image->filename);
@@ -525,35 +525,35 @@ case 'imagerotate180':
 case 'imagerotate270':
     $view = Horde_Util::getFormData('view');
     $angle = intval(substr($actionID, 11));
-    $image = &$ansel_storage->getImage($image_id);
+    $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     $image->rotate($view, $angle);
     $image->display($view);
     exit;
 
 case 'imageflip':
     $view = Horde_Util::getFormData('view');
-    $image = &$ansel_storage->getImage($image_id);
+    $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     $image->flip($view);
     $image->display($view);
     exit;
 
 case 'imagemirror':
     $view = Horde_Util::getFormData('view');
-    $image = &$ansel_storage->getImage($image_id);
+    $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     $image->mirror($view);
     $image->display($view);
     exit;
 
 case 'imagegrayscale':
     $view = Horde_Util::getFormData('view');
-    $image = &$ansel_storage->getImage($image_id);
+    $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     $image->grayscale($view);
     $image->display($view);
     exit;
 
 case 'imagewatermark':
     $view = Horde_Util::getFormData('view');
-    $image = &$ansel_storage->getImage($image_id);
+    $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     $image->watermark($view, $watermark, $watermark_halign, $watermark_valign,
                       $watermark_font);
     $image->display($view);
@@ -615,7 +615,7 @@ case 'move':
     $newGallery = Horde_Util::getFormData('new_gallery');
     if ($images && $newGallery) {
         try {
-            $newGallery = $ansel_storage->getGallery($newGallery);
+            $newGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($newGallery);
             $result = $gallery->moveImagesTo($images, $newGallery);
             $notification->push(
                 sprintf(ngettext("Moved %d photo from \"%s\" to \"%s\"",
@@ -660,7 +660,7 @@ case 'copy':
     $newGallery = Horde_Util::getFormData('new_gallery');
     if ($images && $newGallery) {
         try {
-            $newGallery = $ansel_storage->getGallery($newGallery);
+            $newGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($newGallery);
             $result = $gallery->copyImagesTo($images, $newGallery);
             $notification->push(
                     sprintf(ngettext("Copied %d photo to %s",
@@ -687,7 +687,7 @@ case 'copy':
 case 'downloadzip':
     $galleryId = Horde_Util::getFormData('gallery');
     if ($galleryId) {
-        $gallery = $ansel_storage->getGallery($galleryId);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
         if (!$registry->getAuth() ||
             !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) ||
             $gallery->hasPasswd() || !$gallery->isOldEnough()) {
@@ -734,7 +734,7 @@ case 'previewcrop':
         $action = substr($actionID, 7);
 
         /* Retrieve image details. */
-        $image = &$ansel_storage->getImage($image_id);
+        $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
         $title = sprintf(_("Preview changes for %s :: %s"),
                          $gallery->get('name'),
                          $image->filename);
@@ -752,7 +752,7 @@ case 'imagecrop':
         if ($gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
             $params = Horde_Util::getFormData('params');
             list($x1, $y1, $x2, $y2) = explode('.', $params);
-            $image = &$ansel_storage->getImage($image_id);
+            $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
             $image->load('full');
             $image->crop($x1, $y1, $x2, $y2);
             $image->display();
index 0bd3013..2133366 100644 (file)
@@ -11,8 +11,8 @@
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
-$image = $ansel_storage->getImage(Horde_Util::getFormData('image'));
-$gallery = $ansel_storage->getGallery($image->gallery);
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) || !$gallery->canDownload()) {
     throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."), __FILE__, __LINE__);
 }
index f4b9b78..ac7a877 100644 (file)
@@ -17,8 +17,8 @@ if (empty($conf['ecard']['enable'])) {
 }
 
 /* Get the gallery and the image, and abort if either fails. */
-$gallery = $ansel_storage->getGallery(Horde_Util::getFormData('gallery'));
-$image = &$gallery->getImage(Horde_Util::getFormData('image'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(Horde_Util::getFormData('gallery'));
+$image = $gallery->getImage(Horde_Util::getFormData('image'));
 
 /* Run through the action handlers. */
 switch (Horde_Util::getFormData('actionID')) {
index ffe1615..1fa89c6 100644 (file)
@@ -11,8 +11,8 @@
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
-$image = $ansel_storage->getImage(Horde_Util::getFormData('image'));
-$gallery = $ansel_storage->getGallery($image->gallery);
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) || !$gallery->canDownload()) {
     throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
 }
index 7e7e281..937c9ee 100644 (file)
@@ -11,8 +11,8 @@
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
-$image = &$ansel_storage->getImage(Horde_Util::getFormData('image'));
-$gallery = $ansel_storage->getGallery($image->gallery);
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
     throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
 }
index 8ec5632..25f5c2f 100644 (file)
@@ -11,8 +11,8 @@
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
-$image = $ansel_storage->getImage(Horde_Util::getFormData('image'));
-$gallery = $ansel_storage->getGallery(abs($image->gallery));
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery));
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
     throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
 }
index 1942c30..203e979 100644 (file)
@@ -12,8 +12,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
 $style = Horde_Util::getFormData('style');
-$image = $ansel_storage->getImage(Horde_Util::getFormData('image'));
-$gallery = $ansel_storage->getGallery(abs($image->gallery));
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery));
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
     throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
 }
index 1e7d838..a9ea08a 100644 (file)
@@ -11,8 +11,8 @@
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
-$image = &$ansel_storage->getImage(Horde_Util::getFormData('image'));
-$gallery = $ansel_storage->getGallery($image->gallery);
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
     throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
 }
index bb7b39c..1caea0d 100644 (file)
@@ -11,8 +11,8 @@
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
 
-$image = $ansel_storage->getImage(Horde_Util::getFormData('image'));
-$gallery = $ansel_storage->getGallery(abs($image->gallery));
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery));
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
     throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
 }
index d39beaf..1655484 100644 (file)
@@ -13,7 +13,7 @@ Horde_Registry::appInit('ansel');
 
 $gallery_id = Horde_Util::getFormData('gallery');
 try {
-    $gallery = $ansel_storage->getGallery($gallery_id);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
 } catch (Ansel_Exception $e) {
     $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error');
     header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
@@ -209,7 +209,7 @@ if ($form->validate($vars)) {
         $cnt = count($image_ids);
         for ($i = 0; $i < $conf['image']['autogen'] && $cnt > $i; $i++) {
             $image_id = $image_ids[$i];
-            $image = &$GLOBALS['ansel_storage']->getImage($image_id);
+            $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
             $image->createView('screen');
             $image->createView('thumb');
             $image->createView('mini');
index 4ecad89..c28e54c 100644 (file)
@@ -10,7 +10,7 @@
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('ansel');
-$gallery = $ansel_storage->getGallery((int)Horde_Util::getFormData('gallery'));
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery((int)Horde_Util::getFormData('gallery'));
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
     throw new Horde_Exception_PermissionDenied();
 }
index 057903f..b9489ca 100644 (file)
@@ -54,7 +54,7 @@ class Ansel_Ajax_Imple_EditCaption extends Horde_Ajax_Imple_Base
             /* Are we requesting the unformatted text? */
             if (!empty($args['action']) && $args['action'] == 'load') {
                 $id = $args['id'];
-                $image = $GLOBALS['ansel_storage']->getImage($id);
+                $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
                 $caption = $image->caption;
 
                 return $caption;
@@ -66,8 +66,8 @@ class Ansel_Ajax_Imple_EditCaption extends Horde_Ajax_Imple_Base
                     return '';
             }
             $id = $args['id'];
-            $image = $GLOBALS['ansel_storage']->getImage($id);
-            $g = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
+            $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
             if ($g->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
                 $image->caption = $pref_value;
                 try {
index ce66ae8..0a08d86 100644 (file)
@@ -49,7 +49,7 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base
                 // Attempt to get faces from the picture if we don't already have results,
                 // or if we were asked to explicitly try again.
                 if (($reload || empty($result))) {
-                    $image = $GLOBALS['ansel_storage']->getImage($image_id);
+                    $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
                     $image->createView('screen');
                     $result = $faces->getFromPicture($image_id, $autocreate);
                 }
@@ -70,8 +70,8 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base
             case 'delete':
                 // delete - deletes a single face from an image.
                 $face_id = (int)$post['face'];
-                $image = $GLOBALS['ansel_storage']->getImage($image_id);
-                $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+                $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
+                $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
                 if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
                     throw new Horde_Exception('Access denied editing the photo.');
                 }
@@ -87,8 +87,8 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base
                 }
 
                 $name = $post['facename'];
-                $image = &$GLOBALS['ansel_storage']->getImage($image_id);
-                $gallery = &$GLOBALS['ansel_storage']->getGallery($image->gallery);
+                $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
+                $gallery = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
                 if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
                     throw new Horde_Exception('You are not allowed to edit this photo');
                 }
index 8c2b167..14e8878 100644 (file)
@@ -38,7 +38,7 @@ class Ansel_Ajax_Imple_GallerySlugCheck extends Horde_Ajax_Imple_Base
             return array('response' => '0');
         }
 
-        $exists = $GLOBALS['ansel_storage']->slugExists($slug) ? 0 : 1;
+        $exists = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->slugExists($slug) ? 0 : 1;
         return array('response' => $exists);
     }
 
index 8549272..4159134 100644 (file)
@@ -39,8 +39,8 @@ class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Ajax_Imple_Base
 
         // Get the image and gallery to check perms
         try {
-            $image = $GLOBALS['ansel_storage']->getImage((int)$img);
-            $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage((int)$img);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
         } catch (Ansel_Exception $e) {
             return array('response' => 0);
         }
@@ -64,7 +64,7 @@ class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Ajax_Imple_Base
             // Now get the "add geotag" stuff
             $addurl = Horde::applicationUrl('map_edit.php')->add('image', $img);
             $addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::applicationUrl('map_edit.php'), array('params' => array('image' => $img), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;'));
-            $imgs = $GLOBALS['ansel_storage']->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
+            $imgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
             if (count($imgs) > 0) {
                 $imgsrc = '<div class="ansel_location_sameas">';
                 foreach ($imgs as $id => $data) {
index 98dcc60..682fe78 100644 (file)
@@ -27,7 +27,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Ajax_Imple_AutoComple
 
         /* Use ajax? */
         if (!isset($_SESSION['ansel']['ajax_locationac'])) {
-            $results = $GLOBALS['ansel_storage']->searchLocations();
+            $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->searchLocations();
             if ($results instanceof PEAR_Error) {
                 Horde::logMessage($results, 'ERR');
             } else {
@@ -39,7 +39,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Ajax_Imple_AutoComple
             $ret['ajax'] = 'LocationAutoCompleter';
         } else {
             if (empty($results)) {
-                $results = $GLOBALS['ansel_storage']->searchLocations();
+                $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->searchLocations();
             }
             $ret['browser'] = Horde_Serialize::serialize($results, Horde_Serialize::JSON);
         }
@@ -55,7 +55,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Ajax_Imple_AutoComple
             return array();
         }
         try {
-            $locs = $GLOBALS['ansel_storage']->searchLocations($input);
+            $locs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->searchLocations($input);
             if (!count($locs)) {
                 $locs = new StdClass();
             }
index ca5e2a3..cf23875 100644 (file)
@@ -54,11 +54,11 @@ class Ansel_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base
 
         /* Get the resource owner */
         if ($type == 'gallery') {
-            $resource = $GLOBALS['ansel_storage']->getGallery($id);
+            $resource = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($id);
             $parent = $resource;
         } else {
-            $resource = $GLOBALS['ansel_storage']->getImage($id);
-            $parent = $GLOBALS['ansel_storage']->getGallery($resource->gallery);
+            $resource = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
+            $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($resource->gallery);
         }
 
         switch ($action) {
index 1c7bbb2..b312d07 100644 (file)
@@ -79,9 +79,8 @@ class Ansel
                              $allLevels = true, $from = 0, $count = 0,
                              $ignore = null)
     {
-        global $ansel_storage;
-        $galleries = $ansel_storage->listGalleries($perm, $attributes, $parent,
-                                                   $allLevels, $from, $count);
+        $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()
+                ->listGalleries($perm, $attributes, $parent, $allLevels, $from, $count);
         $tree = Horde_Tree::factory('gallery_tree', 'Select');
 
         if (!empty($ignore)) {
@@ -211,8 +210,8 @@ class Ansel
                         // Getting these objects is not ideal, but at this point
                         // they should already be locally cached so the cost
                         // is minimized.
-                        $i = $GLOBALS['ansel_storage']->getImage($data['image']);
-                        $g = $GLOBALS['ansel_storage']->getGallery($data['gallery']);
+                        $i = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($data['image']);
+                        $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($data['gallery']);
                         if ($g->get('view_mode') == 'Date') {
 
                             $imgDate = new Horde_Date($i->originalDate);
@@ -387,7 +386,7 @@ class Ansel
      */
     static public function getImageUrl($imageId, $view = 'screen', $full = false, $style = null)
     {
-        global $conf, $ansel_storage;
+        global $conf;
 
         // To avoid having to add a new img/* file everytime we add a new
         // thumbstyle, we check for the 'non-prettythumb' views, then route the
@@ -419,7 +418,7 @@ class Ansel
             // We have to make sure the image exists first, since we won't
             // be going through img/*.php to auto-create it.
             try {
-                $image = $ansel_storage->getImage($imageId);
+                $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($imageId);
             } catch (Ansel_Exception $e) {
                 Horde::logMessage($e, 'ERR');
                 return Horde::applicationUrl((string)Ansel::getErrorImage($view), $full);
@@ -615,8 +614,9 @@ class Ansel
      */
     static public function getBreadCrumbs($separator = ' &raquo; ', $gallery = null)
     {
-        global $prefs, $ansel_storage;
+        global $prefs;
 
+        $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
         $groupby = Horde_Util::getFormData('groupby', $prefs->getValue('groupby'));
         $owner = Horde_Util::getFormData('owner');
         $image_id = (int)Horde_Util::getFormData('image');
@@ -957,11 +957,11 @@ class Ansel
 
         $zipfiles = array();
         foreach ($images as $id) {
-            $image = $GLOBALS['ansel_storage']->getImage($id);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
             // If we didn't select an entire gallery, check the download
             // size for each image.
             if (!isset($view)) {
-                $g = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+                $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
                 $v = $g->canDownload() ? 'full' : 'screen';
             } else {
                 $v = $view;
index f46e6db..f84868a 100644 (file)
@@ -38,7 +38,7 @@ class Ansel_Api extends Horde_Registry_Api
 
         if (empty($path)) {
             $owners = array();
-            $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, null, false);
+            $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, null, false);
             foreach ($galleries  as $gallery) {
                 $owners[$gallery->data['share_owner'] ? $gallery->data['share_owner'] : '-system-'] = true;
             }
@@ -69,28 +69,27 @@ class Ansel_Api extends Horde_Registry_Api
                 }
             }
             return $results;
-
         } else {
             if (count($parts) == 1) {
                 // This request is for all galleries owned by the requested user.
-                $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, $parts[0], null, false);
+                $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, $parts[0], null, false);
                 $images = array();
             } elseif ($this->galleryExists(null, end($parts))) {
                 // This request if for a certain gallery, list all sub-galleries
                 // and images.
                 $gallery_id = end($parts);
-                $galleries = $GLOBALS['ansel_storage']->getGalleries(array($gallery_id));
+                $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleries(array($gallery_id));
                 if (!isset($galleries[$gallery_id]) ||
                     !$galleries[$gallery_id]->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
 
                     throw new Horde_Exception_NotFound(_("Invalid gallery specified."));
                 }
-                $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $gallery_id, false);
+                $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $gallery_id, false);
                 $images = $this->listImages(null, $gallery_id, Horde_Perms::SHOW, 'mini');
 
             } elseif (count($parts) > 2 &&
                       $this->galleryExists(null, $parts[count($parts) - 2]) &&
-                      ($image = $GLOBALS['ansel_storage']->getImage(end($parts)))) {
+                      ($image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(end($parts)))) {
 
                 return array('data' => $image->raw(),
                              'mimetype' => $image->type,
@@ -187,10 +186,10 @@ class Ansel_Api extends Horde_Registry_Api
         }
         $image_name = array_pop($parts);
         $gallery_id = end($parts);
-        if (!$GLOBALS['ansel_storage']->galleryExists($gallery_id)) {
+        if (!$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($gallery_id)) {
             throw new Horde_Exception_NotFound("Gallery does not exist");
         }
-        $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             throw new Horde_Exception_PermissionDenied(_("Access denied adding photos to \"%s\"."));
         }
@@ -216,7 +215,7 @@ class Ansel_Api extends Horde_Registry_Api
         }
 
         try {
-            if (!($image = $GLOBALS['ansel_storage']->getImage($image_id))) {
+            if (!($image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id))) {
                 return false;
             }
         } catch (Ansel_Exception $e) {
@@ -307,26 +306,22 @@ class Ansel_Api extends Horde_Registry_Api
                               $gallery_data = null, $encoding = null, $slug = null,
                               $compression = 'none', $skiphook = false)
     {
-        $image_data = null;
-
-        /* If no app is given use Ansel's own gallery which is initialized
-         * in base.php */
+        /* Set application scope */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set($app);
         }
-
+        $image_data = null;
+       
         if (isset($image['filename']) &&
             isset($image['description']) &&
             isset($image['data']) &&
             isset($image['type'])) {
                 Horde::logMessage(sprintf("Receiving image %s in saveImage() with a raw filesize of %i", $image['filename'], strlen($image['data'])), 'DEBUG');
                 $image_data = array('image_filename' => $image['filename'],
-                    'image_caption' => $image['description'],
-                    'image_type' => $image['type'],
-                    'data' => $this->_getImageData($image['data'], $encoding, $compression, true));
-            } else {
-                Horde::logMessage(sprintf("Receiving image %s in saveImage() with a raw filesize of %i", $image['file'], filesize($image['file'])), 'DEBUG');
-            }
+                                    'image_caption' => $image['description'],
+                                    'image_type' => $image['type'],
+                                    'data' => $this->_getImageData($image['data'], $encoding, $compression, true));
+        }
 
         if (is_null($image_data) && getimagesize($image['file']) === false) {
             throw new InvalidArgumentException(_("The file you uploaded does not appear to be a valid photo."));
@@ -335,9 +330,9 @@ class Ansel_Api extends Horde_Registry_Api
             throw new InvalidArgumentException(_("A gallery to add this photo to is required."));
         }
         if (!empty($slug)) {
-            $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug);
-        } elseif ($GLOBALS['ansel_storage']->galleryExists($gallery_id)) {
-            $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug);
+        } elseif ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($gallery_id)) {
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
         }
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied adding photos to \"%s\"."), $gallery->get('name')));
@@ -358,11 +353,9 @@ class Ansel_Api extends Horde_Registry_Api
             );
         }
 
-        if (isset($image['tags']) && is_array($image['tags']) &&
-            count($image['tags'])) {
-                $image_data['tags'] = $image['tags'];
-            }
-
+        if (isset($image['tags']) && is_array($image['tags']) && count($image['tags'])) {
+            $image_data['tags'] = $image['tags'];
+        }
         $image_id = $gallery->addImage($image_data, $default);
 
         // Call the postupload hook if needed
@@ -406,14 +399,12 @@ class Ansel_Api extends Horde_Registry_Api
             throw new Horde_Exception_PermissionDenied(_("Access denied deleting galleries."));
         }
 
-        /* If no app is given use Ansel's own gallery which is initialized in
-        base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
-        $image = $GLOBALS['ansel_storage']->getImage($image_id);
-        $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+        $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
             throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied deleting photos from \"%s\"."), $gallery->get('name')));
         }
@@ -444,7 +435,7 @@ class Ansel_Api extends Horde_Registry_Api
         }
 
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
         if (!empty($perm)) {
@@ -456,7 +447,7 @@ class Ansel_Api extends Horde_Registry_Api
             $permobj = null;
         }
 
-        $gallery = $GLOBALS['ansel_storage']->createGallery($attributes, $permobj, $parent);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery($attributes, $permobj, $parent);
 
         return $gallery->id;
     }
@@ -476,13 +467,11 @@ class Ansel_Api extends Horde_Registry_Api
             throw new Horde_Exception_PermissionDenied(_("Access denied deleting galleries."));
         }
 
-        /* If no app is given use Ansel's own gallery which is initialized in
-        base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
-        $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
             throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied deleting gallery \"%s\"."), $gallery->get('name')));
         } else {
@@ -493,7 +482,7 @@ class Ansel_Api extends Horde_Registry_Api
                 }
             }
 
-            return $GLOBALS['ansel_storage']->removeGallery($gallery);
+            return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery);
         }
     }
 
@@ -508,17 +497,14 @@ class Ansel_Api extends Horde_Registry_Api
      */
     public function count($app = null, $gallery_id = null, $slug = '')
     {
-        /* If no app is given use Ansel's own gallery which is initialized in
-        base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
-
         try {
             if (!empty($slug)) {
-                $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug);
+                $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug);
             } else {
-                $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+                $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
             }
             return (int)$gallery->countImages();
         } catch (Ansel_Exception $e) {
@@ -539,16 +525,14 @@ class Ansel_Api extends Horde_Registry_Api
     public function getDefaultImage($app = null, $gallery_id = null,
         $style = 'ansel_default', $slug = '')
     {
-        /* If no app is given use Ansel's own gallery which is initialized in
-        base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
         if (!empty($slug)) {
-            $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug);
         } else {
-            $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
         }
 
         return $gallery->getDefaultImage($style);
@@ -565,13 +549,10 @@ class Ansel_Api extends Horde_Registry_Api
      *
      * @return string  The image path.
      */
-    public function getImageUrl($app = null, $image_id, $view = 'screen',
-        $full = false, $style = null)
+    public function getImageUrl($app = null, $image_id, $view = 'screen', $full = false, $style = null)
     {
-        /* If no app is given use Ansel's own gallery which is initialized in
-        base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
         return (string)Ansel::getImageUrl($image_id, $view, $full, $style);
@@ -595,14 +576,13 @@ class Ansel_Api extends Horde_Registry_Api
                                     $app = null, $encoding = null,
                                     $compression = 'none')
     {
-        /* If no app is given use Ansel's own gallery which is initialized in base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
         /* Get image and gallery */
-        $image = $GLOBALS['ansel_storage']->getImage($image_id);
-        $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+        $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 
         /* Check age and password */
         if (!$gallery->hasPasswd() || !$gallery->isOldEnough()) {
@@ -653,9 +633,9 @@ class Ansel_Api extends Horde_Registry_Api
         /* If no app is given use Ansel's own gallery which is initialized in
         base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
-        $galleries = $GLOBALS['ansel_storage']->listGalleries(
+        $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(
             $perm, $attributes, $parent, $allLevels, $from, $count, $sort_by, $direction);
 
         $return = array();
@@ -678,13 +658,13 @@ class Ansel_Api extends Horde_Registry_Api
     public function getGalleries($ids = array(), $app = null, $slugs = array())
     {
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
         if (count($slugs)) {
-            $results = $GLOBALS['ansel_storage']->getGalleriesBySlugs($slugs);
+            $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleriesBySlugs($slugs);
         } else {
-            $results = $GLOBALS['ansel_storage']->getGalleries($ids);
+            $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleries($ids);
         }
 
         /* We can't just return the results of the getGalleries call - we need to
@@ -718,14 +698,11 @@ class Ansel_Api extends Horde_Registry_Api
         $allLevels = true, $from = 0, $count = 0,
         $default = null)
     {
-        /* If no app is given use Ansel's own gallery which is initialized in
-        base.php */
         if (!is_null($app)) {
-           $GLOBALS['ansel_storage'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set($app);
         }
 
-        return Ansel::selectGalleries($default, $perm, null, $parent, $allLevels,
-            $from, $count);
+        return Ansel::selectGalleries($default, $perm, null, $parent, $allLevels, $from, $count);
     }
 
     /**
@@ -752,16 +729,14 @@ class Ansel_Api extends Horde_Registry_Api
         $view = 'screen', $full = false, $from = 0,
         $count = 0, $style = null, $slug = '')
     {
-        /* If no app is given use Ansel's own gallery which is initialized in
-        base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
         /* Determine the default gallery when none is given. The first gallery in
         the list is the default gallery. */
         if (is_null($gallery_id) && empty($slug)) {
-            $galleries = $GLOBALS['ansel_storage']->listGalleries($perm);
+            $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries($perm);
             if (!count($galleries)) {
                 return array();
             }
@@ -769,9 +744,9 @@ class Ansel_Api extends Horde_Registry_Api
             $gallery_names = array_keys($galleries[$keys[0]]['galleries']);
             $gallery_id = $gallery_names[0];
         } elseif (!empty($slug)) {
-            $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug);
         } else {
-            $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
         }
 
         $images = $gallery->listImages();
@@ -779,7 +754,7 @@ class Ansel_Api extends Horde_Registry_Api
         $counter = 0;
         $imagelist = array();
         foreach ($images as $id) {
-            $image = $GLOBALS['ansel_storage']->getImage($id);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
             $imagelist[$id]['name'] = $image->filename;
             $imagelist[$id]['caption'] = $image->caption;
             $imagelist[$id]['type'] = $image->type;
@@ -815,9 +790,9 @@ class Ansel_Api extends Horde_Registry_Api
         $slugs = array())
     {
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
-        $images = $GLOBALS['ansel_storage']->getRecentImages($galleries, $limit, $slugs);
+        $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($galleries, $limit, $slugs);
         $imagelist = array();
         foreach ($images as $image) {
             $id = $image->id;
@@ -856,13 +831,11 @@ class Ansel_Api extends Horde_Registry_Api
     public function countGalleries($app = null, $perm = Horde_Perms::SHOW, $attributes = null,
         $parent = null, $allLevels = true)
     {
-        /* If no app is given use Ansel's own gallery which is initialized
-         * in base.php */
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
-        return $GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), $perm,
+        return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), $perm,
             $attributes, $parent,
             $allLevels);
     }
@@ -906,13 +879,9 @@ class Ansel_Api extends Horde_Registry_Api
      */
     public function searchTags($names, $max = 10, $from = 0,
                                $resource_type = 'all', $user = null, $raw = false,
-                               $app = null)
+                               $app = 'ansel')
     {
-        if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
-        } else {
-            $app = 'ansel';
-        }
+        $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         $results = Ansel_Tags::searchTags($names, $max, $from,  $resource_type, $user);
 
         /* Check for error or if we requested the raw data array */
@@ -923,7 +892,7 @@ class Ansel_Api extends Horde_Registry_Api
         $return = array();
         if (!empty($results['images'])) {
             foreach ($results['images'] as $image_id) {
-                $image = $GLOBALS['ansel_storage']->getImage($image_id);
+                $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
                 $desc = $image->caption;
                 $title = $image->filename;
                 $view_url = Ansel::getUrlFor('view',
@@ -932,16 +901,16 @@ class Ansel_Api extends Horde_Registry_Api
                     'view' => 'Image'),
                     true);
                 $return[] = array('title' => $image->filename,
-                    'desc'=> $image->caption,
-                    'view_url' => $view_url,
-                    'app' => $app);
+                                  'desc'=> $image->caption,
+                                  'view_url' => $view_url,
+                                  'app' => $app);
             }
 
         }
 
         if (!empty($results['galleries'])) {
             foreach ($results['galleries'] as $gallery) {
-                $gal = $GLOBALS['ansel_storage']->getGallery($gallery);
+                $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery);
                 $view_url = Horde::applicationUrl('view.php')->add(
                         array('gallery' => $gallery,
                               'view' => 'Gallery'));
@@ -967,10 +936,10 @@ class Ansel_Api extends Horde_Registry_Api
     public function galleryExists($app, $gallery_id = null, $slug = '')
     {
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
 
-        return $GLOBALS['ansel_storage']->galleryExists($gallery_id, $slug);
+        return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($gallery_id, $slug);
     }
 
     /**
@@ -995,11 +964,10 @@ class Ansel_Api extends Horde_Registry_Api
      *
      * @return array  An array containing 'html' and 'crumbs' keys.
      */
-    public function renderView($params = array(), $app = null,
-        $view = 'Gallery')
+    public function renderView($params = array(), $app = null, $view = 'Gallery')
     {
         if (!is_null($app)) {
-            $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
         }
         $classname = 'Ansel_View_' . basename($view);
         $params['api'] = true;
index a22e9f1..38f5407 100644 (file)
@@ -48,7 +48,6 @@ class Ansel_Application extends Horde_Registry_Application
      *
      * Global variables defined:
      *   $ansel_db - TODO
-     *   $ansel_storage - TODO
      *
      * @throws Horde_Exception
      */
@@ -59,9 +58,9 @@ class Ansel_Application extends Horde_Registry_Application
         }
 
         $binders = array(
-            'Ansel_Storage' => new Ansel_Injector_Binder_Storage(),
             'Ansel_Styles' => new Ansel_Injector_Binder_Styles(),
             'Ansel_Faces' => new Ansel_Injector_Binder_Faces(),
+            'Ansel_Storage' => new Ansel_Injector_Binder_Storage()
         );
         foreach ($binders as $interface => $binder) {
             $GLOBALS['injector']->addBinder($interface, $binder);
@@ -69,7 +68,9 @@ class Ansel_Application extends Horde_Registry_Application
 
         // Create db, share, and vfs instances.
         $GLOBALS['ansel_db'] = Ansel::getDb();
-        $GLOBALS['ansel_storage'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope('ansel');
+
+        /* Set up a default config */
+        $GLOBALS['injector']->bindImplementation('Ansel_Config', 'Ansel_Config');
 
         /* Set a logger for the Vfs */
         $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images')->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger'));
index 9416068..411b4d8 100644 (file)
@@ -36,8 +36,8 @@ class Horde_Block_ansel_gallery extends Horde_Block {
                             'type' => 'checkbox',
                             'default' => true));
 
-        if ($GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
-            foreach ($GLOBALS['ansel_storage']->listGalleries() as $gal) {
+        if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
+            foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries() as $gal) {
                 $params['gallery']['values'][$gal->id] = $gal->get('name');
             }
         }
@@ -116,9 +116,9 @@ class Horde_Block_ansel_gallery extends Horde_Block {
 
         // Get the gallery object and cache it.
         if (isset($this->_params['gallery']) && $this->_params['gallery'] != '__random') {
-            $this->_gallery = $GLOBALS['ansel_storage']->getGallery($this->_params['gallery']);
+            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_params['gallery']);
         } else {
-            $this->_gallery = $GLOBALS['ansel_storage']->getRandomGallery();
+            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery();
         }
 
         // Protect at least a little bit against getting an empty gallery. We
index 9fde9c1..a906c9d 100644 (file)
@@ -40,7 +40,7 @@ class Horde_Block_ansel_my_galleries extends Horde_Block {
         Horde::addScriptFile('tooltips.js', 'horde');
         /* Get the top level galleries */
         try {
-            $galleries = $GLOBALS['ansel_storage']->listGalleries(
+            $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(
                 Horde_Perms::EDIT, $GLOBALS['registry']->getAuth(), null, false, 0,
                 empty($this->_params['limit']) ? 0 : $this->_params['limit'],
                 'last_modified', 1);
index d17f53f..e4a1afe 100644 (file)
@@ -28,7 +28,7 @@ class Horde_Block_ansel_random_photo extends Horde_Block {
 
     function _content()
     {
-        $gallery = $GLOBALS['ansel_storage']->getRandomGallery();
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery();
         if (!$gallery) {
             return _("There are no photo galleries available.");
         }
index 8679f57..d09a901 100644 (file)
@@ -29,8 +29,8 @@ class Horde_Block_ansel_recent_comments extends Horde_Block {
                             'default' => '__random',
                             'values' => array('all' => 'All')));
 
-        if ($GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
-            foreach ($GLOBALS['ansel_storage']->listGalleries(Horde_Perms::READ) as $id => $gal) {
+        if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
+            foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::READ) as $id => $gal) {
                 $params['gallery']['values'][$id] = $gal->get('name');
             }
         }
@@ -68,7 +68,7 @@ class Horde_Block_ansel_recent_comments extends Horde_Block {
 
     function _content()
     {
-        global $registry, $ansel_storage;
+        global $registry;
 
         if ($this->_params['gallery'] == 'all') {
             $threads = $registry->call('forums/list', array(0, 'ansel'));
@@ -103,7 +103,7 @@ class Horde_Block_ansel_recent_comments extends Horde_Block {
 
         foreach ($results as $comment) {
             try {
-                $image = &$ansel_storage->getImage($comment['image_id']);
+                $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($comment['image_id']);
                 $url = Ansel::getUrlFor('view',
                                         array('view' => 'Image',
                                               'gallery' => abs($image->gallery),
@@ -139,9 +139,9 @@ class Horde_Block_ansel_recent_comments extends Horde_Block {
         // Get the gallery object and cache it.
         if (isset($this->_params['gallery']) &&
             $this->_params['gallery'] != '__random') {
-            $this->_gallery = $GLOBALS['ansel_storage']->getGallery($this->_params['gallery']);
+            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_params['gallery']);
         } else {
-            $this->_gallery =$GLOBALS['ansel_storage']->getRandomGallery();
+            $this->_gallery =$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery();
         }
 
         if (empty($this->_gallery)) {
index a2d45da..e8e4fea 100644 (file)
@@ -31,8 +31,8 @@ class Horde_Block_ansel_recently_added extends Horde_Block {
                              'default' => 10),
         );
 
-        if ($GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
-            foreach ($GLOBALS['ansel_storage']->listGalleries(Horde_Perms::READ) as $id => $gal) {
+        if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
+            foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::READ) as $id => $gal) {
                 if (!$gal->hasPasswd() && $gal->isOldEnough()) {
                     $params['gallery']['values'][$id] = $gal->get('name');
                 }
@@ -83,7 +83,7 @@ class Horde_Block_ansel_recently_added extends Horde_Block {
         // Retrieve the images, but protect against very large values for
         // limit.
         try {
-            $results = $GLOBALS['ansel_storage']->getRecentImages(
+            $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages(
             $galleries, min($this->_params['limit'], 100));
         } catch (Ansel_Exception $e) {
             return $e->getMessage();
@@ -115,7 +115,7 @@ function previewImage(e, image_id) {
 HEADER;
 
         foreach ($results as $image) {
-            $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 
             // Don't show locked galleries in the block.
             if (!$gallery->isOldEnough() || $gallery->hasPasswd()) {
@@ -171,9 +171,9 @@ HEADER;
         /* Get the gallery object and cache it. */
         if (isset($this->_params['gallery']) &&
             $this->_params['gallery'] != '__random') {
-            $this->_gallery = $GLOBALS['ansel_storage']->getGallery($this->_params['gallery']);
+            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_params['gallery']);
         } else {
-            $this->_gallery = $GLOBALS['ansel_storage']->getRandomGallery();
+            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery();
         }
 
         if (empty($this->_gallery)) {
index e26b892..27a70e1 100644 (file)
@@ -35,8 +35,8 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block {
                              'default' => 250),
         );
 
-        if ($GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
-            foreach ($GLOBALS['ansel_storage']->listGalleries(Horde_Perms::READ) as $id => $gal) {
+        if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
+            foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::READ) as $id => $gal) {
                 if (!$gal->hasPasswd() && $gal->isOldEnough()) {
                     $params['gallery']['values'][$id] = $gal->get('name');
                 }
@@ -87,14 +87,14 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block {
         }
 
         try {
-            $images = $GLOBALS['ansel_storage']->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100));
+            $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100));
         } catch (Ansel_Exception $e) {
             return $e->getMessage();
         }
         $images = array_reverse($images);
         foreach ($images as $key => $image) {
             $id = $image['image_id'];
-            $gallery = $GLOBALS['ansel_storage']->getGallery($image['gallery_id']);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image['gallery_id']);
 
             /* Don't show locked galleries in the block. */
             if (!$gallery->isOldEnough() || $gallery->hasPasswd()) {
@@ -145,10 +145,10 @@ EOT;
 
         if (isset($this->_params['gallery']) &&
             $this->_params['gallery'] != '__random') {
-            $this->_gallery = $GLOBALS['ansel_storage']->getGallery(
+            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(
                 $this->_params['gallery']);
         } else {
-            $this->_gallery = $GLOBALS['ansel_storage']->getRandomGallery();
+            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery();
         }
 
         if (empty($this->_gallery)) {
diff --git a/ansel/lib/Config.php b/ansel/lib/Config.php
new file mode 100644 (file)
index 0000000..efc41aa
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Utility class for specifying scope-specific ansel configuration.
+ *
+ */
+class Ansel_Config
+{
+    protected $_config = array();
+
+    /**
+     * Const'r - set the default scope to ansel.
+     * 
+     */
+    public function __construct()
+    {
+        $this->_config['scope'] = 'ansel';
+    }
+
+    public function set($config, $value)
+    {
+        $this->_config[$config] = $value;
+    }
+
+    public function get($config)
+    {
+        if (!isset($this->_config[$config])) {
+            throw InvalidArgumentException($config . _(" not found"));
+        }
+        return $this->_config[$config];
+    }
+
+}
\ No newline at end of file
index aa3d4c5..d3d35fa 100644 (file)
@@ -169,7 +169,7 @@ class Ansel_Faces_Base
         // should be encapsulated by the shares driver and not parsed from
         // an internally generated query string fragment. Will need to split
         // this out into two seperate operations somehow.
-        $share = substr($GLOBALS['ansel_storage']->shares->getShareCriteria(
+        $share = substr($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->getShareCriteria(
             $GLOBALS['registry']->getAuth(), Horde_Perms::READ), 5);
 
         $sql = 'SELECT f.face_id, f.gallery_id, f.image_id, f.face_name FROM ansel_faces f, '
@@ -209,7 +209,7 @@ class Ansel_Faces_Base
     {
         // add gallery permission
         // FIXME: Ditto on the REALLY ugly hack comment from above!
-        $share = substr($GLOBALS['ansel_storage']->shares->getShareCriteria(
+        $share = substr($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->getShareCriteria(
             $GLOBALS['registry']->getAuth(), Horde_Perms::READ), 5);
 
         $sql = 'SELECT COUNT(*) FROM ansel_faces f, '
@@ -352,7 +352,7 @@ class Ansel_Faces_Base
                 return false;
             }
             $data = $this->getFaceById($face_id, true);
-            $image = $GLOBALS['ansel_storage']->getImage($image_id);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
 
             // Actually create the image.
             $this->createView(
@@ -445,8 +445,8 @@ class Ansel_Faces_Base
      */
     public function saveCustomFace($face_id, $image, $x1, $y1, $x2, $y2, $name = '')
     {
-        $image = $GLOBALS['ansel_storage']->getImage($image);
-        $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+        $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             throw new Horde_Exception_PermissionDenied('Access denied editing the photo.');
         }
@@ -534,8 +534,8 @@ class Ansel_Faces_Base
     {
         // get image if ID is passed
         if (!($image instanceof Ansel_Image)) {
-            $image = $GLOBALS['ansel_storage']->getImage($image);
-            $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
             if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
                 throw new Horde_Exception_PermissionDenied('Access denied editing the photo.');
             }
@@ -730,7 +730,7 @@ class Ansel_Faces_Base
      */
     public function getFromGallery($gallery_id, $create = false, $force = false)
     {
-        $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             throw new Horde_Exception(sprintf("Access denied editing gallery \"%s\".", $gallery->get('name')));
         }
index 897fd78..f74bde1 100644 (file)
@@ -29,7 +29,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
     {
         /* Pass on up the chain */
         parent::__construct($attributes);
-        $this->setShareOb($GLOBALS['ansel_storage']->shares);
+        $this->setShareOb($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares);
         $mode = isset($attributes['attribute_view_mode']) ? $attributes['attribute_view_mode'] : 'Normal';
         $this->_setModeHelper($mode);
     }
@@ -128,7 +128,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
         }
 
         // Check for slug uniqueness
-        $slugGalleryId = $GLOBALS['ansel_storage']->slugExists($this->data['attribute_slug']);
+        $slugGalleryId = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->slugExists($this->data['attribute_slug']);
         if ($slugGalleryId > 0 && $slugGalleryId <> $this->id) {
             throw InvalidArgumentException(
                 sprintf(_("Could not save gallery, the slug, \"%s\", already exists."),
@@ -169,7 +169,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             }
         } else {
             /* Updating other gallery */
-            $g = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+            $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
             $count = $g->get('images');
             if ($add) {
                 $count += $images;
@@ -257,7 +257,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
         /* Check for a supported multi-page image */
         if ($image->isMultiPage() === true) {
             $params['name'] = $image->getImagePageCount() . ' page image: ' . $image->filename;
-            $mGallery = $GLOBALS['ansel_storage']->createGallery($params, $this->getPermission(), $this->getId());
+            $mGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery($params, $this->getPermission(), $this->getId());
             $i = 1;
             foreach ($image as $page) {
                 $page->caption = sprintf(_("Page %d"), $i++);
@@ -562,7 +562,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
      */
     public function getRecentImages($limit = 10)
     {
-        return $GLOBALS['ansel_storage']->getRecentImages(array($this->id),
+        return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages(array($this->id),
                                                           $limit);
     }
 
@@ -575,7 +575,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
      */
     public function &getImage($id)
     {
-        return $GLOBALS['ansel_storage']->getImage($id);
+        return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
     }
 
     /**
@@ -695,7 +695,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             if ($this->hasSubGalleries()) {
                 // Fall through to a default image of a sub gallery.
                 try {
-                    $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $this, false);
+                    $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $this, false);
                 } catch (Horde_Exception $e) {
                     return false;
                 }
@@ -868,7 +868,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
     {
         /* Make sure we have a gallery object */
         if (!is_null($parent) && !($parent instanceof Ansel_Gallery)) {
-            $parent = $GLOBALS['ansel_storage']->getGallery($parent);
+            $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($parent);
         }
 
         /* Check this now since we don't know if we are updating the DB or not */
@@ -985,7 +985,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
 
     public function __wakeup()
     {
-        $this->setShareOb($GLOBALS['ansel_storage']->shares);
+        $this->setShareOb($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares);
         $mode = $this->get('view_mode');
         $this->_setModeHelper($mode);
     }
index 81170b2..33b76ae 100644 (file)
@@ -156,7 +156,7 @@ class Ansel_GalleryMode_Date
     {
         if (!is_array($this->_subGalleries)) {
             /* Get a list of all the subgalleries */
-            $subs = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $this->_gallery);
+            $subs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $this->_gallery);
             $this->_subGalleries = array_keys($subs);
         }
     }
@@ -172,13 +172,15 @@ class Ansel_GalleryMode_Date
      */
     function getGalleryChildren($perm = Horde_Perms::SHOW, $from = 0, $to = 0, $noauto = false)
     {
-        global $ansel_db, $ansel_storage;
+        global $ansel_db;
 
         /* Cache the results */
         static $children = array();
 
-        $cache_key = md5($this->_gallery->id . serialize($this->_date) . $from . $to);
+        /* Ansel Storage */
+        $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
 
+        $cache_key = md5($this->_gallery->id . serialize($this->_date) . $from . $to);
         if (!empty($children[$cache_key])) {
             return $children[$cache_key];
         }
@@ -429,7 +431,7 @@ class Ansel_GalleryMode_Date
          */
         if ($this->_gallery->get('has_subgalleries')) {
             $gallery_ids = array();
-            $images = $GLOBALS['ansel_storage']->getImages(array('ids' => $ids));
+            $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => $ids));
             foreach ($images as $image) {
                 if (empty($gallery_ids[$image->gallery])) {
                     $gallery_ids[$image->gallery] = 1;
@@ -480,7 +482,7 @@ class Ansel_GalleryMode_Date
     {
         /* Make sure $image is an Ansel_Image; if not, try loading it. */
         if (!($image instanceof Ansel_Image)) {
-            $image = $GLOBALS['ansel_storage']->getImage($image);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image);
         }
 
         /* Make sure the image is in this gallery. */
@@ -592,7 +594,7 @@ class Ansel_GalleryMode_Date
                 $ids = array_merge($ids, $child->_images);
             }
             $ids = $this->_getArraySlice($ids, $from, $count);
-            $images = $GLOBALS['ansel_storage']->getImages(array('ids' => $ids));
+            $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => $ids));
         }
 
         return $images;
@@ -824,7 +826,7 @@ class Ansel_Gallery_Date {
      */
     function getRecentImages($limit = 10)
     {
-        return $GLOBALS['ansel_storage']->getRecentImages(array($this->id),
+        return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages(array($this->id),
                                                           $limit);
     }
 
@@ -837,7 +839,7 @@ class Ansel_Gallery_Date {
      */
     function &getImage($id)
     {
-        return $GLOBALS['ansel_storage']->getImage($id);
+        return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
     }
 
     /**
index 095a728..cfac65a 100644 (file)
@@ -65,12 +65,12 @@ class Ansel_GalleryMode_Normal {
 
             /* Get the number of images and galleries */
             $numimages = $this->countImages();
-            $num_galleries = $GLOBALS['ansel_storage']->countGalleries(
+            $num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(
                 $GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, null, $this->_gallery, false);
 
             /* Now fetch the subgalleries, but only if we need to */
             if ($num_galleries > $from) {
-                $galleries = $GLOBALS['ansel_storage']->listGalleries(
+                $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(
                     Horde_Perms::SHOW, null, $this->_gallery, false, $from, $to);
             }
         }
@@ -142,7 +142,7 @@ class Ansel_GalleryMode_Normal {
             return $this->_gallery->data['attribute_images'];
         }
 
-        $gCnt = $GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(),
+        $gCnt = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(),
                                                           $perm, null,
                                                           $this->_gallery, false);
 
@@ -163,7 +163,7 @@ class Ansel_GalleryMode_Normal {
      */
     function listImages($from = 0, $count = 0)
     {
-        return $GLOBALS['ansel_storage']->listImages($this->_gallery->id, $from,
+        return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listImages($this->_gallery->id, $from,
                                                      $count);
     }
 
@@ -295,7 +295,7 @@ class Ansel_GalleryMode_Normal {
      */
     function getImages($from = 0, $count = 0)
     {
-        $images = $GLOBALS['ansel_storage']->getImages(array('gallery_id' => $this->_gallery->id,
+        $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('gallery_id' => $this->_gallery->id,
                                                              'count' => $count,
                                                              'from' => $from));
 
@@ -325,7 +325,7 @@ class Ansel_GalleryMode_Normal {
     {
         if ($subgalleries && $this->hasSubGalleries()) {
             $count = $this->countImages(false);
-            $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW,
+            $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW,
                                                                   false,
                                                                   $this->_gallery,
                                                                   true);
index 99a6b44..b27ce2b 100644 (file)
@@ -521,11 +521,11 @@ class Ansel_Image Implements Iterator
         /* Existing image, just save and exit */
         if ($this->id) {
             /* Save image details */
-            return $GLOBALS['ansel_storage']->saveImage($this);
+            return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->saveImage($this);
         }
 
         /* New image, need to save the image files, exif etc... */
-        $GLOBALS['ansel_storage']->saveImage($this);
+        $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->saveImage($this);
 
         /* The EXIF functions require a stream, so we need to save before we read */
         $this->_writeData();
@@ -553,7 +553,7 @@ class Ansel_Image Implements Iterator
 
         /* Save again if EXIF changed any values */
         if (!empty($needUpdate)) {
-            $GLOBALS['ansel_storage']->saveImage($this);
+            $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->saveImage($this);
         }
 
         return $this->id;
@@ -671,7 +671,7 @@ class Ansel_Image Implements Iterator
 
         /* Save attributes. */
         foreach ($exif_fields as $name => $value) {
-            $GLOBALS['ansel_storage']->saveImageAttribute($this->id, $name, $value);
+            $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->saveImageAttribute($this->id, $name, $value);
             $this->_exif[$name] = Horde_Image_Exif::getHumanReadable($name, $value);
         }
 
@@ -838,7 +838,7 @@ class Ansel_Image Implements Iterator
     {
         if ($view == 'full' && !$this->_dirty) {
             // Check full photo permissions
-            $gallery = $GLOBALS['ansel_storage']->getGallery($this->gallery);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->gallery);
             if ($gallery instanceof PEAR_Error) {
                 throw new Ansel_Exception($gallery);
             }
@@ -1116,12 +1116,10 @@ class Ansel_Image Implements Iterator
      */
     public function getTags()
     {
-        global $ansel_storage;
-
         if (count($this->_tags)) {
             return $this->_tags;
         }
-        $gallery = $ansel_storage->getGallery($this->gallery);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->gallery);
         if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
             return Ansel_Tags::readTags($this->id);
         } else {
@@ -1139,9 +1137,7 @@ class Ansel_Image Implements Iterator
      */
     public function setTags($tags)
     {
-        global $ansel_storage;
-
-        $gallery = $ansel_storage->getGallery(abs($this->gallery));
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($this->gallery));
         if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             // Clear the local cache.
             $this->_tags = array();
@@ -1200,17 +1196,13 @@ class Ansel_Image Implements Iterator
      */
     public function getViewHash($view, $style = null)
     {
-        global $ansel_storage;
-
         // These views do not care about style...just return the $view value.
-        if ($view == 'screen' || $view == 'thumb' || $view == 'mini' ||
-            $view == 'full') {
-
+        if ($view == 'screen' || $view == 'thumb' || $view == 'mini' || $view == 'full') {
             return $view;
         }
 
         if (is_null($style)) {
-            $gallery = $ansel_storage->getGallery(abs($this->gallery));
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($this->gallery));
             $style = $gallery->getStyle();
         } else {
             $style = Ansel::getStyleDefinition($style);
@@ -1230,7 +1222,7 @@ class Ansel_Image Implements Iterator
      */
     public function getAttributes($format = false)
     {
-        $attributes = $GLOBALS['ansel_storage']->getImageAttributes($this->id);
+        $attributes = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageAttributes($this->id);
         $exif = Horde_Image_Exif::factory($GLOBALS['conf']['exif']['driver'], !empty($GLOBALS['conf']['exif']['params']) ? $GLOBALS['conf']['exif']['params'] : array());
         $fields = Horde_Image_Exif::getFields($exif);
         $output = array();
index f77c6bd..ec89ab1 100644 (file)
@@ -127,7 +127,7 @@ class Ansel_ImageView
      */
     protected function _getGalleryWithImages($parent)
     {
-        $galleries = $GLOBALS['ansel_storage']->listGalleries(
+        $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(
             Horde_Perms::SHOW, null, $parent, false);
 
         foreach ($galleries as $gallery) {
index a392d8b..07486ca 100644 (file)
@@ -23,7 +23,7 @@ class Ansel_ImageView_PolaroidThumb extends Ansel_ImageView
            (which will have a negative gallery_id). */
         if ($this->_image->gallery > 0) {
             if (is_null($this->_style)) {
-                $gal = $GLOBALS['ansel_storage']->getGallery($this->_image->gallery);
+                $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
                 $styleDef = $gal->getStyle();
             } else {
                 $styleDef = Ansel::getStyleDefinition($this->_style);
index bbf8df9..58d2bc1 100644 (file)
@@ -23,7 +23,7 @@ class Ansel_ImageView_PrettyThumb extends Ansel_ImageView
          * (which will have a negative gallery_id). */
         if ($this->_image->gallery > 0) {
             if (is_null($this->_style)) {
-                $gal = $GLOBALS['ansel_storage']->getGallery($this->_image->gallery);
+                $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
                 $styleDef = $gal->getStyle();
             } else {
                 $styleDef = Ansel::getStyleDefinition($this->_style);
index 8929f41..d5b396b 100644 (file)
@@ -23,7 +23,7 @@ class Ansel_ImageView_ShadowSharpThumb extends Ansel_ImageView
          * (which will have a negative gallery_id). */
         if ($this->_image->gallery > 0) {
             if (is_null($this->_style)) {
-                $gal = $GLOBALS['ansel_storage']->getGallery($this->_image->gallery);
+                $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
                 $styleDef = $gal->getStyle();
             } else {
                 $styleDef = Ansel::getStyleDefinition($this->_style);
index 5f403ea..ecc62c3 100644 (file)
 class Ansel_Injector_Factory_Storage
 {
     /**
-     *
+     * Depends on the Ansel_Scope value being available to the injector.
      * @var array
      */
     private $_instances = array();
 
-   /**
-    * @var Horde_Injector
-    */
-    private $_injector;
-
     /**
      *
-     * @param Horde_Injector $injector
-     *
-     * @return Horde_Injector_Factory_Storage
+     * @var Horde_Injector
      */
+    private $_injector;
+
     public function __construct(Horde_Injector $injector)
     {
         $this->_injector = $injector;
     }
 
     /**
-     * Obtain a Ansel_Storage object for the requested scope.
+     * Return an Ansel_Storage instance scoped for the current Ansel scope
      *
      * @param string $scope  The application scope
      *
      * @return Ansel_Storage
      */
-    public function getScope($scope = 'ansel')
+    public function getScope()
     {
-        if (!isset($this->_instances[$scope])) {
+        $scope = $this->_injector->getInstance('Ansel_Config')->get('scope');
+        if (empty($this->_instances[$scope])) {
             $this->_instances[$scope] = new Ansel_Storage($this->_injector->getInstance('Horde_Share')->getScope($scope, 'Sql_Hierarchical'));
         }
-       
+
        return $this->_instances[$scope];
     }
 
index a805d68..2fcc451 100644 (file)
 class Ansel_Storage
 {
     /**
-     * Scope for this storage object.
-     *
-     * @var string
-     */
-    private $_scope = 'ansel';
-
-    /**
      * database handle
      *
      * @var MDB2
@@ -959,7 +952,7 @@ class Ansel_Storage
             $image = $this->getImage($id);
             $gallery_id = abs($image->gallery);
             if (empty($galleries[$gallery_id])) {
-                $galleries[$gallery_id]['gallery'] = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+                $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
             }
 
             // Any authentication that needs to take place for any of the
index 7a187f1..d7d727f 100644 (file)
@@ -217,8 +217,8 @@ class Ansel_Tags
                 $imgs = array();
                 foreach ($images as $id) {
                     try {
-                        $img = $GLOBALS['ansel_storage']->getImage($id);
-                        $gal = $GLOBALS['ansel_storage']->getGallery($img->gallery);
+                        $img = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
+                        $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($img->gallery);
                         $owner = $gal->get('owner');
                         if ($gal->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW) &&
                             (!isset($user) || (isset($user) && $owner && $owner == $user))) {
@@ -250,7 +250,7 @@ class Ansel_Tags
                 /* Check perms */
                 foreach ($galleries as $id) {
                     try {
-                        $gallery = $GLOBALS['ansel_storage']->getGallery($id);
+                        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($id);
                     } catch (Ansel_Exception $e) {
                         Horde::logMessage($e->getMessage(), 'ERR');
                         continue;
@@ -514,7 +514,7 @@ class Ansel_Tags_Search {
                                                $this->_owner);
         $galleries = array();
         foreach ($gresults['galleries'] as $gallery) {
-            $galleries[] = $GLOBALS['ansel_storage']->getGallery($gallery);
+            $galleries[] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery);
         }
 
         /* Do we need to get images? */
@@ -527,7 +527,7 @@ class Ansel_Tags_Search {
                                                   'images',
                                                    $this->_owner);
 
-            $images = count($iresults['images']) ? array_values($GLOBALS['ansel_storage']->getImages(array('ids' => $iresults['images']))) : array();
+            $images = count($iresults['images']) ? array_values($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => $iresults['images']))) : array();
             if (($conf['comments']['allow'] == 'all' || ($conf['comments']['allow'] == 'authenticated' && $GLOBALS['registry']->getAuth())) &&
                 $registry->hasMethod('forums/numMessagesBatch')) {
 
index d6cb4fe..9df76c9 100644 (file)
@@ -27,7 +27,7 @@ class Ansel_Tile_Image
     {
         global $conf, $registry;
 
-        $parent = $GLOBALS['ansel_storage']->getGallery($image->gallery);
+        $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
         if (is_null($style)) {
             $style = $parent->getStyle();
         }
index 9424d9a..ad7ad53 100644 (file)
@@ -137,9 +137,9 @@ abstract class Ansel_View_Base
 
         // If we have a slug, use it.
         if (!empty($slug)) {
-            $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug);
         } else {
-            $gallery = $GLOBALS['ansel_storage']->getGallery($galleryId);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
         }
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
             throw new Horde_Exception(sprintf(_("Access denied to gallery \"%s\"."), $gallery->get('name')));
index 165269e..b193eed 100644 (file)
@@ -54,10 +54,9 @@ class Ansel_View_Embedded {
      */
     function makeView($params)
     {
-        global $ansel_storage;
-
         $view = new Ansel_View_Embedded();
         $view->_params = $params;
+
         return $view;
     }
 
index 42d824b..f1ef3be 100644 (file)
@@ -30,8 +30,6 @@ class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Gallery
      */
     public function html()
     {
-        /* Read in parameters and set defaults */
-
         /* Required */
         $node = $this->_params['container'];
         if (empty($node)) {
@@ -83,7 +81,7 @@ class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Gallery
                 $images[] = $gallery->getDefaultImage($gallery_style);
             }
         }
-        $json = $GLOBALS['ansel_storage']->getImageJson($images, null, true, $thumbsize, true);
+        $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageJson($images, null, true, $thumbsize, true);
 
         /* Some paths */
         $cssurl = Horde::url($GLOBALS['registry']->get('themesuri', 'ansel') . '/jsembed.css', true);
index 2e7abc4..3ecf6ee 100644 (file)
@@ -76,8 +76,8 @@ class Ansel_View_EmbeddedRenderer_Mini extends Ansel_View_Gallery
                                            'count' => $count,
                                            'view_links' => true));
         } else {
-            $json = $GLOBALS['ansel_storage']->getImageJson($images, null, true, $thumbsize, true);
-            $json_full = $GLOBALS['ansel_storage']->getImageJson($images, null, true, 'screen', true);
+            $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageJson($images, null, true, $thumbsize, true);
+            $json_full = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageJson($images, null, true, 'screen', true);
         }
 
         /* Some paths */
index 724a933..44465f9 100644 (file)
@@ -42,8 +42,9 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base
         if (empty($this->view->api)) {
             $option_edit = $this->view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
             $option_select = $option_delete = $this->view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE);
-            $option_move = ($option_delete && $GLOBALS['ansel_storage']->countGalleries(Horde_Perms::EDIT));
-            $option_copy = ($option_edit && $GLOBALS['ansel_storage']->countGalleries(Horde_Perms::EDIT));
+            $option_move = ($option_delete && $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(Horde_Perms::EDIT));
+            $option_copy = ($option_edit && $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(Horde_Perms::EDIT));
+
             /* See if we requested a show_actions change */
             if (Horde_Util::getFormData('actionID', '') == 'show_actions') {
                 $prefs->setValue('show_actions', (int)!$prefs->getValue('show_actions'));
index d241281..af5d565 100644 (file)
@@ -66,8 +66,8 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende
                                                          Horde_Perms::EDIT);
             $option_select = $option_delete = $this->view->gallery->hasPermission(
                 $GLOBALS['registry']->getAuth(), Horde_Perms::DELETE);
-            $option_move = ($option_delete && $GLOBALS['ansel_storage']->countGalleries(Horde_Perms::EDIT));
-            $option_copy = ($option_edit && $GLOBALS['ansel_storage']->countGalleries(Horde_Perms::EDIT));
+            $option_move = ($option_delete && $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(Horde_Perms::EDIT));
+            $option_copy = ($option_edit && $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(Horde_Perms::EDIT));
             /* See if we requested a show_actions change (fallback for non-js) */
             if (Horde_Util::getFormData('actionID', '') == 'show_actions') {
                 $prefs->setValue('show_actions', (int)!$prefs->getValue('show_actions'));
index 5cfffd8..5fd8cbe 100644 (file)
@@ -32,7 +32,7 @@ class Ansel_View_Image extends Ansel_View_Base
         parent::__construct($params);
 
         /* Get the Ansel_Image */
-        $image = &$GLOBALS['ansel_storage']->getImage($params['image_id']);
+        $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($params['image_id']);
 
         /* Get the Ansel_Gallery */
         $this->gallery = $this->_getGallery();
index 188f0b5..bc0d4df 100644 (file)
@@ -43,13 +43,16 @@ class Ansel_View_List extends Ansel_View_Base
      */
     public function __construct($params = array())
     {
-        global $prefs, $ansel_storage;
+        global $prefs;
 
         parent::__construct($params);
 
         /* Notifications */
         $notification = $GLOBALS['injector']->getInstance('Horde_Notification');
 
+        /* Ansel_Storage */
+        $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
+
         // We'll need this in the template.
         $this->_sortBy = !empty($this->_params['sort']) ? $this->_params['sort'] : 'name';
         $this->_sortDir = isset($this->_params['sort_dir']) ? $this->_params['sort_dir'] : 0;
@@ -186,7 +189,7 @@ class Ansel_View_List extends Ansel_View_Base
      */
     public function html()
     {
-        global $conf, $prefs, $registry, $ansel_storage;
+        global $conf, $prefs, $registry;
 
         $vars = Horde_Variables::getDefaultVariables();
         if (!empty($this->_params['page'])) {
index e9cf14e..18dc4e8 100644 (file)
@@ -35,9 +35,10 @@ class Ansel_View_Results extends Ansel_View_Base
      */
     public function __construct()
     {
-        global $prefs, $conf, $ansel_storage;
+        global $prefs, $conf;
 
         $notification = $GLOBALS['injector']->getInstance('Horde_Notification');
+        $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
 
         $this->_owner = Horde_Util::getFormData('owner', null);
         $this->_search = Ansel_Tags::getSearch(null, $this->_owner);
@@ -212,7 +213,10 @@ class Ansel_View_Results extends Ansel_View_Base
      */
     public function html()
     {
-        global $conf, $prefs, $ansel_storage;
+        global $conf, $prefs;
+
+        /* Ansel Storage*/
+        $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
 
         // Get the slice of galleries/images to view on this page.
         $results = $this->_search->getSlice($this->_page, $this->_perPage);
index d0df96c..ee3cfe7 100644 (file)
@@ -65,13 +65,11 @@ class Ansel_Widget_Geotag extends Ansel_Widget_Base
     /**
      * Build the HTML for the widget
      *
-     * @TODO inject $ansel_storage
      * @return string
      */
     public function html()
     {
-        global $ansel_storage;
-
+        $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
         $geodata = $ansel_storage->getImagesGeodata($this->_params['images']);
         $url = Horde::applicationUrl('map_edit.php', true);
         $rtext = _("Relocate this image");
@@ -262,7 +260,7 @@ EOT;
      */
     protected function _getGalleryImagesWithGeodata()
     {
-        return $GLOBALS['ansel_storage']->getImagesGeodata(array(), $this->_view->gallery->id);
+        return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImagesGeodata(array(), $this->_view->gallery->id);
     }
 
     /**
index a101ee1..2305df4 100644 (file)
@@ -64,7 +64,7 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base
         $tree->setOption(array('class' => 'anselWidgets'));
 
         try {
-            $gals = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, $owner,
+            $gals = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, $owner,
                                                              null, true, 0, 0,
                                                             'name', 0);
         } catch (Ansel_Exception $e) {
index bd1f6e7..d044208 100644 (file)
@@ -28,7 +28,7 @@ class Ansel_Widget_OwnerFaces extends Ansel_Widget_Base
         try {
             $this->_count = $this->_faces->countOwnerFaces($this->_owner);
         } catch (Horde_Exception $e) {
-            Horde::logMessage($e->getMessage, 'ERR');
+            Horde::logMessage($e->getMessage(), 'ERR');
             $this->_count = 0;
         }
         if (empty($this->_count)) {
index b6b4a38..0863780 100755 (executable)
@@ -52,7 +52,7 @@ class Ansel_Widget_SimilarPhotos extends Ansel_Widget_Base
      */
     public function _getRelatedImages()
     {
-        global $ansel_storage;
+        $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
 
         $html = '';
         $tags = array_values($this->_view->resource->getTags());
index 15e7afe..9e4806d 100644 (file)
@@ -22,8 +22,8 @@ $image_id = Horde_Util::getFormData('image');
 if (empty($image_id)) {
     Horde::fatal(_("An error has occured retrieving the image. Details have been logged."), __FILE__, __LINE__, true);
 }
-$image = $ansel_storage->getImage($image_id);
-$gallery = $ansel_storage->getGallery($image->gallery);
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
+$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
     throw new Horde_Exception_PermissionDenied(_("Not Authorized. Details have been logged for the server administrator."));
 }
@@ -72,7 +72,7 @@ $gtUrl = $gt->getUrl();
 $loadingImg = Horde::img('loading.gif', _("Loading..."));
 
 /* Obtain other geotagged images to possibly locate this image at */
-$imgs = $GLOBALS['ansel_storage']->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
+$imgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
 if (count($imgs) > 0) {
     $other_images = '<div class="ansel_location_sameas">' . _("Click on a thumbnail to locate at the same point.") . '<br />';
     foreach ($imgs as $id => $data) {
index 62c0121..22aca8d 100644 (file)
@@ -27,13 +27,13 @@ $actionID = Horde_Util::getFormData('actionID', 'edit');
 switch ($actionID) {
 case 'edit':
     try {
-        $share = $ansel_storage->getGallery(Horde_Util::getFormData('cid'));
+        $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(Horde_Util::getFormData('cid'));
         $form = 'edit.inc';
         $perm = &$share->getPermission();
     } catch (Horde_Share_Exception $e) {
         if (($share_name = Horde_Util::getFormData('share')) !== null) {
             try {
-                $share = $ansel_storage->shares->getShare($share_name);
+                $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->getShare($share_name);
                 $form = 'edit.inc';
                 $perm = $share->getPermission();
             } catch (Horde_Share_Exception $e) {
@@ -51,7 +51,7 @@ case 'edit':
 case 'editform':
 case 'editforminherit':
     try {
-        $share = &$ansel_storage->getGallery(Horde_Util::getFormData('cid'));
+        $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(Horde_Util::getFormData('cid'));
     } catch (Horde_Share_Exception $e) {
         $notification->push(_("Attempt to edit a non-existent share."), 'horde.error');
     }
@@ -250,7 +250,7 @@ case 'editforminherit':
 if (empty($share)) {
     $title = _("Edit Permissions");
 } else {
-    $children = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::READ, false, $share);
+    $children = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::READ, false, $share);
     $title = sprintf(_("Edit Permissions for %s"), $share->get('name'));
 }
 
index 99ff408..36eeb72 100644 (file)
@@ -13,8 +13,8 @@ Horde_Registry::appInit('ansel');
 
 $imageId = Horde_Util::getFormData('image');
 try {
-    $image = $ansel_storage->getImage($imageId);
-    $gal = $ansel_storage->getGallery(abs($image->gallery));
+    $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($imageId);
+    $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery));
     $img = Ansel::getImageUrl($imageId, 'thumb', false);
 } catch (Ansel_Exception $e) {
     Horde::logMessage($e->getMessage(), 'ERR');
index 8509b57..e8a98c0 100644 (file)
@@ -13,7 +13,7 @@ Horde_Registry::appInit('ansel');
 
 $vars = Horde_Variables::getDefaultVariables();
 try {
-    $gallery = $ansel_storage->getGallery($vars->get('gallery'));
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($vars->get('gallery'));
 } catch (Ansel_Exception $e) {
     $notification->push($e->getMessage());
     header('Location: ' . Horde::applicationUrl('list.php'));
index 7f24641..205ba3a 100644 (file)
@@ -17,7 +17,7 @@ Horde_Registry::appInit('ansel');
 $title = _("Do you really want to report this gallery?");
 $gallery_id = (int)Horde_Util::getFormData('gallery');
 try {
-    $gallery = $ansel_storage->getGallery($gallery_id);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
 } catch (Ansel_Exception $e) {
     $notification->push($gallery->getMessage());
     header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
index 98ab659..3325681 100644 (file)
@@ -41,7 +41,7 @@ if (empty($rss)) {
     switch ($stream_type) {
     case 'all':
         try {
-            $images = $ansel_storage->getRecentImages();
+            $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages();
         } catch (Ansel_Exception $e) {
             $images = array();
         }
@@ -73,22 +73,22 @@ if (empty($rss)) {
         // Retrieve latest from specified gallery
         // Try a slug first.
         if ($slug) {
-            $gallery = $ansel_storage->getGalleryBySlug($slug);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug);
         } elseif (is_numeric($id)) {
-            $gallery = $ansel_storage->getGallery($id);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($id);
         }
         if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW) &&
             !$gallery->hasPasswd() && $gallery->isOldEnough()) {
 
             if (!$gallery->countImages() && $gallery->hasSubGalleries()) {
-                $subgalleries = $ansel_storage->listGalleries(Horde_Perms::SHOW,
+                $subgalleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW,
                                                               null,
                                                               $gallery);
                 $subs = array();
                 foreach ($subgalleries as $subgallery) {
                     $subs[] = $subgallery->id;
                 }
-                $images = $ansel_storage->getRecentImages($subs);
+                $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($subs);
             } else {
                 $images = $gallery->getRecentImages();
                 $owner = &$gallery->getOwner();
@@ -104,7 +104,7 @@ if (empty($rss)) {
                                         array('view' => 'Gallery',
                                               'gallery' => $id),
                                         true);
-            $img = &$ansel_storage->getImage($gallery->getDefaultImage('ansel_default'));
+            $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($gallery->getDefaultImage('ansel_default'));
             $params = array('last_modified' => $gallery->get('last_modified'),
                             'name' => sprintf(_("%s on %s"),
                                               $gallery->get('name'),
@@ -125,7 +125,7 @@ if (empty($rss)) {
     case 'user':
         $galleries = array();
         try {
-            $shares = $ansel_storage->listGalleries(Horde_Perms::SHOW, $id);
+            $shares = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, $id);
             foreach ($shares as $gallery) {
                 if ($gallery->isOldEnough() && !$gallery->hasPasswd()) {
                     $galleries[] = $gallery->id;
@@ -137,7 +137,7 @@ if (empty($rss)) {
         $images = array();
         if (isset($galleries) && count($galleries)) {
             try {
-                $images = $ansel_storage->getRecentImages($galleries);
+                $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($galleries);
             } catch (Ansel_Exception $e) {
                  Horde::logMessage($e->getMessage(), 'ERR');
             }
@@ -176,7 +176,7 @@ if (empty($rss)) {
         $images = Ansel_Tags::searchTagsById($tag_id, 10, 0, 'images');
         $tag_id = array_pop($tag_id);
         try {
-            $images = $ansel_storage->getImages(array('ids' => $images['images']));
+            $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => $images['images']));
         } catch (Ansel_Exception $e) {
              Horde::logMessage($e->getMessage(), 'ERR');
              $images = array();
@@ -213,7 +213,7 @@ if (empty($rss)) {
             $gallery_id = $images[$i]->gallery;
             if (empty($galleries[$gallery_id])) {
                 try {
-                    $galleries[$gallery_id]['gallery'] = $GLOBALS['ansel_storage']->getGallery($gallery_id);
+                    $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
                 } catch (Ansel_Exception $e) {}
             }
             if (!isset($galleries[$gallery_id]['perm'])) {
index 78ce05e..53391f5 100755 (executable)
@@ -79,7 +79,7 @@ if ($results instanceof PEAR_Error) {
 $image_ids = $results->fetchAll(MDB2_FETCHMODE_ASSOC);
 $results->free();
 foreach (array_values($image_ids) as $image_id) {
-    $image = $ansel_storage->getImage($image_id['image_id']);
+    $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id['image_id']);
     $results = $image->exifToTags($exif_fields);
     $cli->message(sprintf(_("Extracted exif fields from %s"), $image->filename), 'cli.success');
 }
index 9a941c4..4e53cca 100755 (executable)
@@ -102,12 +102,12 @@ if (!empty($username) && !empty($password)) {
 
 // Choose the gallery to add to (or use the created one).
 if (!empty($galleryId)) {
-    if (!$ansel_storage->galleryExists($galleryId)) {
+    if (!$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) {
         $error = sprintf(_("Invalid gallery \"%s\" specified."), $galleryId);
         Horde::logMessage($error, 'WARN');
         $cli->fatal($error);
     } else {
-        $gallery = $ansel_storage->getGallery($galleryId);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
         if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             $error = sprintf(_("Access denied adding photos to \"%s\"."), $galleryId);
             Horde::logMessage($error, 'WARN');
@@ -128,7 +128,7 @@ if (!empty($createGallery)) {
                         'desc' => $gallery_desc,
                         'owner' => $gallery_owner);
     try {
-        $gallery = $ansel_storage->createGallery($attributes, null, $parent);
+        $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery($attributes, null, $parent);
     } catch (Ansel_Exception $e) {
         $galleryId = null;
         $error = sprintf(_("The gallery \"%s\" couldn't be created: %s"),
@@ -150,11 +150,11 @@ if (!empty($list)) {
 
         $images = array_keys($images);
         foreach ($images as $id) {
-            $image = $ansel_storage->getImage($id);
+            $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
             $cli->writeln(str_pad($image->filename, 30) . $image->getVFSPath() . '/' . $id);
         }
     } else {
-        $galleries = $GLOBALS['ansel_storage']->listGalleries();
+        $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries();
         $cli->message(_("Listing Gallery/Name"), 'cli.success');
         $cli->writeln();
         foreach ($galleries as $id => $gallery) {
index 6a74238..a1e2621 100755 (executable)
@@ -78,7 +78,7 @@ if (empty($dir)) {
 Horde_Nls::setCharset('utf-8');
 $gallery_id = processDirectory($dir);
 if (!$keepEmpties) {
-    $gallery = $ansel_storage->getGallery($gallery_id);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
     emptyGalleryCheck($gallery);
 }
 exit;
@@ -91,20 +91,20 @@ exit;
 function emptyGalleryCheck($gallery)
 {
     if ($gallery->hasSubGalleries()) {
-        $children = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $gallery, false);
+        $children = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $gallery, false);
         foreach ($children as $child) {
             // First check all children to see if they are empty...
             emptyGalleryCheck($child);
             if (!$child->countImages() && !$child->hasSubGalleries()) {
-                $result = $GLOBALS['ansel_storage']->removeGallery($child);
+                $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($child);
                 $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $child->get('name')), 'cli.success');
             }
 
             // Refresh the gallery values since we mucked around a bit with it
-            $gallery = $GLOBALS['ansel_storage']->getGallery($gallery->getId());
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery->getId());
             // Now that any empty children are removed, see if we are empty
             if (!$gallery->countImages() && !$gallery->hasSubGalleries()) {
-                $result = $GLOBALS['ansel_storage']->removeGallery($gallery);
+                $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery);
                 $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $gallery->get('name')), 'cli.success');
             }
         }
@@ -131,7 +131,7 @@ function processDirectory($dir, $parent = null)
     // Create a gallery for this directory level.
     $name = basename($dir);
     $cli->message(sprintf(_("Creating gallery: \"%s\""), $name), 'cli.message');
-    $gallery = $GLOBALS['ansel_storage']->createGallery(array('name' => $name), null, $parent);
+    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery(array('name' => $name), null, $parent);
     $cli->message(sprintf(_("The gallery \"%s\" was created successfully."), $name), 'cli.success');
 
     // Read all the files into an array.
index ef32cd0..018716f 100755 (executable)
@@ -114,20 +114,20 @@ processDirectory($dir, null, $gallery_id, $gallery_slug, $useCompression);
 function emptyGalleryCheck($gallery)
 {
     if ($gallery->hasSubGalleries()) {
-        $children = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $gallery, false);
+        $children = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $gallery, false);
         foreach ($children as $child) {
             // First check all children to see if they are empty...
             emptyGalleryCheck($child);
             if (!$child->countImages() && !$child->hasSubGalleries()) {
-                $result = $GLOBALS['ansel_storage']->removeGallery($child);
+                $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($child);
                 $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $child->get('name')), 'cli.success');
             }
 
             // Refresh the gallery values since we mucked around a bit with it
-            $gallery = $GLOBALS['ansel_storage']->getGallery($gallery->getId());
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery->getId());
             // Now that any empty children are removed, see if we are empty
             if (!$gallery->countImages() && !$gallery->hasSubGalleries()) {
-                $result = $GLOBALS['ansel_storage']->removeGallery($gallery);
+                $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery);
                 $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $gallery->get('name')), 'cli.success');
             }
         }
index 8fd7737..dbfd99a 100644 (file)
@@ -1,5 +1,5 @@
 <h1 class="header">
- <?php $gallery = $ansel_storage->getGallery($galleryId);
+ <?php $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
        printf($actionID == 'delete' ? _("Really delete %s and all of its subgalleries?") : _("Really empty %s?"), htmlspecialchars($gallery->get('name')))
  ?>
 </h1>
index 0308fd2..927380a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-$num_galleries = $GLOBALS['ansel_storage']->countGalleries(
+$num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(
     $GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, array('category' => $group), null, false);
 
 if (empty($group)) {
@@ -20,10 +20,10 @@ $link = Horde::link($viewurl, $category_title, 'light');
 
 $preview_gallery = array();
 if ($num_galleries < 5) {
-    $preview_gallery = $GLOBALS['ansel_storage']->listGalleries(
+    $preview_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(
                             Horde_Perms::SHOW, array('category' => $group), null, false);
 } else {
-    $preview_gallery = $GLOBALS['ansel_storage']->listGalleries(
+    $preview_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(
                             Horde_Perms::SHOW, array('category' => $group), null,
                             false, rand(0, $num_galleries - 4), 4);
 }
index aebc265..dbc3b53 100644 (file)
@@ -25,13 +25,13 @@ $link = Horde::link(Ansel::getUrlFor('view', array('groupby' => $groupby,
                                                    'owner' => $group,
                                                    'view' => 'List')));
 
-$num_galleries = $ansel_storage->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW,
+$num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW,
                                                 $group, null, false);
 if ($num_galleries < 5) {
-    $mini_galleries = $ansel_storage->listGalleries(Horde_Perms::SHOW,
+    $mini_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW,
                                                     $group, null, false);
 } else {
-    $mini_galleries = $GLOBALS['ansel_storage']->listGalleries(
+    $mini_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(
         Horde_Perms::SHOW, $group, null, false, rand(0, $num_galleries - 4), 4);
 }
 $mini_galleries = array_values($mini_galleries);
index c4d4248..7bc9a5a 100644 (file)
@@ -79,11 +79,11 @@ if ($cmd == 'list') {
 
 // Check if a gallery was selected from the list.
 if ($cmd == 'select') {
-    if (!$galleryId || !$ansel_storage->galleryExists($galleryId)) {
+    if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) {
         $error = _("Invalid gallery specified.") . "<br />\n";
     } else {
         try {
-            $gallery = $ansel_storage->getGallery($galleryId);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
             $error = false;
         } catch (Ansel_Exception $e) {
             $error = _("There was an error accessing the gallery");
@@ -114,7 +114,7 @@ if ($cmd == 'new') {
     if ($create) {
         /* Creating a new gallery. */
         try {
-            $gallery = $ansel_storage->createGallery(
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery(
                     array('name' => $gallery_name, 'desc' => $gallery_desc));
             $galleryId = $gallery->id;
             $msg = sprintf(_("The gallery \"%s\" was created successfully."), $gallery_name);
@@ -166,11 +166,11 @@ if ($cmd == 'add') {
     $galleryId = Horde_Util::getFormData('gallery');
     $name = isset($_FILES['imagefile']['name']) ? Horde_Util::dispelMagicQuotes($_FILES['imagefile']['name']) : null;
     $file = isset($_FILES['imagefile']['tmp_name']) ? $_FILES['imagefile']['tmp_name'] : null;
-    if (!$galleryId || !$ansel_storage->galleryExists($galleryId)) {
+    if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) {
         $error = _("Invalid gallery specified.") . "<br />\n";
     } else {
         try {
-            $gallery = $ansel_storage->getGallery($galleryId);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
             if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
                 $error = sprintf(_("Access denied adding photos to \"%s\"."), $gallery->get('name'));
             } else {
@@ -191,7 +191,7 @@ if ($cmd == 'add') {
                 $error = $e->getMessage();
             }
 
-            $gallery = $ansel_storage->getGallery($galleryId);
+            $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
             try {
                 $image_id = $gallery->addImage($image);
                 $error = false;