From 291d53e7e190a917673839e9ad4aa9756d6b421a Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sat, 25 Dec 2010 23:48:07 -0500 Subject: [PATCH] Always request an Ansel_Storage object, we have a factory binder --- ansel/disclamer.php | 2 +- ansel/edit_dates.php | 8 +-- ansel/faces/claim.php | 2 +- ansel/faces/custom.php | 4 +- ansel/faces/gallery.php | 2 +- ansel/faces/image.php | 2 +- ansel/faces/name.php | 4 +- ansel/faces/report.php | 2 +- ansel/gallery.php | 10 ++-- ansel/gallery/captions.php | 2 +- ansel/gallery/delete.php | 6 +-- ansel/gallery/sort.php | 2 +- ansel/group.php | 4 +- ansel/image.php | 40 +++++++-------- ansel/img/download.php | 4 +- ansel/img/ecard.php | 2 +- ansel/img/full.php | 4 +- ansel/img/index.php | 4 +- ansel/img/mini.php | 4 +- ansel/img/prettythumb.php | 4 +- ansel/img/screen.php | 4 +- ansel/img/thumb.php | 4 +- ansel/img/upload.php | 2 +- ansel/img/upload_preview.php | 2 +- ansel/lib/Ajax/Imple/EditCaption.php | 6 +-- ansel/lib/Ajax/Imple/EditFaces.php | 10 ++-- ansel/lib/Ajax/Imple/EditGalleryFaces.php | 12 ++--- ansel/lib/Ajax/Imple/GallerySlugCheck.php | 2 +- ansel/lib/Ajax/Imple/ImageSaveGeotag.php | 6 +-- ansel/lib/Ajax/Imple/LocationAutoCompleter.php | 6 +-- ansel/lib/Ajax/Imple/TagActions.php | 6 +-- ansel/lib/Ansel.php | 15 +++--- ansel/lib/Api.php | 59 +++++++++++----------- ansel/lib/Application.php | 17 +++++++ ansel/lib/Block/gallery.php | 6 +-- ansel/lib/Block/my_galleries.php | 15 +++--- ansel/lib/Block/random_photo.php | 2 +- ansel/lib/Block/recent_comments.php | 8 +-- ansel/lib/Block/recently_added.php | 12 ++--- ansel/lib/Block/recently_added_geodata.php | 4 +- ansel/lib/Faces/Base.php | 16 +++--- ansel/lib/Gallery.php | 18 +++---- ansel/lib/Gallery/Decorator/Date.php | 5 +- ansel/lib/GalleryMode/Date.php | 18 +++---- ansel/lib/GalleryMode/Normal.php | 18 +++---- ansel/lib/Image.php | 20 ++++---- ansel/lib/ImageGenerator.php | 3 +- ansel/lib/ImageGenerator/PolaroidThumb.php | 2 +- ansel/lib/ImageGenerator/RoundedThumb.php | 2 +- ansel/lib/ImageGenerator/ShadowThumb.php | 2 +- ansel/lib/Injector/Factory/Storage.php | 18 +++++-- ansel/lib/Search/Tag.php | 4 +- ansel/lib/Storage.php | 2 +- ansel/lib/Tagger.php | 4 +- ansel/lib/Tile/Image.php | 2 +- ansel/lib/View/Base.php | 4 +- ansel/lib/View/EmbeddedRenderer/GalleryLink.php | 2 +- ansel/lib/View/EmbeddedRenderer/Mini.php | 4 +- ansel/lib/View/GalleryProperties.php | 16 +++--- ansel/lib/View/GalleryRenderer/Gallery.php | 4 +- ansel/lib/View/GalleryRenderer/GalleryLightbox.php | 4 +- ansel/lib/View/Image.php | 2 +- ansel/lib/View/List.php | 2 +- ansel/lib/View/Results.php | 4 +- ansel/lib/View/Upload.php | 2 +- ansel/lib/Widget/Geotag.php | 4 +- ansel/lib/Widget/OtherGalleries.php | 3 +- ansel/lib/Widget/SimilarPhotos.php | 4 +- ansel/map_edit.php | 6 +-- ansel/perms.php | 9 ++-- ansel/preview.php | 4 +- ansel/protect.php | 2 +- ansel/report.php | 2 +- ansel/rss.php | 23 ++++----- ansel/scripts/all_images_exif_to_tags.php | 2 +- ansel/scripts/ansel.php | 10 ++-- ansel/scripts/recursive_import.php | 13 +++-- ansel/scripts/remote_import.php | 9 ++-- ansel/templates/gallery/delete_confirmation.inc | 2 +- ansel/templates/group/owner.inc | 8 ++- ansel/xppublish.php | 12 ++--- 81 files changed, 303 insertions(+), 298 deletions(-) diff --git a/ansel/disclamer.php b/ansel/disclamer.php index b45396a36..686f1ab19 100644 --- a/ansel/disclamer.php +++ b/ansel/disclamer.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('ansel'); $vars = Horde_Variables::getDefaultVariables(); try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($vars->get('gallery')); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($vars->get('gallery')); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage()); Horde::url('view.php?view=List', true)->redirect(); diff --git a/ansel/edit_dates.php b/ansel/edit_dates.php index 7a95b43a0..ecaf73253 100644 --- a/ansel/edit_dates.php +++ b/ansel/edit_dates.php @@ -18,7 +18,7 @@ $page = Horde_Util::getFormData('page', 0); /* If we have a single gallery, check perms now */ if (!empty($gallery_id)) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); if (empty($gallery_id)) { // Images might be from different galleries - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { continue; } @@ -82,7 +82,7 @@ $html = ''; foreach ($keys as $key) { $html .= '[thumbnail]'; } -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(array_pop($keys)); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(array_pop($keys)); /* Display the form */ $vars->set('image', $images); $vars->set('gallery', $gallery_id); diff --git a/ansel/faces/claim.php b/ansel/faces/claim.php index f80e91094..6d11d6344 100644 --- a/ansel/faces/claim.php +++ b/ansel/faces/claim.php @@ -35,7 +35,7 @@ if ($form->validate()) { $notification->push(_("Action was cancelled."), 'horde.warning'); } else { $report = Ansel_Report::factory(); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($face['gallery_id']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($face['gallery_id']); $face_link = Horde::url('faces/custom.php', true)->add( array('name' => $vars->get('person'), diff --git a/ansel/faces/custom.php b/ansel/faces/custom.php index bb5905dc6..ad20ef85c 100644 --- a/ansel/faces/custom.php +++ b/ansel/faces/custom.php @@ -24,14 +24,14 @@ if (!empty($url)) { $form_post = Horde::url('faces/savecustom.php')->add($urlparams); try { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($image); Horde::url('list.php')->redirect(); exit; } -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied editing the photo.")); Ansel::getUrlFor('view', array('gallery' => $image->gallery))->redirect(); diff --git a/ansel/faces/gallery.php b/ansel/faces/gallery.php index 301138bd5..b2b0117ef 100644 --- a/ansel/faces/gallery.php +++ b/ansel/faces/gallery.php @@ -22,7 +22,7 @@ if (empty($gallery_id)) { exit; } try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); Ansel::getUrlFor('view', array('gallery' => $gallery_id))->redirect(); diff --git a/ansel/faces/image.php b/ansel/faces/image.php index d8100a283..8eac8d280 100644 --- a/ansel/faces/image.php +++ b/ansel/faces/image.php @@ -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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); try { $image->createView('screen'); $result = $faces->getFromPicture($image_id, $autocreate); diff --git a/ansel/faces/name.php b/ansel/faces/name.php index 8dcb4b0ab..b56923ab1 100644 --- a/ansel/faces/name.php +++ b/ansel/faces/name.php @@ -17,8 +17,8 @@ $image_id = (int)Horde_Util::getFormData('image'); $face_id = (int)Horde_Util::getFormData('face'); $name = Horde_Util::getFormData('name'); -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); -$gallery = $$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()>getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')>getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception('Access denied editing the photo.'); } diff --git a/ansel/faces/report.php b/ansel/faces/report.php index 1ac306c96..387e5ba4e 100644 --- a/ansel/faces/report.php +++ b/ansel/faces/report.php @@ -39,7 +39,7 @@ if ($form->validate()) { } else { require ANSEL_BASE . '/lib/Report.php'; $report = Ansel_Report::factory(); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($face['gallery_id']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($face['gallery_id']); $face_link = Horde::url('faces/face.php', true)->add( array('name' => $vars->get('person'), diff --git a/ansel/gallery.php b/ansel/gallery.php index a6b4f4fa7..0e917f9ab 100644 --- a/ansel/gallery.php +++ b/ansel/gallery.php @@ -33,7 +33,7 @@ case 'modify': case 'downloadzip': $galleryId = Horde_Util::getFormData('gallery'); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); if (!$registry->getAuth() || !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { @@ -51,7 +51,7 @@ case 'empty': $galleryId = Horde_Util::getFormData('gallery'); if ($galleryId) { try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); require $registry->get('templates', 'horde') . '/common-header.inc'; echo Horde::menu(); $notification->notify(array('listeners' => 'status')); @@ -71,7 +71,7 @@ case 'generateDefault': // Re-generate the default pretty gallery image. $galleryId = Horde_Util::getFormData('gallery'); try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); $gallery->clearStacks(); $notification->push(_("The gallery's default photo has successfully been reset."), 'horde.success'); Horde::url('view.php', true)->add('gallery', $galleryId)->redirect(); @@ -86,7 +86,7 @@ case 'generateThumbs': // Re-generate all of this gallery's prettythumbs. $galleryId = Horde_Util::getFormData('gallery'); try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage(), 'horde.error'); Horde::url('index.php', true)->redirect(); @@ -101,7 +101,7 @@ case 'deleteCache': // Delete all cached image views. $galleryId = Horde_Util::getFormData('gallery'); try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage(), 'horde.error'); Horde::url('index.php', true)->redirect(); diff --git a/ansel/gallery/captions.php b/ansel/gallery/captions.php index ab99fb7f5..f2e8e00c2 100644 --- a/ansel/gallery/captions.php +++ b/ansel/gallery/captions.php @@ -17,7 +17,7 @@ if (!$galleryId) { exit; } try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Error accessing %s: %s"), $galleryId, $e->getMessage()), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); diff --git a/ansel/gallery/delete.php b/ansel/gallery/delete.php index afcef4dbb..2653ee73e 100644 --- a/ansel/gallery/delete.php +++ b/ansel/gallery/delete.php @@ -17,7 +17,7 @@ $galleryId = Horde_Util::getPost('gallery'); if ($galleryId) { try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 { - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->removeGallery($gallery); + $GLOBALS['injector']->getInstance('Ansel_Storage')->removeGallery($gallery); $notification->push(sprintf(_("Successfully deleted %s."), $gallery->get('name')), 'horde.success'); } catch (Ansel_Exception $e) { $notification->push(sprintf( @@ -58,7 +58,7 @@ if ($galleryId) { $gallery->get('name')), 'horde.error'); } else { - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->emptyGallery($gallery); + $GLOBALS['injector']->getInstance('Ansel_Storage')->emptyGallery($gallery); $notification->push(sprintf(_("Successfully emptied \"%s\""), $gallery->get('name'))); } Ansel::getUrlFor('view', diff --git a/ansel/gallery/sort.php b/ansel/gallery/sort.php index f57bee8ae..6f8bab5dc 100644 --- a/ansel/gallery/sort.php +++ b/ansel/gallery/sort.php @@ -19,7 +19,7 @@ if (!isset($galleryId)) { exit; } try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); } catch (Ansel_Excception $e) { $notification->push(_("There was an error accessing the gallery."), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); diff --git a/ansel/group.php b/ansel/group.php index 8210358ee..4256d8d03 100644 --- a/ansel/group.php +++ b/ansel/group.php @@ -29,9 +29,9 @@ $groups_perpage = $prefs->getValue('groupsperpage'); switch ($groupby) { case 'owner': try { - if ($num_groups = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->shares->countOwners(Horde_Perms::SHOW, null, false)) { + if ($num_groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->shares->countOwners(Horde_Perms::SHOW, null, false)) { - $groups = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->shares->listOwners(Horde_Perms::SHOW, + $groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->shares->listOwners(Horde_Perms::SHOW, null, false, $gbpage * $groups_perpage, diff --git a/ansel/image.php b/ansel/image.php index 6b6aa2973..616dd86d4 100644 --- a/ansel/image.php +++ b/ansel/image.php @@ -53,7 +53,7 @@ if (is_null($actionID) && is_null($tags)) { /* Get the gallery object and style information */ try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); @@ -64,7 +64,7 @@ try { if (!is_null($tags) && strlen($tags)) { $tags = explode(',', $tags); if (!empty($image_id)) { - $resource = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $resource = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); } else { $resource = $gallery; } @@ -101,7 +101,7 @@ switch ($actionID) { case 'deletetags': $tag = Horde_Util::getFormData('tag'); if (!empty($image_id)) { - $resource = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $resource = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $page = Horde_Util::getFormData('page', 0); $url = Ansel::getUrlFor('view', array_merge( array('view' => 'Image', @@ -126,7 +126,7 @@ case 'deletetags': case 'modify': try { - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $ret = Horde_Util::getFormData('ret', 'gallery'); } catch (Ansel_Exception $e) { $notification->push(_("Photo not found."), 'horde.error'); @@ -202,7 +202,7 @@ case 'save': } catch (Horde_Browser_Exception $e) {} } - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->caption = $vars->get('image_desc'); $image->setTags(explode(',' , $vars->get('image_tags'))); @@ -307,7 +307,7 @@ case 'resizeedit': } /* Retrieve image details. */ - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $title = sprintf(_("Edit %s :: %s"), $gallery->get('name'), $image->filename); @@ -366,7 +366,7 @@ case 'watermark': true)->redirect(); exit; } else { - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->watermark('screen', $watermark, $watermark_halign, $watermark_valign, $watermark_font); $image->updateData($image->raw('screen'), 'screen'); @@ -394,7 +394,7 @@ case 'resize': 'horde.error'); } else { try { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); @@ -457,7 +457,7 @@ case 'resize': case 'setwatermark': $title = _("Watermark"); try { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($image->getMessage(), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); @@ -504,7 +504,7 @@ case 'previewrotate270': $action = substr($actionID, 7); /* Retrieve image details. */ - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $title = sprintf(_("Preview changes for %s :: %s"), $gallery->get('name'), $image->filename); @@ -522,35 +522,35 @@ case 'imagerotate180': case 'imagerotate270': $view = Horde_Util::getFormData('view'); $angle = intval(substr($actionID, 11)); - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->rotate($view, $angle); $image->display($view); exit; case 'imageflip': $view = Horde_Util::getFormData('view'); - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->flip($view); $image->display($view); exit; case 'imagemirror': $view = Horde_Util::getFormData('view'); - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->mirror($view); $image->display($view); exit; case 'imagegrayscale': $view = Horde_Util::getFormData('view'); - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->grayscale($view); $image->display($view); exit; case 'imagewatermark': $view = Horde_Util::getFormData('view'); - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->watermark($view, $watermark, $watermark_halign, $watermark_valign, $watermark_font); $image->display($view); @@ -612,7 +612,7 @@ case 'move': $newGallery = Horde_Util::getFormData('new_gallery'); if ($images && $newGallery) { try { - $newGallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($newGallery); + $newGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($newGallery); $result = $gallery->moveImagesTo($images, $newGallery); $notification->push( sprintf(ngettext("Moved %d photo from \"%s\" to \"%s\"", @@ -656,7 +656,7 @@ case 'copy': $newGallery = Horde_Util::getFormData('new_gallery'); if ($images && $newGallery) { try { - $newGallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($newGallery); + $newGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($newGallery); $result = $gallery->copyImagesTo($images, $newGallery); $notification->push( sprintf(ngettext("Copied %d photo to %s", @@ -683,7 +683,7 @@ case 'copy': case 'downloadzip': $galleryId = Horde_Util::getFormData('gallery'); if ($galleryId) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); if (!$registry->getAuth() || !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) || $gallery->hasPasswd() || !$gallery->isOldEnough()) { @@ -729,7 +729,7 @@ case 'previewcrop': $action = substr($actionID, 7); /* Retrieve image details. */ - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $title = sprintf(_("Preview changes for %s :: %s"), $gallery->get('name'), $image->filename); @@ -747,7 +747,7 @@ case 'imagecrop': if ($gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $params = Horde_Util::getFormData('params'); list($x1, $y1, $x2, $y2) = explode('.', $params); - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->load('full'); $image->crop($x1, $y1, $x2, $y2); $image->display(); diff --git a/ansel/img/download.php b/ansel/img/download.php index e62c57c85..91ee9de77 100644 --- a/ansel/img/download.php +++ b/ansel/img/download.php @@ -11,8 +11,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(Horde_Util::getFormData('image')); -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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__); } diff --git a/ansel/img/ecard.php b/ansel/img/ecard.php index b0a7e6794..0ee638b02 100644 --- a/ansel/img/ecard.php +++ b/ansel/img/ecard.php @@ -17,7 +17,7 @@ if (empty($conf['ecard']['enable'])) { } /* Get the gallery and the image, and abort if either fails. */ -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(Horde_Util::getFormData('gallery')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(Horde_Util::getFormData('gallery')); $image = $gallery->getImage(Horde_Util::getFormData('image')); /* Run through the action handlers. */ diff --git a/ansel/img/full.php b/ansel/img/full.php index 5bc185d09..3fa0b4f02 100644 --- a/ansel/img/full.php +++ b/ansel/img/full.php @@ -11,8 +11,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(Horde_Util::getFormData('image')); -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) || !$gallery->canDownload()) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/index.php b/ansel/img/index.php index 7a031b9cc..f509001bc 100644 --- a/ansel/img/index.php +++ b/ansel/img/index.php @@ -11,8 +11,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(Horde_Util::getFormData('image')); -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/mini.php b/ansel/img/mini.php index 367453850..50a6c6cb0 100644 --- a/ansel/img/mini.php +++ b/ansel/img/mini.php @@ -11,8 +11,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(Horde_Util::getFormData('image')); -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(abs($image->gallery)); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($image->gallery)); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/prettythumb.php b/ansel/img/prettythumb.php index d342a787d..31559c0be 100644 --- a/ansel/img/prettythumb.php +++ b/ansel/img/prettythumb.php @@ -21,8 +21,8 @@ if ($thumbstyle && $background) { } else { $style = null; } -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(Horde_Util::getFormData('image')); -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(abs($image->gallery)); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($image->gallery)); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/screen.php b/ansel/img/screen.php index 53c0f2165..1cb0f88d8 100644 --- a/ansel/img/screen.php +++ b/ansel/img/screen.php @@ -11,8 +11,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(Horde_Util::getFormData('image')); -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/thumb.php b/ansel/img/thumb.php index 0156a3e38..4da9b0f68 100644 --- a/ansel/img/thumb.php +++ b/ansel/img/thumb.php @@ -11,8 +11,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(Horde_Util::getFormData('image')); -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(abs($image->gallery)); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($image->gallery)); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/upload.php b/ansel/img/upload.php index 0a03adb33..58d9590df 100644 --- a/ansel/img/upload.php +++ b/ansel/img/upload.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('ansel'); $gallery_id = Horde_Util::getFormData('gallery'); try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error'); Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); diff --git a/ansel/img/upload_preview.php b/ansel/img/upload_preview.php index d61c782bd..c81e6210e 100644 --- a/ansel/img/upload_preview.php +++ b/ansel/img/upload_preview.php @@ -11,7 +11,7 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery((int)Horde_Util::getFormData('gallery')); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery((int)Horde_Util::getFormData('gallery')); } catch (Ansel_Exception $e) { echo $e->getMessage(); Horde::logMessage($e->getMessage(), 'err'); diff --git a/ansel/lib/Ajax/Imple/EditCaption.php b/ansel/lib/Ajax/Imple/EditCaption.php index e84866d55..9d401baac 100644 --- a/ansel/lib/Ajax/Imple/EditCaption.php +++ b/ansel/lib/Ajax/Imple/EditCaption.php @@ -56,7 +56,7 @@ class Ansel_Ajax_Imple_EditCaption extends Horde_Core_Ajax_Imple /* Are we requesting the unformatted text? */ if (!empty($args['action']) && $args['action'] == 'load') { $id = $args['id']; - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($id); $caption = $image->caption; return $caption; @@ -68,8 +68,8 @@ class Ansel_Ajax_Imple_EditCaption extends Horde_Core_Ajax_Imple return ''; } $id = $args['id']; - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($id); - $g = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($id); + $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if ($g->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $image->caption = $pref_value; try { diff --git a/ansel/lib/Ajax/Imple/EditFaces.php b/ansel/lib/Ajax/Imple/EditFaces.php index f303c93d5..f4969a69e 100644 --- a/ansel/lib/Ajax/Imple/EditFaces.php +++ b/ansel/lib/Ajax/Imple/EditFaces.php @@ -49,7 +49,7 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Core_Ajax_Imple // 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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->createView('screen'); $result = $faces->getFromPicture($image_id, $autocreate); } @@ -70,8 +70,8 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Core_Ajax_Imple case 'delete': // delete - deletes a single face from an image. $face_id = (int)$post['face']; - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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_Core_Ajax_Imple } $name = $post['facename']; - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); - $gallery = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); + $gallery = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception('You are not allowed to edit this photo'); } diff --git a/ansel/lib/Ajax/Imple/EditGalleryFaces.php b/ansel/lib/Ajax/Imple/EditGalleryFaces.php index fb3773a32..2a560ec69 100644 --- a/ansel/lib/Ajax/Imple/EditGalleryFaces.php +++ b/ansel/lib/Ajax/Imple/EditGalleryFaces.php @@ -29,7 +29,7 @@ class Ansel_Ajax_Imple_EditGalleryFaces extends Horde_Ajax_Imple_Base $autocreate = true; $result = $faces->getImageFacesData($image_id); if (empty($result)) { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($this->_params['image_id']); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($this->_params['image_id']); $image->createView('screen'); $result = $faces->getFromPicture($this->_params['image_id'], $autocreate); } @@ -67,7 +67,7 @@ class Ansel_Ajax_Imple_EditGalleryFaces 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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->createView('screen'); $result = $faces->getFromPicture($image_id, $autocreate); } @@ -88,8 +88,8 @@ class Ansel_Ajax_Imple_EditGalleryFaces extends Horde_Ajax_Imple_Base case 'delete': // delete - deletes a single face from an image. $face_id = (int)$post['face']; - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); - $gallery = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); + $gallery = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (!$gallery->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception('Access denied editing the photo.'); } @@ -106,8 +106,8 @@ class Ansel_Ajax_Imple_EditGalleryFaces extends Horde_Ajax_Imple_Base } $name = $post['facename']; - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); - $gallery = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); + $gallery = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (!$gallery->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception('You are not allowed to edit this photo'); } diff --git a/ansel/lib/Ajax/Imple/GallerySlugCheck.php b/ansel/lib/Ajax/Imple/GallerySlugCheck.php index f734a999a..135917b03 100644 --- a/ansel/lib/Ajax/Imple/GallerySlugCheck.php +++ b/ansel/lib/Ajax/Imple/GallerySlugCheck.php @@ -38,7 +38,7 @@ class Ansel_Ajax_Imple_GallerySlugCheck extends Horde_Core_Ajax_Imple return array('response' => '0'); } - $exists = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->slugExists($slug) ? 0 : 1; + $exists = $GLOBALS['injector']->getInstance('Ansel_Storage')->slugExists($slug) ? 0 : 1; return array('response' => $exists); } diff --git a/ansel/lib/Ajax/Imple/ImageSaveGeotag.php b/ansel/lib/Ajax/Imple/ImageSaveGeotag.php index 7049896b5..a3db45b7b 100644 --- a/ansel/lib/Ajax/Imple/ImageSaveGeotag.php +++ b/ansel/lib/Ajax/Imple/ImageSaveGeotag.php @@ -39,8 +39,8 @@ class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Core_Ajax_Imple // Get the image and gallery to check perms try { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage((int)$img); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage((int)$img); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); } catch (Ansel_Exception $e) { return array('response' => 0); } @@ -64,7 +64,7 @@ class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Core_Ajax_Imple // Now get the "add geotag" stuff $addurl = Horde::url('map_edit.php')->add('image', $img); $addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::url('map_edit.php'), array('params' => array('image' => $img), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;')); - $imgs = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); + $imgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); if (count($imgs) > 0) { $imgsrc = '
'; foreach ($imgs as $id => $data) { diff --git a/ansel/lib/Ajax/Imple/LocationAutoCompleter.php b/ansel/lib/Ajax/Imple/LocationAutoCompleter.php index c45f12f6a..1d3ebe9a0 100644 --- a/ansel/lib/Ajax/Imple/LocationAutoCompleter.php +++ b/ansel/lib/Ajax/Imple/LocationAutoCompleter.php @@ -27,7 +27,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Core_Ajax_Imple_AutoC /* Use ajax? */ if (!$GLOBALS['session']->exists('ansel', 'ajax_locationac')) { - $results = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->searchLocations(); + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->searchLocations(); if ($results instanceof PEAR_Error) { Horde::logMessage($results, 'ERR'); } else { @@ -39,7 +39,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Core_Ajax_Imple_AutoC $ret['ajax'] = 'LocationAutoCompleter'; } else { if (empty($results)) { - $results = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->searchLocations(); + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->searchLocations(); } $ret['browser'] = Horde_Serialize::serialize($results, Horde_Serialize::JSON); } @@ -55,7 +55,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Core_Ajax_Imple_AutoC return array(); } try { - $locs = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->searchLocations($input); + $locs = $GLOBALS['injector']->getInstance('Ansel_Storage')->searchLocations($input); if (!count($locs)) { $locs = new StdClass(); } diff --git a/ansel/lib/Ajax/Imple/TagActions.php b/ansel/lib/Ajax/Imple/TagActions.php index 40c721452..d1aa17f61 100644 --- a/ansel/lib/Ajax/Imple/TagActions.php +++ b/ansel/lib/Ajax/Imple/TagActions.php @@ -54,11 +54,11 @@ class Ansel_Ajax_Imple_TagActions extends Horde_Core_Ajax_Imple /* Get the resource owner */ if ($type == 'gallery') { - $resource = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($id); + $resource = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($id); $parent = $resource; } else { - $resource = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($id); - $parent = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($resource->gallery); + $resource = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($id); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($resource->gallery); } switch ($action) { diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index 44433e45a..65d042c0b 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -75,8 +75,7 @@ class Ansel static public function selectGalleries($params = array()) { $galleries = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel__Storage') ->listGalleries($params); $params = new Horde_Support_Array($params); @@ -193,8 +192,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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($data['image']); - $g = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($data['gallery']); + $i = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($data['image']); + $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($data['gallery']); if ($g->get('view_mode') == 'Date') { $imgDate = new Horde_Date($i->originalDate); $data['year'] = $imgDate->year; @@ -394,7 +393,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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($imageId); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($imageId); } catch (Ansel_Exception $e) { Horde::logMessage($e, 'ERR'); return Horde::url((string)Ansel::getErrorImage($view), $full); @@ -520,7 +519,7 @@ class Ansel { global $prefs; - $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); $groupby = Horde_Util::getFormData('groupby', $prefs->getValue('groupby')); $owner = Horde_Util::getFormData('owner'); $image_id = (int)Horde_Util::getFormData('image'); @@ -802,11 +801,11 @@ class Ansel $zipfiles = array(); foreach ($images as $id) { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($id); // If we didn't select an entire gallery, check the download // size for each image. if (!isset($view)) { - $g = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); $v = $g->canDownload() ? 'full' : 'screen'; } else { $v = $view; diff --git a/ansel/lib/Api.php b/ansel/lib/Api.php index 1bd29c313..164e9c903 100644 --- a/ansel/lib/Api.php +++ b/ansel/lib/Api.php @@ -36,7 +36,7 @@ class Ansel_Api extends Horde_Registry_Api $path = trim($path, '/'); $parts = explode('/', $path); - $storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); if (empty($path)) { $owners = array(); $galleries = $storage->listGalleries(array('all_levels' => false)); @@ -80,7 +80,7 @@ class Ansel_Api extends Horde_Registry_Api // This request if for a certain gallery, list all sub-galleries // and images. $gallery_id = end($parts); - $galleries = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGalleries(array($gallery_id)); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleries(array($gallery_id)); if (!isset($galleries[$gallery_id]) || !$galleries[$gallery_id]->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { @@ -92,7 +92,7 @@ class Ansel_Api extends Horde_Registry_Api } elseif (count($parts) > 2 && $this->galleryExists(null, $parts[count($parts) - 2]) && - ($image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage(end($parts)))) { + ($image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(end($parts)))) { return array('data' => $image->raw(), 'mimetype' => $image->type, @@ -189,10 +189,10 @@ class Ansel_Api extends Horde_Registry_Api } $image_name = array_pop($parts); $gallery_id = end($parts); - if (!$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->galleryExists($gallery_id)) { + if (!$GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($gallery_id)) { throw new Horde_Exception_NotFound("Gallery does not exist"); } - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception_PermissionDenied(_("Access denied adding photos to \"%s\".")); } @@ -218,7 +218,7 @@ class Ansel_Api extends Horde_Registry_Api } try { - if (!($image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id))) { + if (!($image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id))) { return false; } } catch (Ansel_Exception $e) { @@ -337,9 +337,9 @@ class Ansel_Api extends Horde_Registry_Api throw new InvalidArgumentException(_("A gallery to add this photo to is required.")); } if (!empty($params['slug'])) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGalleryBySlug($params['slug']); - } elseif ($GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->galleryExists($gallery_id)) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleryBySlug($params['slug']); + } elseif ($GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($gallery_id)) { + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } /* Check perms for requested gallery */ @@ -419,8 +419,8 @@ class Ansel_Api extends Horde_Registry_Api $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $params['scope']); } - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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'))); } @@ -470,7 +470,7 @@ class Ansel_Api extends Horde_Registry_Api } /* Create the gallery */ - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->createGallery($attributes, $permobj, $parent); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->createGallery($attributes, $permobj, $parent); return $gallery->id; } @@ -500,11 +500,11 @@ class Ansel_Api extends Horde_Registry_Api } /* Get, and check perms on the gallery */ - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 { - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->removeGallery($gallery); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->removeGallery($gallery); } } @@ -528,9 +528,9 @@ class Ansel_Api extends Horde_Registry_Api try { if (!empty($params['slug'])) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGalleryBySlug($params['slug']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleryBySlug($params['slug']); } else { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } return (int)$gallery->countImages(); } catch (Ansel_Exception $e) { @@ -558,9 +558,9 @@ class Ansel_Api extends Horde_Registry_Api } if (!empty($params['slug'])) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGalleryBySlug($params['slug']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleryBySlug($params['slug']); } else { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } return $gallery->getKeyImage(empty($params['style']) ? 'ansel_default' : $params['style']); @@ -617,8 +617,8 @@ class Ansel_Api extends Horde_Registry_Api } /* Get image and gallery */ - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); /* Check age and password */ if (!$gallery->hasPasswd() || !$gallery->isOldEnough()) { @@ -679,8 +679,7 @@ class Ansel_Api extends Horde_Registry_Api $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $params['scope']); } $galleries = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries($params); $return = array(); foreach ($galleries as $gallery) { @@ -707,9 +706,9 @@ class Ansel_Api extends Horde_Registry_Api } if (count($slugs)) { - $results = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGalleriesBySlugs($slugs); + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleriesBySlugs($slugs); } else { - $results = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGalleries($ids); + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleries($ids); } // We can't just return the results of the getGalleries call - we need @@ -780,7 +779,7 @@ class Ansel_Api extends Horde_Registry_Api $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - $storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); // 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)) { @@ -846,7 +845,7 @@ class Ansel_Api extends Horde_Registry_Api if (!is_null($app)) { $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - $images = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRecentImages($galleries, $limit, $slugs); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages($galleries, $limit, $slugs); $imagelist = array(); if ($style) { $style = Ansel::getStyleDefinition($style); @@ -892,7 +891,7 @@ class Ansel_Api extends Horde_Registry_Api $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->countGalleries($GLOBALS['registry']->getAuth(), $perm, + return $GLOBALS['injector']->getInstance('Ansel_Storage')->countGalleries($GLOBALS['registry']->getAuth(), $perm, $attributes, $parent, $allLevels); } @@ -949,7 +948,7 @@ class Ansel_Api extends Horde_Registry_Api $return = array(); if (!empty($results['images'])) { foreach ($results['images'] as $image_id) { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $desc = $image->caption; $title = $image->filename; $view_url = Ansel::getUrlFor('view', @@ -967,7 +966,7 @@ class Ansel_Api extends Horde_Registry_Api if (!empty($results['galleries'])) { foreach ($results['galleries'] as $gallery) { - $gal = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery); $view_url = Horde::url('view.php')->add( array('gallery' => $gallery, 'view' => 'Gallery')); @@ -996,7 +995,7 @@ class Ansel_Api extends Horde_Registry_Api $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->galleryExists($gallery_id, $slug); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($gallery_id, $slug); } /** diff --git a/ansel/lib/Application.php b/ansel/lib/Application.php index e8ccb00e7..a704e5345 100644 --- a/ansel/lib/Application.php +++ b/ansel/lib/Application.php @@ -228,4 +228,21 @@ class Ansel_Application extends Horde_Registry_Application return false; } + /** + * Callback, called from common-template-mobile.inc that sets up the jquery + * mobile init hanler. + */ + public function mobileInitCallback() + { + //Horde::addScriptFile('mobile.js'); + require ANSEL_TEMPLATES . '/mobile/javascript_defs.php'; + + /* Inline script. */ + Horde::addInlineScript( + '$(window.document).bind("mobileinit", function() { + $.mobile.page.prototype.options.backBtnText = "' . _("Back") .'"; + $.mobile.loadingMessage = "' . _("loading") . '";' + ); + } + } diff --git a/ansel/lib/Block/gallery.php b/ansel/lib/Block/gallery.php index c9402eb0e..607e438fa 100644 --- a/ansel/lib/Block/gallery.php +++ b/ansel/lib/Block/gallery.php @@ -48,7 +48,7 @@ class Horde_Block_ansel_gallery extends Horde_Block 'type' => 'checkbox', 'default' => true)); - $storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); if ($storage->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { foreach ($storage->listGalleries() as $gal) { $params['gallery']['values'][$gal->id] = $gal->get('name'); @@ -138,9 +138,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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->_params['gallery']); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_params['gallery']); } else { - $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRandomGallery(); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRandomGallery(); } // Protect at least a little bit against getting an empty gallery. We diff --git a/ansel/lib/Block/my_galleries.php b/ansel/lib/Block/my_galleries.php index 074bf5822..b0bb845e8 100644 --- a/ansel/lib/Block/my_galleries.php +++ b/ansel/lib/Block/my_galleries.php @@ -57,14 +57,13 @@ class Horde_Block_ansel_my_galleries extends Horde_Block /* Get the top level galleries */ try { - $galleries = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage') - ->create()->listGalleries(array('perm' => Horde_Perms::EDIT, - 'attributes' => $GLOBALS['registry']->getAuth(), - 'all_levels' => false, - 'count' => empty($this->_params['limit']) ? 0 : $this->_params['limit'], - 'sort_by' => 'last_modified', - 'direction' => Ansel::SORT_DESCENDING)); - + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage') + ->listGalleries(array('perm' => Horde_Perms::EDIT, + 'attributes' => $GLOBALS['registry']->getAuth(), + 'all_levels' => false, + 'count' => empty($this->_params['limit']) ? 0 : $this->_params['limit'], + 'sort_by' => 'last_modified', + 'direction' => Ansel::SORT_DESCENDING)); } catch (Ansel_Exception $e) { return $e->getMessage(); } diff --git a/ansel/lib/Block/random_photo.php b/ansel/lib/Block/random_photo.php index 7a103db3e..289a1011a 100644 --- a/ansel/lib/Block/random_photo.php +++ b/ansel/lib/Block/random_photo.php @@ -44,7 +44,7 @@ class Horde_Block_ansel_random_photo extends Horde_Block */ protected function _content() { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRandomGallery(); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRandomGallery(); if (!$gallery) { return _("There are no photo galleries available."); } diff --git a/ansel/lib/Block/recent_comments.php b/ansel/lib/Block/recent_comments.php index 340391f74..b18b51588 100644 --- a/ansel/lib/Block/recent_comments.php +++ b/ansel/lib/Block/recent_comments.php @@ -40,7 +40,7 @@ class Horde_Block_ansel_recent_comments extends Horde_Block 'type' => 'enum', 'default' => '__random', 'values' => array('all' => 'All'))); - $storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); if ($storage->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { foreach ($storage->listGalleries(array('perm' => Horde_Perms::READ)) as $id => $gal) { $params['gallery']['values'][$id] = $gal->get('name'); @@ -121,7 +121,7 @@ class Horde_Block_ansel_recent_comments extends Horde_Block foreach ($results as $comment) { try { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($comment['image_id']); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($comment['image_id']); $url = Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => abs($image->gallery), @@ -163,9 +163,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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->_params['gallery']); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_params['gallery']); } else { - $this->_gallery =$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRandomGallery(); + $this->_gallery =$GLOBALS['injector']->getInstance('Ansel_Storage')->getRandomGallery(); } if (empty($this->_gallery)) { diff --git a/ansel/lib/Block/recently_added.php b/ansel/lib/Block/recently_added.php index c873791cc..6af4caf5f 100644 --- a/ansel/lib/Block/recently_added.php +++ b/ansel/lib/Block/recently_added.php @@ -44,8 +44,8 @@ class Horde_Block_ansel_recently_added extends Horde_Block 'default' => 10), ); - if ($GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { - foreach ($GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->listGalleries(array('perm' => Horde_Perms::READ)) as $id => $gal) { + if ($GLOBALS['injector']->getInstance('Ansel_Storage')->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { + foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('perm' => Horde_Perms::READ)) as $id => $gal) { if (!$gal->hasPasswd() && $gal->isOldEnough()) { $params['gallery']['values'][$id] = $gal->get('name'); } @@ -98,7 +98,7 @@ class Horde_Block_ansel_recently_added extends Horde_Block // Retrieve the images, but protect against very large values for limit. try { - $results = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRecentImages( + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages( $galleries, min($this->_params['limit'], 100)); } catch (Ansel_Exception $e) { return $e->getMessage(); @@ -130,7 +130,7 @@ function previewImage(e, image_id) { HEADER; foreach ($results as $image) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); // Don't show locked galleries in the block. if (!$gallery->isOldEnough() || $gallery->hasPasswd()) { @@ -187,9 +187,9 @@ HEADER; /* Get the gallery object and cache it. */ if (isset($this->_params['gallery']) && $this->_params['gallery'] != '__random') { - $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->_params['gallery']); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_params['gallery']); } else { - $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRandomGallery(); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRandomGallery(); } if (empty($this->_gallery)) { diff --git a/ansel/lib/Block/recently_added_geodata.php b/ansel/lib/Block/recently_added_geodata.php index d4d54c3de..be061cb18 100644 --- a/ansel/lib/Block/recently_added_geodata.php +++ b/ansel/lib/Block/recently_added_geodata.php @@ -53,14 +53,14 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block protected function _content() { try { - $images = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100)); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image['gallery_id']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image['gallery_id']); /* Don't show locked galleries in the block. */ if (!$gallery->isOldEnough() || $gallery->hasPasswd()) { diff --git a/ansel/lib/Faces/Base.php b/ansel/lib/Faces/Base.php index cb8499c90..2b931bbe1 100644 --- a/ansel/lib/Faces/Base.php +++ b/ansel/lib/Faces/Base.php @@ -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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->shares->getShareCriteria( + $share = substr($GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->shares->getShareCriteria( + $share = substr($GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image); - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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'))); } diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index ee2e7f838..a69587f3b 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -29,7 +29,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria { /* Pass on up the chain */ parent::__construct($attributes); - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->shares->initShareObject($this); + $GLOBALS['injector']->getInstance('Ansel_Storage')->shares->initShareObject($this); $this->_setModeHelper(isset($attributes['attribute_view_mode']) ? $attributes['attribute_view_mode'] : 'Normal'); } @@ -136,7 +136,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria } // Check for slug uniqueness - $slugGalleryId = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->slugExists($this->data['attribute_slug']); + $slugGalleryId = $GLOBALS['injector']->getInstance('Ansel_Storage')->slugExists($this->data['attribute_slug']); if ($slugGalleryId > 0 && $slugGalleryId <> $this->id) { throw InvalidArgumentException( sprintf(_("Could not save gallery, the slug, \"%s\", already exists."), @@ -256,7 +256,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria /* Check for a supported multi-page image */ if ($image->isMultiPage() === true) { $params['name'] = $image->getImagePageCount() . ' page image: ' . $image->filename; - $mGallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->createGallery($params, $this->getPermission(), $this->getId()); + $mGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->createGallery($params, $this->getPermission(), $this->getId()); $i = 1; foreach ($image as $page) { $page->caption = sprintf(_("Page %d"), $i++); @@ -550,7 +550,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria */ public function getRecentImages($limit = 10) { - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRecentImages(array($this->id), + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages(array($this->id), $limit); } @@ -563,7 +563,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria */ public function &getImage($id) { - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($id); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($id); } /** @@ -664,8 +664,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria /* Fall through to a key image of a sub gallery. */ try { $galleries = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('parent' => $this, 'all_levels' => false)); foreach ($galleries as $galleryId => $gallery) { @@ -863,7 +862,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria { /* Make sure we have a gallery object */ if (!is_null($parent) && !($parent instanceof Ansel_Gallery)) { - $parent = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($parent); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($parent); } /* Check this now since we don't know if we are updating the DB or not */ @@ -973,7 +972,8 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria { return $this->_modeHelper->getGalleryCrumbData(); } -/** + + /** * Serialize this object. * * @return string The serialized data. diff --git a/ansel/lib/Gallery/Decorator/Date.php b/ansel/lib/Gallery/Decorator/Date.php index 0f8218c92..23ce28d0f 100644 --- a/ansel/lib/Gallery/Decorator/Date.php +++ b/ansel/lib/Gallery/Decorator/Date.php @@ -112,8 +112,7 @@ class Ansel_Gallery_Decorator_Date */ public function getRecentImages($limit = 10) { - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage') - ->create() + return $GLOBALS['injector']->getInstance('Ansel_Storage') ->getRecentImages(array($this->_gallery->id), $limit); } @@ -126,7 +125,7 @@ class Ansel_Gallery_Decorator_Date */ public function getImage($id) { - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($id); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($id); } /** diff --git a/ansel/lib/GalleryMode/Date.php b/ansel/lib/GalleryMode/Date.php index 8998d7631..725d840c5 100644 --- a/ansel/lib/GalleryMode/Date.php +++ b/ansel/lib/GalleryMode/Date.php @@ -158,7 +158,7 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base static $children = array(); /* Ansel Storage */ - $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); $cache_key = md5($this->_gallery->id . serialize($this->_date) . $from . $to); if (!empty($children[$cache_key])) { @@ -418,7 +418,7 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base */ if ($this->_gallery->get('has_subgalleries')) { $gallery_ids = array(); - $images = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImages(array('ids' => $ids)); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImages(array('ids' => $ids)); foreach ($images as $image) { if (empty($gallery_ids[$image->gallery])) { $gallery_ids[$image->gallery] = 1; @@ -429,12 +429,12 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base } /* Bulk update the images to their new gallery_id */ - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->setImagesGallery($ids, $gallery->id); + $GLOBALS['injector']->getInstance('Ansel_Storage')->setImagesGallery($ids, $gallery->id); /* Update the gallery counts for each affected gallery */ if ($this->_gallery->get('has_subgalleries')) { foreach ($gallery_ids as $id => $count) { - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create() + $GLOBALS['injector']->getInstance('Ansel_Storage') ->getGallery($id) ->updateImageCount($count, false); } @@ -467,7 +467,7 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base { /* Make sure $image is an Ansel_Image; if not, try loading it. */ if (!($image instanceof Ansel_Image)) { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image); } /* Make sure the image is in this gallery. */ @@ -497,11 +497,10 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base } catch (VFS_Exception $e) {} /* Delete from storage */ - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create() - ->removeImage($image->id); + $GLOBALS['injector']->getInstance('Ansel_Storage')->removeImage($image->id); if (!$isStack) { - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create() + $GLOBALS['injector']->getInstance('Ansel_Storage') ->getGallery($image_gallery) ->updateImageCount(1, false); } @@ -611,8 +610,7 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base if (!is_array($this->_subGalleries)) { /* Get a list of all the subgalleries */ $subs = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('parent' => $this->_gallery)); $this->_subGalleries = array_keys($subs); } diff --git a/ansel/lib/GalleryMode/Normal.php b/ansel/lib/GalleryMode/Normal.php index af40a6d6c..a3236fb87 100644 --- a/ansel/lib/GalleryMode/Normal.php +++ b/ansel/lib/GalleryMode/Normal.php @@ -37,7 +37,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base $galleries = array(); $num_galleries = 0; if ($this->hasSubGalleries()) { - $storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); /* Get the number of images and galleries */ $numimages = $this->countImages(); $num_galleries = $storage->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, null, $this->_gallery, false); @@ -109,8 +109,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base return $this->_gallery->data['attribute_images']; } - $gCnt = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage') - ->create() + $gCnt = $GLOBALS['injector']->getInstance('Ansel_Storage') ->countGalleries($GLOBALS['registry']->getAuth(), $perm, null, $this->_gallery, false); @@ -134,8 +133,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base */ public function listImages($from = 0, $count = 0) { - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage') - ->create() + return $GLOBALS['injector']->getInstance('Ansel_Storage') ->listImages($this->_gallery->id, $from, $count); } @@ -166,7 +164,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base } } - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->setImagesGallery($ids, $gallery->id); + $GLOBALS['injector']->getInstance('Ansel_Storage')->setImagesGallery($ids, $gallery->id); $this->_gallery->updateImageCount(count($ids), false); $gallery->updateImageCount(count($ids), true); @@ -215,7 +213,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base } catch (VFS_Exception $e) {} /* Delete from storage */ - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->removeImage($image->id); + $GLOBALS['injector']->getInstance('Ansel_Storage')->removeImage($image->id); if (!$isStack) { $this->_gallery->updateImageCount(1, false); } @@ -262,8 +260,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base */ public function getImages($from = 0, $count = 0) { - $images = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage') - ->create() + $images = $GLOBALS['injector']->getInstance('Ansel_Storage') ->getImages(array('gallery_id' => $this->_gallery->id, 'count' => $count, 'from' => $from)); @@ -295,8 +292,7 @@ class Ansel_GalleryMode_Normal extends Ansel_GalleryMode_Base if ($subgalleries && $this->hasSubGalleries()) { $count = $this->countImages(false); $galleries = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('parent' => $this->_gallery)); foreach ($galleries as $galleryId => $gallery) { diff --git a/ansel/lib/Image.php b/ansel/lib/Image.php index 1492290a9..ae1433b83 100644 --- a/ansel/lib/Image.php +++ b/ansel/lib/Image.php @@ -505,11 +505,11 @@ class Ansel_Image Implements Iterator /* Existing image, just save and exit */ if ($this->id) { /* Save image details */ - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->saveImage($this); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->saveImage($this); } /* New image, need to save the image files */ - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->saveImage($this); + $GLOBALS['injector']->getInstance('Ansel_Storage')->saveImage($this); /* The EXIF functions require a stream, so we need to save before we read */ $this->_writeData(); @@ -538,7 +538,7 @@ class Ansel_Image Implements Iterator /* Save again if EXIF changed any values */ if (!empty($needUpdate)) { - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->saveImage($this); + $GLOBALS['injector']->getInstance('Ansel_Storage')->saveImage($this); } return $this->id; @@ -655,7 +655,7 @@ class Ansel_Image Implements Iterator /* Save attributes. */ foreach ($exif_fields as $name => $value) { - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->saveImageAttribute($this->id, $name, $value); + $GLOBALS['injector']->getInstance('Ansel_Storage')->saveImageAttribute($this->id, $name, $value); $this->_exif[$name] = Horde_Image_Exif::getHumanReadable($name, $value); } @@ -754,7 +754,7 @@ class Ansel_Image Implements Iterator if ($view == 'all' || $view == 'prettythumb') { $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel'); - $hashes = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getHashes(); + $hashes = $GLOBALS['injector']->getInstance('Ansel_Storage')->getHashes(); foreach ($hashes as $hash) { $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs') @@ -816,7 +816,7 @@ class Ansel_Image Implements Iterator { if ($view == 'full' && !$this->_dirty) { // Check full photo permissions - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->gallery); if ($gallery instanceof PEAR_Error) { throw new Ansel_Exception($gallery); } @@ -1093,7 +1093,7 @@ class Ansel_Image Implements Iterator if (count($this->_tags)) { return $this->_tags; } - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->gallery); if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { return $GLOBALS['injector']->getInstance('Ansel_Tagger')->getTags($this->id, 'image'); } else { @@ -1111,7 +1111,7 @@ class Ansel_Image Implements Iterator */ public function setTags($tags) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(abs($this->gallery)); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($this->gallery)); if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { // Clear the local cache. $this->_tags = array(); @@ -1174,7 +1174,7 @@ class Ansel_Image Implements Iterator } if (is_null($style)) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(abs($this->gallery)); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($this->gallery)); $style = $gallery->getStyle(); } $view = md5($style->thumbstyle . '.' . $style->background); @@ -1192,7 +1192,7 @@ class Ansel_Image Implements Iterator */ public function getAttributes($format = false) { - $attributes = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImageAttributes($this->id); + $attributes = $GLOBALS['injector']->getInstance('Ansel_Storage')->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(); diff --git a/ansel/lib/ImageGenerator.php b/ansel/lib/ImageGenerator.php index a2bf8ed82..a7f2c7e7a 100644 --- a/ansel/lib/ImageGenerator.php +++ b/ansel/lib/ImageGenerator.php @@ -144,8 +144,7 @@ class Ansel_ImageGenerator protected function _getGalleryWithImages($parent) { $galleries = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('parent' => $parent, 'all_levels' => false)); foreach ($galleries as $gallery) { diff --git a/ansel/lib/ImageGenerator/PolaroidThumb.php b/ansel/lib/ImageGenerator/PolaroidThumb.php index 2062a646b..e2ce6b621 100644 --- a/ansel/lib/ImageGenerator/PolaroidThumb.php +++ b/ansel/lib/ImageGenerator/PolaroidThumb.php @@ -29,7 +29,7 @@ class Ansel_ImageGenerator_PolaroidThumb extends Ansel_ImageGenerator (which will have a negative gallery_id). */ if ($this->_image->gallery > 0) { if (is_null($this->_style)) { - $gal = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->_image->gallery); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_image->gallery); $styleDef = $gal->getStyle(); } else { $styleDef = $this->_style; diff --git a/ansel/lib/ImageGenerator/RoundedThumb.php b/ansel/lib/ImageGenerator/RoundedThumb.php index e7f7d1e6e..3e6cb6545 100644 --- a/ansel/lib/ImageGenerator/RoundedThumb.php +++ b/ansel/lib/ImageGenerator/RoundedThumb.php @@ -29,7 +29,7 @@ class Ansel_ImageGenerator_RoundedThumb extends Ansel_ImageGenerator * (which will have a negative gallery_id). */ if ($this->_image->gallery > 0) { if (is_null($this->_style)) { - $gal = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->_image->gallery); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_image->gallery); $styleDef = $gal->getStyle(); } else { $styleDef = $this->_style; diff --git a/ansel/lib/ImageGenerator/ShadowThumb.php b/ansel/lib/ImageGenerator/ShadowThumb.php index 95aed414b..1db3377e9 100644 --- a/ansel/lib/ImageGenerator/ShadowThumb.php +++ b/ansel/lib/ImageGenerator/ShadowThumb.php @@ -29,7 +29,7 @@ class Ansel_ImageGenerator_ShadowThumb extends Ansel_ImageGenerator * (which will have a negative gallery_id). */ if ($this->_image->gallery > 0) { if (is_null($this->_style)) { - $gal = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->_image->gallery); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_image->gallery); $styleDef = $gal->getStyle(); } else { $styleDef = $this->_style; diff --git a/ansel/lib/Injector/Factory/Storage.php b/ansel/lib/Injector/Factory/Storage.php index 9eff18b58..f964e93df 100644 --- a/ansel/lib/Injector/Factory/Storage.php +++ b/ansel/lib/Injector/Factory/Storage.php @@ -1,6 +1,8 @@ * @category Horde @@ -10,7 +12,8 @@ class Ansel_Injector_Factory_Storage { /** - * Depends on the Ansel_Scope value being available to the injector. + * Array of already instantiated instances + * * @var array */ private $_instances = array(); @@ -21,15 +24,19 @@ class Ansel_Injector_Factory_Storage */ private $_injector; + /** + * Constructor + * + * @param Horde_Injector $injector + */ public function __construct(Horde_Injector $injector) { $this->_injector = $injector; } /** - * Return an Ansel_Storage instance scoped for the current Ansel scope - * - * @param string $scope The application scope + * Return an Ansel_Storage instance scoped for the current Ansel scope. + * Scope is determined by the current value of Ansel_Config::scope * * @return Ansel_Storage */ @@ -42,4 +49,5 @@ class Ansel_Injector_Factory_Storage return $this->_instances[$scope]; } + } diff --git a/ansel/lib/Search/Tag.php b/ansel/lib/Search/Tag.php index 5868141dc..66c4b4635 100644 --- a/ansel/lib/Search/Tag.php +++ b/ansel/lib/Search/Tag.php @@ -113,7 +113,7 @@ class Ansel_Search_Tag /* Instantiate the Gallery objects */ $galleries = array(); foreach ($gresults as $gallery) { - $galleries[] = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery); + $galleries[] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery); } /* Do we need to get images? */ @@ -121,7 +121,7 @@ class Ansel_Search_Tag $count = $perpage - count($galleries); if ($count > 0) { $iresults = array_slice($this->_results['images'], $istart, $count); - $images = count($iresults) ? array_values($GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImages(array('ids' => $iresults))) : array(); + $images = count($iresults) ? array_values($GLOBALS['injector']->getInstance('Ansel_Storage')->getImages(array('ids' => $iresults))) : array(); if (($conf['comments']['allow'] == 'all' || ($conf['comments']['allow'] == 'authenticated' && $GLOBALS['registry']->getAuth())) && $registry->hasMethod('forums/numMessagesBatch')) { diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index 5a49f7438..20e57097c 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -874,7 +874,7 @@ class Ansel_Storage $image = $this->getImage($id); $gallery_id = abs($image->gallery); if (empty($galleries[$gallery_id])) { - $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } // Any authentication that needs to take place for any of the diff --git a/ansel/lib/Tagger.php b/ansel/lib/Tagger.php index ae7242c45..b9b87930b 100644 --- a/ansel/lib/Tagger.php +++ b/ansel/lib/Tagger.php @@ -370,7 +370,7 @@ class Ansel_Tagger { $args = array('typeId' => 'image', 'limit' => 10); if ($ownerOnly) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); $args['userId'] = $gallery->get('owner'); } @@ -385,7 +385,7 @@ class Ansel_Tagger } try { - $images = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImages(array('ids' => array_keys($ids))); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImages(array('ids' => array_keys($ids))); } catch (Horde_Exception_NotFound $e) { $images = array(); } diff --git a/ansel/lib/Tile/Image.php b/ansel/lib/Tile/Image.php index 93d05d5a2..ad0241572 100644 --- a/ansel/lib/Tile/Image.php +++ b/ansel/lib/Tile/Image.php @@ -27,7 +27,7 @@ class Ansel_Tile_Image { global $conf, $registry; - $parent = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery); if (is_null($style)) { $style = $parent->getStyle(); } diff --git a/ansel/lib/View/Base.php b/ansel/lib/View/Base.php index 9aac1ee6e..5625264c7 100644 --- a/ansel/lib/View/Base.php +++ b/ansel/lib/View/Base.php @@ -141,9 +141,9 @@ abstract class Ansel_View_Base // If we have a slug, use it. try { if (!empty($slug)) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGalleryBySlug($slug); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleryBySlug($slug); } else { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); } } catch (Ansel_Exception $e) { throw new Horde_Exception_NotFound($e->getmessage()); diff --git a/ansel/lib/View/EmbeddedRenderer/GalleryLink.php b/ansel/lib/View/EmbeddedRenderer/GalleryLink.php index 4694b326c..c2e5b5ccc 100644 --- a/ansel/lib/View/EmbeddedRenderer/GalleryLink.php +++ b/ansel/lib/View/EmbeddedRenderer/GalleryLink.php @@ -81,7 +81,7 @@ class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Gallery $images[] = $gallery->getKeyImage($gallery_style); } } - $json = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImageJson($images, null, true, $thumbsize, true); + $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, null, true, $thumbsize, true); $GLOBALS['injector']->getInstance('Horde_Themes_Css')->addThemeStylesheet('jsembed.css'); Horde::startBuffer(); diff --git a/ansel/lib/View/EmbeddedRenderer/Mini.php b/ansel/lib/View/EmbeddedRenderer/Mini.php index 402a40e03..4f9b1f777 100644 --- a/ansel/lib/View/EmbeddedRenderer/Mini.php +++ b/ansel/lib/View/EmbeddedRenderer/Mini.php @@ -76,8 +76,8 @@ class Ansel_View_EmbeddedRenderer_Mini extends Ansel_View_Gallery 'count' => $count, 'view_links' => true)); } else { - $json = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImageJson($images, null, true, $thumbsize, true); - $json_full = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImageJson($images, null, true, 'screen', true); + $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, null, true, $thumbsize, true); + $json_full = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, null, true, 'screen', true); } $horde_css = $GLOBALS['injector']->getInstance('Horde_Themes_Css'); diff --git a/ansel/lib/View/GalleryProperties.php b/ansel/lib/View/GalleryProperties.php index 90e327f13..a00d57fe3 100644 --- a/ansel/lib/View/GalleryProperties.php +++ b/ansel/lib/View/GalleryProperties.php @@ -149,7 +149,7 @@ class Ansel_View_GalleryProperties // permissions to add to it. $parentId = $this->_params['gallery']; try { - $parent = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($parentId); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($parentId); } catch (Ansel_Exception $e) { $GLOBALS['notification']->push($e->getMessage(), 'horde.error'); Horde::url('view.php?view=List', true)->redirect(); @@ -182,7 +182,7 @@ class Ansel_View_GalleryProperties } try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($this->_params['gallery']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($this->_params['gallery']); $parent = $gallery->getParent(); $this->_properties = array( 'name' => $gallery->get('name'), @@ -255,10 +255,10 @@ class Ansel_View_GalleryProperties $gallery_parent = null; } if ($galleryId && - ($exists = ($GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->galleryExists($galleryId)) === true)) { + ($exists = ($GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($galleryId)) === true)) { // Modifying an existing gallery. - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $GLOBALS['notification']->push(sprintf(_("Access denied saving gallery \"%s\"."), $gallery->get('name')), 'horde.error'); } else { @@ -287,7 +287,7 @@ class Ansel_View_GalleryProperties } if ($gallery_parent != $old_parent_id) { if (!is_null($gallery_parent)) { - $new_parent = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_parent); + $new_parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_parent); } else { $new_parent = null; } @@ -310,7 +310,7 @@ class Ansel_View_GalleryProperties // Is this a new subgallery? if ($gallery_parent) { try { - $parent = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_parent); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_parent); } catch (Ansel_Exception $e) { $GLOBALS['notification']->push($e->getMessage(), 'horde.error'); Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); @@ -340,7 +340,7 @@ class Ansel_View_GalleryProperties $parent = (!empty($gallery_parent)) ? $gallery_parent : null; try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->createGallery( + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->createGallery( array('name' => $gallery_name, 'desc' => $gallery_desc, 'tags' => explode(',', $gallery_tags), @@ -369,7 +369,7 @@ class Ansel_View_GalleryProperties // Make sure that the style hash is recorded, ignoring non-styled thumbs if ($style->thumbstyle != 'Thumb') { - $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->ensureHash($gallery->getViewHash('prettythumb')); + $GLOBALS['injector']->getInstance('Ansel_Storage')->ensureHash($gallery->getViewHash('prettythumb')); } // Clear the OtherGalleries widget cache diff --git a/ansel/lib/View/GalleryRenderer/Gallery.php b/ansel/lib/View/GalleryRenderer/Gallery.php index c7b73c4f7..5736e0280 100644 --- a/ansel/lib/View/GalleryRenderer/Gallery.php +++ b/ansel/lib/View/GalleryRenderer/Gallery.php @@ -49,8 +49,8 @@ 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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->countGalleries(Horde_Perms::EDIT)); - $option_copy = ($option_edit && $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->countGalleries(Horde_Perms::EDIT)); + $option_move = ($option_delete && $GLOBALS['injector']->getInstance('Ansel_Storage')->countGalleries(Horde_Perms::EDIT)); + $option_copy = ($option_edit && $GLOBALS['injector']->getInstance('Ansel_Storage')->countGalleries(Horde_Perms::EDIT)); /* See if we requested a show_actions change */ if (Horde_Util::getFormData('actionID', '') == 'show_actions') { diff --git a/ansel/lib/View/GalleryRenderer/GalleryLightbox.php b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php index 6015f5f99..a298e1d52 100644 --- a/ansel/lib/View/GalleryRenderer/GalleryLightbox.php +++ b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php @@ -73,8 +73,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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->countGalleries(Horde_Perms::EDIT)); - $option_copy = ($option_edit && $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->countGalleries(Horde_Perms::EDIT)); + $option_move = ($option_delete && $GLOBALS['injector']->getInstance('Ansel_Storage')->countGalleries(Horde_Perms::EDIT)); + $option_copy = ($option_edit && $GLOBALS['injector']->getInstance('Ansel_Storage')->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')); diff --git a/ansel/lib/View/Image.php b/ansel/lib/View/Image.php index 804351329..94e610dd5 100644 --- a/ansel/lib/View/Image.php +++ b/ansel/lib/View/Image.php @@ -32,7 +32,7 @@ class Ansel_View_Image extends Ansel_View_Base parent::__construct($params); /* Get the Ansel_Image */ - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($params['image_id']); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($params['image_id']); /* Get the Ansel_Gallery */ $this->gallery = $this->_getGallery(); diff --git a/ansel/lib/View/List.php b/ansel/lib/View/List.php index b31c5cab1..ca2e46599 100644 --- a/ansel/lib/View/List.php +++ b/ansel/lib/View/List.php @@ -52,7 +52,7 @@ class Ansel_View_List extends Ansel_View_Base $notification = $GLOBALS['injector']->getInstance('Horde_Notification'); /* Ansel_Storage */ - $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); // We'll need this in the template. $this->_sortBy = !empty($this->_params['sort']) ? $this->_params['sort'] : 'name'; diff --git a/ansel/lib/View/Results.php b/ansel/lib/View/Results.php index d50c8fb41..bb682244c 100644 --- a/ansel/lib/View/Results.php +++ b/ansel/lib/View/Results.php @@ -55,7 +55,7 @@ class Ansel_View_Results extends Ansel_View_Base global $prefs, $conf; $notification = $GLOBALS['injector']->getInstance('Horde_Notification'); - $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); $this->_owner = Horde_Util::getFormData('owner', ''); //@TODO: Inject the search object when we have more then just a tag search @@ -226,7 +226,7 @@ class Ansel_View_Results extends Ansel_View_Base global $conf, $prefs; /* Ansel Storage*/ - $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); // Get the slice of galleries/images to view on this page. $results = $this->_search->getSlice($this->_page, $this->_perPage); diff --git a/ansel/lib/View/Upload.php b/ansel/lib/View/Upload.php index ece2e0cb6..4eaad2299 100644 --- a/ansel/lib/View/Upload.php +++ b/ansel/lib/View/Upload.php @@ -166,7 +166,7 @@ EOT; $cnt = count($image_ids); for ($i = 0; $i < $conf['image']['autogen'] && $cnt > $i; $i++) { $image_id = $image_ids[$i]; - $image = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); $image->createView('screen'); $image->createView('thumb'); $image->createView('mini'); diff --git a/ansel/lib/Widget/Geotag.php b/ansel/lib/Widget/Geotag.php index cb5c3e494..26d973475 100644 --- a/ansel/lib/Widget/Geotag.php +++ b/ansel/lib/Widget/Geotag.php @@ -69,7 +69,7 @@ class Ansel_Widget_Geotag extends Ansel_Widget_Base */ public function html() { - $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); $geodata = $ansel_storage->getImagesGeodata($this->_params['images']); $url = Horde::url('map_edit.php', true); $rtext = _("Relocate this image"); @@ -260,7 +260,7 @@ EOT; */ protected function _getGalleryImagesWithGeodata() { - return $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImagesGeodata(array(), $this->_view->gallery->id); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getImagesGeodata(array(), $this->_view->gallery->id); } /** diff --git a/ansel/lib/Widget/OtherGalleries.php b/ansel/lib/Widget/OtherGalleries.php index 292273330..c99d203cc 100644 --- a/ansel/lib/Widget/OtherGalleries.php +++ b/ansel/lib/Widget/OtherGalleries.php @@ -67,8 +67,7 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base $tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('otherAnselGalleries_' . md5($owner), 'Javascript', array('class' => 'anselWidgets')); try { - $galleries = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage') - ->create() + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage') ->listGalleries(array('attributes' => $owner)); } catch (Ansel_Exception $e) { Horde::logMessage($e, 'ERR'); diff --git a/ansel/lib/Widget/SimilarPhotos.php b/ansel/lib/Widget/SimilarPhotos.php index bfcc15a01..2c06e73d4 100755 --- a/ansel/lib/Widget/SimilarPhotos.php +++ b/ansel/lib/Widget/SimilarPhotos.php @@ -52,7 +52,7 @@ class Ansel_Widget_SimilarPhotos extends Ansel_Widget_Base */ public function _getRelatedImages() { - $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create(); + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); $html = ''; $args = array('typeId' => 'image', @@ -63,7 +63,7 @@ class Ansel_Widget_SimilarPhotos extends Ansel_Widget_Base $i = 0; foreach ($results as $result) { $img = $result['image']; - $rGal = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($img->gallery); + $rGal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($img->gallery); if ($rGal->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) $html .= Ansel::getUrlFor( 'view', diff --git a/ansel/map_edit.php b/ansel/map_edit.php index 6ad31de3f..eb0c172ee 100644 --- a/ansel/map_edit.php +++ b/ansel/map_edit.php @@ -22,8 +22,8 @@ $image_id = Horde_Util::getFormData('image'); if (empty($image_id)) { throw new Ansel_Exception(_("An error has occured retrieving the image. Details have been logged.")); } -$image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id); -$gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); +$imgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); if (count($imgs) > 0) { $other_images = '
' . _("Click on a thumbnail to locate at the same point.") . '
'; foreach ($imgs as $id => $data) { diff --git a/ansel/perms.php b/ansel/perms.php index a38bf9385..1e8662daf 100644 --- a/ansel/perms.php +++ b/ansel/perms.php @@ -27,13 +27,13 @@ $actionID = Horde_Util::getFormData('actionID', 'edit'); switch ($actionID) { case 'edit': try { - $share = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(Horde_Util::getFormData('cid')); + $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(Horde_Util::getFormData('cid')); $form = 'edit.inc'; $perm = $share->getPermission(); } catch (Horde_Exception_NotFound $e) { if (($share_name = Horde_Util::getFormData('share')) !== null) { try { - $share = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->shares->getShare($share_name); + $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(Horde_Util::getFormData('cid')); + $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(Horde_Util::getFormData('cid')); } catch (Horde_Share_Exception $e) { $notification->push(_("Attempt to edit a non-existent share."), 'horde.error'); } @@ -252,8 +252,7 @@ if (empty($share)) { $title = _("Edit Permissions"); } else { $children = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('perm' => Horde_Perms::READ, 'parent' => $share)); $title = sprintf(_("Edit Permissions for %s"), $share->get('name')); diff --git a/ansel/preview.php b/ansel/preview.php index 5e5282514..4b9e41cae 100644 --- a/ansel/preview.php +++ b/ansel/preview.php @@ -13,8 +13,8 @@ Horde_Registry::appInit('ansel'); $imageId = Horde_Util::getFormData('image'); try { - $image = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($imageId); - $gal = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery(abs($image->gallery)); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($imageId); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($image->gallery)); $img = Ansel::getImageUrl($imageId, 'thumb', false); } catch (Ansel_Exception $e) { Horde::logMessage($e->getMessage(), 'ERR'); diff --git a/ansel/protect.php b/ansel/protect.php index eb36f609f..d6854c001 100644 --- a/ansel/protect.php +++ b/ansel/protect.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('ansel'); $vars = Horde_Variables::getDefaultVariables(); try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($vars->get('gallery')); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($vars->get('gallery')); } catch (Ansel_Exception $e) { $notification->push($e->getMessage()); Horde::url('list.php')->redirect(); diff --git a/ansel/report.php b/ansel/report.php index 1e8d5adcb..31ff4bc67 100644 --- a/ansel/report.php +++ b/ansel/report.php @@ -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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage()); Horde::url('view.php?view=List', true)->redirect(); diff --git a/ansel/rss.php b/ansel/rss.php index 970582e8b..2fb70a9f7 100644 --- a/ansel/rss.php +++ b/ansel/rss.php @@ -41,7 +41,7 @@ if (empty($rss)) { switch ($stream_type) { case 'all': try { - $images = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRecentImages(); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages(); } catch (Ansel_Exception $e) { $images = array(); } @@ -73,23 +73,22 @@ if (empty($rss)) { // Retrieve latest from specified gallery // Try a slug first. if ($slug) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGalleryBySlug($slug); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleryBySlug($slug); } elseif (is_numeric($id)) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($id); } if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW) && !$gallery->hasPasswd() && $gallery->isOldEnough()) { if (!$gallery->countImages() && $gallery->hasSubGalleries()) { $subgalleries = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('parent' => $gallery)); $subs = array(); foreach ($subgalleries as $subgallery) { $subs[] = $subgallery->id; } - $images = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getRecentImages($subs); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages($subs); } else { $images = $gallery->getRecentImages(); $owner = $gallery->getIdentity(); @@ -104,7 +103,7 @@ if (empty($rss)) { array('view' => 'Gallery', 'gallery' => $id), true); - $img = &$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default'))); + $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default'))); $params = array('last_modified' => $gallery->get('last_modified'), 'name' => sprintf(_("%s on %s"), $gallery->get('name'), @@ -125,8 +124,7 @@ if (empty($rss)) { $galleries = array(); try { $shares = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('attributes' => $id)); foreach ($shares as $gallery) { if ($gallery->isOldEnough() && !$gallery->hasPasswd()) { @@ -140,8 +138,7 @@ if (empty($rss)) { if (isset($galleries) && count($galleries)) { try { $images = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->getRecentImages($galleries); } catch (Ansel_Exception $e) { Horde::logMessage($e->getMessage(), 'ERR'); @@ -180,7 +177,7 @@ if (empty($rss)) { $images = $GLOBALS['injector']->getInstance('Ansel_Tagger')->search(array($id), $filter); try { - $images = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImages(array('ids' => $images['images'])); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImages(array('ids' => $images['images'])); } catch (Ansel_Exception $e) { Horde::logMessage($e->getMessage(), 'ERR'); $images = array(); @@ -214,7 +211,7 @@ if (empty($rss)) { $gallery_id = $images[$i]->gallery; if (empty($galleries[$gallery_id])) { try { - $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); } catch (Ansel_Exception $e) {} } if (!isset($galleries[$gallery_id]['perm'])) { diff --git a/ansel/scripts/all_images_exif_to_tags.php b/ansel/scripts/all_images_exif_to_tags.php index b6421b692..0a700c5f2 100755 --- a/ansel/scripts/all_images_exif_to_tags.php +++ b/ansel/scripts/all_images_exif_to_tags.php @@ -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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($image_id['image_id']); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id['image_id']); $results = $image->exifToTags($exif_fields); $cli->message(sprintf(_("Extracted exif fields from %s"), $image->filename), 'cli.success'); } diff --git a/ansel/scripts/ansel.php b/ansel/scripts/ansel.php index 78b86369c..0ff124503 100755 --- a/ansel/scripts/ansel.php +++ b/ansel/scripts/ansel.php @@ -102,12 +102,12 @@ if (!empty($username) && !empty($password)) { // Choose the gallery to add to (or use the created one). if (!empty($galleryId)) { - if (!$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->galleryExists($galleryId)) { + if (!$GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($galleryId)) { $error = sprintf(_("Invalid gallery \"%s\" specified."), $galleryId); Horde::logMessage($error, 'WARN'); $cli->fatal($error); } else { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->createGallery($attributes, null, $parent); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getImage($id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($id); $cli->writeln(str_pad($image->filename, 30) . $image->getVFSPath() . '/' . $id); } } else { - $galleries = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->listGalleries(); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(); $cli->message(_("Listing Gallery/Name"), 'cli.success'); $cli->writeln(); foreach ($galleries as $id => $gallery) { diff --git a/ansel/scripts/recursive_import.php b/ansel/scripts/recursive_import.php index db10f1eaa..5a35c86fe 100755 --- a/ansel/scripts/recursive_import.php +++ b/ansel/scripts/recursive_import.php @@ -87,7 +87,7 @@ if (!empty($order) && $order != 'date' && $order != 'name' && $order != 'random' $gallery_id = processDirectory($dir); if (!$keepEmpties) { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id); emptyGalleryCheck($gallery); } exit; @@ -101,22 +101,21 @@ function emptyGalleryCheck($gallery) { if ($gallery->hasSubGalleries()) { $children = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('parent' => $gallery)); foreach ($children as $child) { // First check all children to see if they are empty... emptyGalleryCheck($child); if (!$child->countImages() && !$child->hasSubGalleries()) { - $result = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->removeGallery($child); + $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery->getId()); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery->getId()); // Now that any empty children are removed, see if we are empty if (!$gallery->countImages() && !$gallery->hasSubGalleries()) { - $result = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->removeGallery($gallery); + $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->removeGallery($gallery); $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $gallery->get('name')), 'cli.success'); } } @@ -182,7 +181,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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->createGallery(array('name' => $name), null, $parent); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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. diff --git a/ansel/scripts/remote_import.php b/ansel/scripts/remote_import.php index 61e5bd3a5..90062ce7d 100755 --- a/ansel/scripts/remote_import.php +++ b/ansel/scripts/remote_import.php @@ -115,22 +115,21 @@ function emptyGalleryCheck($gallery) { if ($gallery->hasSubGalleries()) { $children = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('parent' => $gallery)); foreach ($children as $child) { // First check all children to see if they are empty... emptyGalleryCheck($child); if (!$child->countImages() && !$child->hasSubGalleries()) { - $result = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->removeGallery($child); + $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->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['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($gallery->getId()); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery->getId()); // Now that any empty children are removed, see if we are empty if (!$gallery->countImages() && !$gallery->hasSubGalleries()) { - $result = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->removeGallery($gallery); + $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->removeGallery($gallery); $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $gallery->get('name')), 'cli.success'); } } diff --git a/ansel/templates/gallery/delete_confirmation.inc b/ansel/templates/gallery/delete_confirmation.inc index 48c0b1aab..e6742d0f7 100644 --- a/ansel/templates/gallery/delete_confirmation.inc +++ b/ansel/templates/gallery/delete_confirmation.inc @@ -1,5 +1,5 @@

- getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + getInstance('Ansel_Storage')->getGallery($galleryId); printf($actionID == 'delete' ? _("Really delete %s and all of its subgalleries?") : _("Really empty %s?"), htmlspecialchars($gallery->get('name'))) ?>

diff --git a/ansel/templates/group/owner.inc b/ansel/templates/group/owner.inc index 628bee0b1..c9e36a935 100644 --- a/ansel/templates/group/owner.inc +++ b/ansel/templates/group/owner.inc @@ -26,18 +26,16 @@ $link = Ansel::getUrlFor('view', array('groupby' => $groupby, 'owner' => $group, 'view' => 'List'))->link(); -$num_galleries = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage') - ->create() +$num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage') ->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, $group, null, false); if ($num_galleries < 5) { $mini_galleries = $GLOBALS['injector']-> - getInstance('Ansel_Injector_Factory_Storage')-> + getInstance('Ansel_Storage')-> create()->listGalleries(array('attributes' => $group, 'all_levels' => false)); } else { $mini_galleries = $GLOBALS['injector'] - ->getInstance('Ansel_Injector_Factory_Storage') - ->create() + ->getInstance('Ansel_Storage') ->listGalleries(array('attributes' => $group, 'from' => rand(0, $num_galleries - 4), 'count' => 4)); diff --git a/ansel/xppublish.php b/ansel/xppublish.php index effe1c8bb..a190ebf39 100644 --- a/ansel/xppublish.php +++ b/ansel/xppublish.php @@ -79,11 +79,11 @@ if ($cmd == 'list') { // Check if a gallery was selected from the list. if ($cmd == 'select') { - if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->galleryExists($galleryId)) { + if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($galleryId)) { $error = _("Invalid gallery specified.") . "
\n"; } else { try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->createGallery( + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 || !$GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->galleryExists($galleryId)) { + if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($galleryId)) { $error = _("Invalid gallery specified.") . "
\n"; } else { try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->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 = $GLOBALS['injector']->getInstance('Ansel_Injector_Factory_Storage')->create()->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId); try { $image_id = $gallery->addImage($image); $error = false; -- 2.11.0