From: Michael J. Rubinsky Date: Sun, 13 Jun 2010 22:18:33 +0000 (-0400) Subject: Use injector for Ansel_Storage. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=04ce072847321ac9a2eed7f88ebdd23d96969e62;p=horde.git Use injector for Ansel_Storage. Introduces a new Ansel_Config class for setting ansel config values that might change during runtime, such as $scope. The Ansel_Storage factory uses Ansel_Config from the injector to return the proper storage scope. So, to use a scope other than the default 'ansel' scope, you need to set it as: $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', 'foo'); --- diff --git a/ansel/disclamer.php b/ansel/disclamer.php index 63d3c8cb5..09989e941 100644 --- a/ansel/disclamer.php +++ b/ansel/disclamer.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('ansel'); $vars = Horde_Variables::getDefaultVariables(); try { - $gallery = $ansel_storage->getGallery($vars->get('gallery')); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($vars->get('gallery')); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage()); header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); diff --git a/ansel/edit_dates.php b/ansel/edit_dates.php index f2977d65e..2eae3952a 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 = $ansel_storage->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("You are not allowed to edit these photos."), 'horde.error'); echo Horde::wrapInlineScript(array( @@ -47,10 +47,10 @@ if ($actionID == 'edit_dates') { $count = 0; foreach (array_keys($images) as $image_id) { try { - $image = $ansel_storage->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); if (empty($gallery_id)) { // Images might be from different galleries - $gallery = $ansel_storage->getGallery($image->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { continue; } @@ -82,7 +82,7 @@ $html = ''; foreach ($keys as $key) { $html .= '[thumbnail]'; } -$image = $ansel_storage->getImage(array_pop($keys)); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(array_pop($keys)); /* Display the form */ $vars->set('image', $images); $vars->set('gallery', $gallery_id); diff --git a/ansel/faces/claim.php b/ansel/faces/claim.php index f32f16cdd..c74cdacc4 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 = $ansel_storage->getGallery($face['gallery_id']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($face['gallery_id']); $face_link = Horde::applicationUrl('faces/custom.php', true)->add( array('name' => $vars->get('person'), diff --git a/ansel/faces/custom.php b/ansel/faces/custom.php index 9b600d9af..e6c65d9b6 100644 --- a/ansel/faces/custom.php +++ b/ansel/faces/custom.php @@ -24,14 +24,14 @@ if (!empty($url)) { $form_post = Horde::applicationUrl('faces/savecustom.php')->add($urlparams); try { - $image = $ansel_storage->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($image); header('Location: ' . Horde::applicationUrl('list.php')); exit; } -$gallery = $ansel_storage->getGallery($image->gallery); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied editing the photo.")); header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $image->gallery))); diff --git a/ansel/faces/gallery.php b/ansel/faces/gallery.php index 7a7516927..b30ddb821 100644 --- a/ansel/faces/gallery.php +++ b/ansel/faces/gallery.php @@ -22,7 +22,7 @@ if (empty($gallery_id)) { exit; } try { - $gallery = $ansel_storage->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $gallery_id))); diff --git a/ansel/faces/image.php b/ansel/faces/image.php index 3ba044eef..ff88ee2df 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 = $ansel_storage->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); try { $image->createView('screen'); $result = $faces->getFromPicture($image_id, $autocreate); diff --git a/ansel/faces/name.php b/ansel/faces/name.php index 0af49df11..32af2a785 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 = &$ansel_storage->getImage($image_id); -$gallery = &$ansel_storage->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); +$gallery = $$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()>getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception('Access denied editing the photo.'); } diff --git a/ansel/faces/report.php b/ansel/faces/report.php index bd1456c27..59a112240 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 = $ansel_storage->getGallery($face['gallery_id']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($face['gallery_id']); $face_link = Horde::applicationUrl('faces/face.php', true)->add( array('name' => $vars->get('person'), diff --git a/ansel/gallery.php b/ansel/gallery.php index eb6f46367..33cc2280a 100644 --- a/ansel/gallery.php +++ b/ansel/gallery.php @@ -45,7 +45,7 @@ case 'addchild': // permissions to add to it. $parentId = Horde_Util::getFormData('gallery'); try { - $parent = $ansel_storage->getGallery($parentId); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($parentId); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); @@ -79,7 +79,7 @@ case 'addchild': case 'downloadzip': $galleryId = Horde_Util::getFormData('gallery'); - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); if (!$registry->getAuth() || !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { @@ -95,7 +95,7 @@ case 'modify': $galleryId = Horde_Util::getFormData('gallery'); try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); // Set up the gallery attributes. $gallery_name = $gallery->get('name'); $gallery_desc = $gallery->get('desc'); @@ -155,10 +155,10 @@ case 'save': $gallery_parent = null; } if ($galleryId && - ($exists = $ansel_storage->galleryExists($galleryId)) === true) { + ($exists = ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) === true)) { // Modifying an existing gallery. - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied saving gallery \"%s\"."), $gallery->get('name')), 'horde.error'); } else { @@ -189,7 +189,7 @@ case 'save': } if ($gallery_parent != $old_parent_id) { if (!is_null($gallery_parent)) { - $new_parent = $ansel_storage->getGallery($gallery_parent); + $new_parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent); } else { $new_parent = null; } @@ -212,7 +212,7 @@ case 'save': // Is this a new subgallery? if ($gallery_parent) { try { - $parent = $ansel_storage->getGallery($gallery_parent); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))); @@ -243,7 +243,7 @@ case 'save': $parent = (!empty($gallery_parent)) ? $gallery_parent : null; try { - $gallery = $ansel_storage->createGallery( + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery( array('name' => $gallery_name, 'desc' => $gallery_desc, 'category' => $gallery_category, @@ -293,7 +293,7 @@ case 'empty': $galleryId = Horde_Util::getFormData('gallery'); if ($galleryId) { try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); require ANSEL_TEMPLATES . '/common-header.inc'; require ANSEL_TEMPLATES . '/menu.inc'; require ANSEL_TEMPLATES . '/gallery/delete_confirmation.inc'; @@ -312,7 +312,7 @@ case 'generateDefault': // Re-generate the default pretty gallery image. $galleryId = Horde_Util::getFormData('gallery'); try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); $gallery->clearStacks(); $notification->push(_("The gallery's default photo has successfully been reset."), 'horde.success'); header('Location: ' . Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)); @@ -327,7 +327,7 @@ case 'generateThumbs': // Re-generate all of this gallery's prettythumbs. $galleryId = Horde_Util::getFormData('gallery'); try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage(), 'horde.error'); header('Location: ' . Horde::applicationUrl('index.php', true)); @@ -342,7 +342,7 @@ case 'deleteCache': // Delete all cached image views. $galleryId = Horde_Util::getFormData('gallery'); try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage(), 'horde.error'); header('Location: ' . Horde::applicationUrl('index.php', true)); diff --git a/ansel/gallery/captions.php b/ansel/gallery/captions.php index ee17799e6..c4db7cd95 100644 --- a/ansel/gallery/captions.php +++ b/ansel/gallery/captions.php @@ -18,7 +18,7 @@ if (!$galleryId) { exit; } try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Error accessing %s: %s"), $galleryId, $e->getMessage()), 'horde.error'); header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); diff --git a/ansel/gallery/delete.php b/ansel/gallery/delete.php index 7ccedd33c..46a16c6a2 100644 --- a/ansel/gallery/delete.php +++ b/ansel/gallery/delete.php @@ -17,7 +17,7 @@ $galleryId = Horde_Util::getPost('gallery'); if ($galleryId) { try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); // Return to the default view. @@ -31,7 +31,7 @@ if ($galleryId) { $gallery->get('name')), 'horde.error'); } else { try { - $ansel_storage->removeGallery($gallery); + $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery); $notification->push(sprintf( _("Successfully deleted %s."), $gallery->get('name')), 'horde.success'); @@ -58,7 +58,7 @@ if ($galleryId) { $gallery->get('name')), 'horde.error'); } else { - $ansel_storage->emptyGallery($gallery); + $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->emptyGallery($gallery); $notification->push(sprintf(_("Successfully emptied \"%s\""), $gallery->get('name'))); } header('Location: ' diff --git a/ansel/gallery/sort.php b/ansel/gallery/sort.php index 17c96f8be..d9ecb7d6f 100644 --- a/ansel/gallery/sort.php +++ b/ansel/gallery/sort.php @@ -20,7 +20,7 @@ if (!isset($galleryId)) { exit; } try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Excception $e) { $notification->push(_("There was an error accessing the gallery."), 'horde.error'); header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); diff --git a/ansel/group.php b/ansel/group.php index accc8a1a9..0c900f0f2 100644 --- a/ansel/group.php +++ b/ansel/group.php @@ -29,14 +29,14 @@ $groups_perpage = $prefs->getValue('groupsperpage'); switch ($groupby) { case 'category': try { - $num_groups = $ansel_storage->countCategories(Horde_Perms::SHOW); + $num_groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countCategories(Horde_Perms::SHOW); } catch (Ansel_Exception $e) { $notification->push($num_groups); $num_groups = 0; $groups = array(); } if ($num_groups) { - $groups = $ansel_storage->listCategories(Horde_Perms::SHOW, + $groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listCategories(Horde_Perms::SHOW, $gbpage * $groups_perpage, $groups_perpage); } else { @@ -46,9 +46,9 @@ case 'category': case 'owner': try { - if ($num_groups = $ansel_storage->shares->countOwners(Horde_Perms::SHOW, null, false)) { + if ($num_groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->countOwners(Horde_Perms::SHOW, null, false)) { - $groups = $ansel_storage->shares->listOwners(Horde_Perms::SHOW, + $groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->listOwners(Horde_Perms::SHOW, null, false, $gbpage * $groups_perpage, diff --git a/ansel/image.php b/ansel/image.php index 52a3fa2dd..5c55eb849 100644 --- a/ansel/image.php +++ b/ansel/image.php @@ -54,7 +54,7 @@ if (is_null($actionID) && is_null($tags)) { /* Get the gallery object and style information */ try { - $gallery = $ansel_storage->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error'); header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); @@ -65,7 +65,7 @@ try { if (!is_null($tags) && strlen($tags)) { $tags = explode(',', $tags); if (!empty($image_id)) { - $resource = &$ansel_storage->getImage($image_id); + $resource = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); } else { $resource = $gallery; } @@ -102,7 +102,7 @@ switch ($actionID) { case 'deletetags': $tag = Horde_Util::getFormData('tag'); if (!empty($image_id)) { - $resource = &$ansel_storage->getImage($image_id); + $resource = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $page = Horde_Util::getFormData('page', 0); $url = Ansel::getUrlFor('view', array_merge( array('view' => 'Image', @@ -127,7 +127,7 @@ case 'deletetags': case 'modify': try { - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $ret = Horde_Util::getFormData('ret', 'gallery'); } catch (Ansel_Exception $e) { $notification->push(_("Photo not found."), 'horde.error'); @@ -204,7 +204,7 @@ case 'save': } catch (Horde_Browser_Exception $e) {} } - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->caption = $vars->get('image_desc'); $image->setTags(explode(',' , $vars->get('image_tags'))); @@ -309,7 +309,7 @@ case 'resizeedit': } /* Retrieve image details. */ - $image = $ansel_storage->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $title = sprintf(_("Edit %s :: %s"), $gallery->get('name'), $image->filename); @@ -367,7 +367,7 @@ case 'watermark': header('Location: ' . $imageurl); exit; } else { - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->watermark('screen', $watermark, $watermark_halign, $watermark_valign, $watermark_font); $image->updateData($image->raw('screen'), 'screen'); @@ -396,7 +396,7 @@ case 'resize': 'horde.error'); } else { try { - $image = $ansel_storage->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); @@ -460,7 +460,7 @@ case 'resize': case 'setwatermark': $title = _("Watermark"); try { - $image = $ansel_storage->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($image->getMessage(), 'horde.error'); header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); @@ -507,7 +507,7 @@ case 'previewrotate270': $action = substr($actionID, 7); /* Retrieve image details. */ - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $title = sprintf(_("Preview changes for %s :: %s"), $gallery->get('name'), $image->filename); @@ -525,35 +525,35 @@ case 'imagerotate180': case 'imagerotate270': $view = Horde_Util::getFormData('view'); $angle = intval(substr($actionID, 11)); - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->rotate($view, $angle); $image->display($view); exit; case 'imageflip': $view = Horde_Util::getFormData('view'); - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->flip($view); $image->display($view); exit; case 'imagemirror': $view = Horde_Util::getFormData('view'); - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->mirror($view); $image->display($view); exit; case 'imagegrayscale': $view = Horde_Util::getFormData('view'); - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->grayscale($view); $image->display($view); exit; case 'imagewatermark': $view = Horde_Util::getFormData('view'); - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->watermark($view, $watermark, $watermark_halign, $watermark_valign, $watermark_font); $image->display($view); @@ -615,7 +615,7 @@ case 'move': $newGallery = Horde_Util::getFormData('new_gallery'); if ($images && $newGallery) { try { - $newGallery = $ansel_storage->getGallery($newGallery); + $newGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($newGallery); $result = $gallery->moveImagesTo($images, $newGallery); $notification->push( sprintf(ngettext("Moved %d photo from \"%s\" to \"%s\"", @@ -660,7 +660,7 @@ case 'copy': $newGallery = Horde_Util::getFormData('new_gallery'); if ($images && $newGallery) { try { - $newGallery = $ansel_storage->getGallery($newGallery); + $newGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($newGallery); $result = $gallery->copyImagesTo($images, $newGallery); $notification->push( sprintf(ngettext("Copied %d photo to %s", @@ -687,7 +687,7 @@ case 'copy': case 'downloadzip': $galleryId = Horde_Util::getFormData('gallery'); if ($galleryId) { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); if (!$registry->getAuth() || !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) || $gallery->hasPasswd() || !$gallery->isOldEnough()) { @@ -734,7 +734,7 @@ case 'previewcrop': $action = substr($actionID, 7); /* Retrieve image details. */ - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $title = sprintf(_("Preview changes for %s :: %s"), $gallery->get('name'), $image->filename); @@ -752,7 +752,7 @@ case 'imagecrop': if ($gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $params = Horde_Util::getFormData('params'); list($x1, $y1, $x2, $y2) = explode('.', $params); - $image = &$ansel_storage->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->load('full'); $image->crop($x1, $y1, $x2, $y2); $image->display(); diff --git a/ansel/img/download.php b/ansel/img/download.php index 0bd301339..21333661d 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 = $ansel_storage->getImage(Horde_Util::getFormData('image')); -$gallery = $ansel_storage->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) || !$gallery->canDownload()) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."), __FILE__, __LINE__); } diff --git a/ansel/img/ecard.php b/ansel/img/ecard.php index f4b9b7864..ac7a87720 100644 --- a/ansel/img/ecard.php +++ b/ansel/img/ecard.php @@ -17,8 +17,8 @@ if (empty($conf['ecard']['enable'])) { } /* Get the gallery and the image, and abort if either fails. */ -$gallery = $ansel_storage->getGallery(Horde_Util::getFormData('gallery')); -$image = &$gallery->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(Horde_Util::getFormData('gallery')); +$image = $gallery->getImage(Horde_Util::getFormData('image')); /* Run through the action handlers. */ switch (Horde_Util::getFormData('actionID')) { diff --git a/ansel/img/full.php b/ansel/img/full.php index ffe1615d1..1fa89c666 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 = $ansel_storage->getImage(Horde_Util::getFormData('image')); -$gallery = $ansel_storage->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ) || !$gallery->canDownload()) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/index.php b/ansel/img/index.php index 7e7e2818a..937c9ee90 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 = &$ansel_storage->getImage(Horde_Util::getFormData('image')); -$gallery = $ansel_storage->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/mini.php b/ansel/img/mini.php index 8ec563289..25f5c2f42 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 = $ansel_storage->getImage(Horde_Util::getFormData('image')); -$gallery = $ansel_storage->getGallery(abs($image->gallery)); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery)); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/prettythumb.php b/ansel/img/prettythumb.php index 1942c3091..203e979e0 100644 --- a/ansel/img/prettythumb.php +++ b/ansel/img/prettythumb.php @@ -12,8 +12,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); $style = Horde_Util::getFormData('style'); -$image = $ansel_storage->getImage(Horde_Util::getFormData('image')); -$gallery = $ansel_storage->getGallery(abs($image->gallery)); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery)); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/screen.php b/ansel/img/screen.php index 1e7d83865..a9ea08a48 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 = &$ansel_storage->getImage(Horde_Util::getFormData('image')); -$gallery = $ansel_storage->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/thumb.php b/ansel/img/thumb.php index bb7b39cbb..1caea0d2d 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 = $ansel_storage->getImage(Horde_Util::getFormData('image')); -$gallery = $ansel_storage->getGallery(abs($image->gallery)); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(Horde_Util::getFormData('image')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery)); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo.")); } diff --git a/ansel/img/upload.php b/ansel/img/upload.php index d39beafbd..165548435 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 = $ansel_storage->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error'); header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); @@ -209,7 +209,7 @@ if ($form->validate($vars)) { $cnt = count($image_ids); for ($i = 0; $i < $conf['image']['autogen'] && $cnt > $i; $i++) { $image_id = $image_ids[$i]; - $image = &$GLOBALS['ansel_storage']->getImage($image_id); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->createView('screen'); $image->createView('thumb'); $image->createView('mini'); diff --git a/ansel/img/upload_preview.php b/ansel/img/upload_preview.php index 4ecad89c5..c28e54cef 100644 --- a/ansel/img/upload_preview.php +++ b/ansel/img/upload_preview.php @@ -10,7 +10,7 @@ require_once dirname(__FILE__) . '/../lib/Application.php'; Horde_Registry::appInit('ansel'); -$gallery = $ansel_storage->getGallery((int)Horde_Util::getFormData('gallery')); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery((int)Horde_Util::getFormData('gallery')); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_PermissionDenied(); } diff --git a/ansel/lib/Ajax/Imple/EditCaption.php b/ansel/lib/Ajax/Imple/EditCaption.php index 057903fc7..b9489ca75 100644 --- a/ansel/lib/Ajax/Imple/EditCaption.php +++ b/ansel/lib/Ajax/Imple/EditCaption.php @@ -54,7 +54,7 @@ class Ansel_Ajax_Imple_EditCaption extends Horde_Ajax_Imple_Base /* Are we requesting the unformatted text? */ if (!empty($args['action']) && $args['action'] == 'load') { $id = $args['id']; - $image = $GLOBALS['ansel_storage']->getImage($id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); $caption = $image->caption; return $caption; @@ -66,8 +66,8 @@ class Ansel_Ajax_Imple_EditCaption extends Horde_Ajax_Imple_Base return ''; } $id = $args['id']; - $image = $GLOBALS['ansel_storage']->getImage($id); - $g = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); + $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if ($g->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $image->caption = $pref_value; try { diff --git a/ansel/lib/Ajax/Imple/EditFaces.php b/ansel/lib/Ajax/Imple/EditFaces.php index ce66ae86e..0a08d86e3 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_Ajax_Imple_Base // Attempt to get faces from the picture if we don't already have results, // or if we were asked to explicitly try again. if (($reload || empty($result))) { - $image = $GLOBALS['ansel_storage']->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->createView('screen'); $result = $faces->getFromPicture($image_id, $autocreate); } @@ -70,8 +70,8 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base case 'delete': // delete - deletes a single face from an image. $face_id = (int)$post['face']; - $image = $GLOBALS['ansel_storage']->getImage($image_id); - $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception('Access denied editing the photo.'); } @@ -87,8 +87,8 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base } $name = $post['facename']; - $image = &$GLOBALS['ansel_storage']->getImage($image_id); - $gallery = &$GLOBALS['ansel_storage']->getGallery($image->gallery); + $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); + $gallery = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception('You are not allowed to edit this photo'); } diff --git a/ansel/lib/Ajax/Imple/GallerySlugCheck.php b/ansel/lib/Ajax/Imple/GallerySlugCheck.php index 8c2b167fc..14e88781e 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_Ajax_Imple_Base return array('response' => '0'); } - $exists = $GLOBALS['ansel_storage']->slugExists($slug) ? 0 : 1; + $exists = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->slugExists($slug) ? 0 : 1; return array('response' => $exists); } diff --git a/ansel/lib/Ajax/Imple/ImageSaveGeotag.php b/ansel/lib/Ajax/Imple/ImageSaveGeotag.php index 85492728e..4159134e3 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_Ajax_Imple_Base // Get the image and gallery to check perms try { - $image = $GLOBALS['ansel_storage']->getImage((int)$img); - $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage((int)$img); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); } catch (Ansel_Exception $e) { return array('response' => 0); } @@ -64,7 +64,7 @@ class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Ajax_Imple_Base // Now get the "add geotag" stuff $addurl = Horde::applicationUrl('map_edit.php')->add('image', $img); $addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::applicationUrl('map_edit.php'), array('params' => array('image' => $img), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;')); - $imgs = $GLOBALS['ansel_storage']->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); + $imgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); if (count($imgs) > 0) { $imgsrc = '
'; foreach ($imgs as $id => $data) { diff --git a/ansel/lib/Ajax/Imple/LocationAutoCompleter.php b/ansel/lib/Ajax/Imple/LocationAutoCompleter.php index 98dcc608a..682fe780d 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_Ajax_Imple_AutoComple /* Use ajax? */ if (!isset($_SESSION['ansel']['ajax_locationac'])) { - $results = $GLOBALS['ansel_storage']->searchLocations(); + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->searchLocations(); if ($results instanceof PEAR_Error) { Horde::logMessage($results, 'ERR'); } else { @@ -39,7 +39,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Ajax_Imple_AutoComple $ret['ajax'] = 'LocationAutoCompleter'; } else { if (empty($results)) { - $results = $GLOBALS['ansel_storage']->searchLocations(); + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->searchLocations(); } $ret['browser'] = Horde_Serialize::serialize($results, Horde_Serialize::JSON); } @@ -55,7 +55,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Ajax_Imple_AutoComple return array(); } try { - $locs = $GLOBALS['ansel_storage']->searchLocations($input); + $locs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->searchLocations($input); if (!count($locs)) { $locs = new StdClass(); } diff --git a/ansel/lib/Ajax/Imple/TagActions.php b/ansel/lib/Ajax/Imple/TagActions.php index ca5e2a33b..cf2387555 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_Ajax_Imple_Base /* Get the resource owner */ if ($type == 'gallery') { - $resource = $GLOBALS['ansel_storage']->getGallery($id); + $resource = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($id); $parent = $resource; } else { - $resource = $GLOBALS['ansel_storage']->getImage($id); - $parent = $GLOBALS['ansel_storage']->getGallery($resource->gallery); + $resource = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($resource->gallery); } switch ($action) { diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index 1c7bbb2d3..b312d0757 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -79,9 +79,8 @@ class Ansel $allLevels = true, $from = 0, $count = 0, $ignore = null) { - global $ansel_storage; - $galleries = $ansel_storage->listGalleries($perm, $attributes, $parent, - $allLevels, $from, $count); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope() + ->listGalleries($perm, $attributes, $parent, $allLevels, $from, $count); $tree = Horde_Tree::factory('gallery_tree', 'Select'); if (!empty($ignore)) { @@ -211,8 +210,8 @@ class Ansel // Getting these objects is not ideal, but at this point // they should already be locally cached so the cost // is minimized. - $i = $GLOBALS['ansel_storage']->getImage($data['image']); - $g = $GLOBALS['ansel_storage']->getGallery($data['gallery']); + $i = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($data['image']); + $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($data['gallery']); if ($g->get('view_mode') == 'Date') { $imgDate = new Horde_Date($i->originalDate); @@ -387,7 +386,7 @@ class Ansel */ static public function getImageUrl($imageId, $view = 'screen', $full = false, $style = null) { - global $conf, $ansel_storage; + global $conf; // To avoid having to add a new img/* file everytime we add a new // thumbstyle, we check for the 'non-prettythumb' views, then route the @@ -419,7 +418,7 @@ class Ansel // We have to make sure the image exists first, since we won't // be going through img/*.php to auto-create it. try { - $image = $ansel_storage->getImage($imageId); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($imageId); } catch (Ansel_Exception $e) { Horde::logMessage($e, 'ERR'); return Horde::applicationUrl((string)Ansel::getErrorImage($view), $full); @@ -615,8 +614,9 @@ class Ansel */ static public function getBreadCrumbs($separator = ' » ', $gallery = null) { - global $prefs, $ansel_storage; + global $prefs; + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope(); $groupby = Horde_Util::getFormData('groupby', $prefs->getValue('groupby')); $owner = Horde_Util::getFormData('owner'); $image_id = (int)Horde_Util::getFormData('image'); @@ -957,11 +957,11 @@ class Ansel $zipfiles = array(); foreach ($images as $id) { - $image = $GLOBALS['ansel_storage']->getImage($id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); // If we didn't select an entire gallery, check the download // size for each image. if (!isset($view)) { - $g = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); $v = $g->canDownload() ? 'full' : 'screen'; } else { $v = $view; diff --git a/ansel/lib/Api.php b/ansel/lib/Api.php index f46e6dbbf..f84868a17 100644 --- a/ansel/lib/Api.php +++ b/ansel/lib/Api.php @@ -38,7 +38,7 @@ class Ansel_Api extends Horde_Registry_Api if (empty($path)) { $owners = array(); - $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, null, false); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, null, false); foreach ($galleries as $gallery) { $owners[$gallery->data['share_owner'] ? $gallery->data['share_owner'] : '-system-'] = true; } @@ -69,28 +69,27 @@ class Ansel_Api extends Horde_Registry_Api } } return $results; - } else { if (count($parts) == 1) { // This request is for all galleries owned by the requested user. - $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, $parts[0], null, false); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, $parts[0], null, false); $images = array(); } elseif ($this->galleryExists(null, end($parts))) { // This request if for a certain gallery, list all sub-galleries // and images. $gallery_id = end($parts); - $galleries = $GLOBALS['ansel_storage']->getGalleries(array($gallery_id)); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleries(array($gallery_id)); if (!isset($galleries[$gallery_id]) || !$galleries[$gallery_id]->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception_NotFound(_("Invalid gallery specified.")); } - $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $gallery_id, false); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $gallery_id, false); $images = $this->listImages(null, $gallery_id, Horde_Perms::SHOW, 'mini'); } elseif (count($parts) > 2 && $this->galleryExists(null, $parts[count($parts) - 2]) && - ($image = $GLOBALS['ansel_storage']->getImage(end($parts)))) { + ($image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(end($parts)))) { return array('data' => $image->raw(), 'mimetype' => $image->type, @@ -187,10 +186,10 @@ class Ansel_Api extends Horde_Registry_Api } $image_name = array_pop($parts); $gallery_id = end($parts); - if (!$GLOBALS['ansel_storage']->galleryExists($gallery_id)) { + if (!$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($gallery_id)) { throw new Horde_Exception_NotFound("Gallery does not exist"); } - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception_PermissionDenied(_("Access denied adding photos to \"%s\".")); } @@ -216,7 +215,7 @@ class Ansel_Api extends Horde_Registry_Api } try { - if (!($image = $GLOBALS['ansel_storage']->getImage($image_id))) { + if (!($image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id))) { return false; } } catch (Ansel_Exception $e) { @@ -307,26 +306,22 @@ class Ansel_Api extends Horde_Registry_Api $gallery_data = null, $encoding = null, $slug = null, $compression = 'none', $skiphook = false) { - $image_data = null; - - /* If no app is given use Ansel's own gallery which is initialized - * in base.php */ + /* Set application scope */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set($app); } - + $image_data = null; + if (isset($image['filename']) && isset($image['description']) && isset($image['data']) && isset($image['type'])) { Horde::logMessage(sprintf("Receiving image %s in saveImage() with a raw filesize of %i", $image['filename'], strlen($image['data'])), 'DEBUG'); $image_data = array('image_filename' => $image['filename'], - 'image_caption' => $image['description'], - 'image_type' => $image['type'], - 'data' => $this->_getImageData($image['data'], $encoding, $compression, true)); - } else { - Horde::logMessage(sprintf("Receiving image %s in saveImage() with a raw filesize of %i", $image['file'], filesize($image['file'])), 'DEBUG'); - } + 'image_caption' => $image['description'], + 'image_type' => $image['type'], + 'data' => $this->_getImageData($image['data'], $encoding, $compression, true)); + } if (is_null($image_data) && getimagesize($image['file']) === false) { throw new InvalidArgumentException(_("The file you uploaded does not appear to be a valid photo.")); @@ -335,9 +330,9 @@ class Ansel_Api extends Horde_Registry_Api throw new InvalidArgumentException(_("A gallery to add this photo to is required.")); } if (!empty($slug)) { - $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug); - } elseif ($GLOBALS['ansel_storage']->galleryExists($gallery_id)) { - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug); + } elseif ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($gallery_id)) { + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied adding photos to \"%s\"."), $gallery->get('name'))); @@ -358,11 +353,9 @@ class Ansel_Api extends Horde_Registry_Api ); } - if (isset($image['tags']) && is_array($image['tags']) && - count($image['tags'])) { - $image_data['tags'] = $image['tags']; - } - + if (isset($image['tags']) && is_array($image['tags']) && count($image['tags'])) { + $image_data['tags'] = $image['tags']; + } $image_id = $gallery->addImage($image_data, $default); // Call the postupload hook if needed @@ -406,14 +399,12 @@ class Ansel_Api extends Horde_Registry_Api throw new Horde_Exception_PermissionDenied(_("Access denied deleting galleries.")); } - /* If no app is given use Ansel's own gallery which is initialized in - base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - $image = $GLOBALS['ansel_storage']->getImage($image_id); - $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied deleting photos from \"%s\"."), $gallery->get('name'))); } @@ -444,7 +435,7 @@ class Ansel_Api extends Horde_Registry_Api } if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } if (!empty($perm)) { @@ -456,7 +447,7 @@ class Ansel_Api extends Horde_Registry_Api $permobj = null; } - $gallery = $GLOBALS['ansel_storage']->createGallery($attributes, $permobj, $parent); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery($attributes, $permobj, $parent); return $gallery->id; } @@ -476,13 +467,11 @@ class Ansel_Api extends Horde_Registry_Api throw new Horde_Exception_PermissionDenied(_("Access denied deleting galleries.")); } - /* If no app is given use Ansel's own gallery which is initialized in - base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { throw new Horde_Exception_PermissionDenied(sprintf(_("Access denied deleting gallery \"%s\"."), $gallery->get('name'))); } else { @@ -493,7 +482,7 @@ class Ansel_Api extends Horde_Registry_Api } } - return $GLOBALS['ansel_storage']->removeGallery($gallery); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery); } } @@ -508,17 +497,14 @@ class Ansel_Api extends Horde_Registry_Api */ public function count($app = null, $gallery_id = null, $slug = '') { - /* If no app is given use Ansel's own gallery which is initialized in - base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - try { if (!empty($slug)) { - $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug); } else { - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } return (int)$gallery->countImages(); } catch (Ansel_Exception $e) { @@ -539,16 +525,14 @@ class Ansel_Api extends Horde_Registry_Api public function getDefaultImage($app = null, $gallery_id = null, $style = 'ansel_default', $slug = '') { - /* If no app is given use Ansel's own gallery which is initialized in - base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } if (!empty($slug)) { - $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug); } else { - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } return $gallery->getDefaultImage($style); @@ -565,13 +549,10 @@ class Ansel_Api extends Horde_Registry_Api * * @return string The image path. */ - public function getImageUrl($app = null, $image_id, $view = 'screen', - $full = false, $style = null) + public function getImageUrl($app = null, $image_id, $view = 'screen', $full = false, $style = null) { - /* If no app is given use Ansel's own gallery which is initialized in - base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } return (string)Ansel::getImageUrl($image_id, $view, $full, $style); @@ -595,14 +576,13 @@ class Ansel_Api extends Horde_Registry_Api $app = null, $encoding = null, $compression = 'none') { - /* If no app is given use Ansel's own gallery which is initialized in base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } /* Get image and gallery */ - $image = $GLOBALS['ansel_storage']->getImage($image_id); - $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); /* Check age and password */ if (!$gallery->hasPasswd() || !$gallery->isOldEnough()) { @@ -653,9 +633,9 @@ class Ansel_Api extends Horde_Registry_Api /* If no app is given use Ansel's own gallery which is initialized in base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - $galleries = $GLOBALS['ansel_storage']->listGalleries( + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries( $perm, $attributes, $parent, $allLevels, $from, $count, $sort_by, $direction); $return = array(); @@ -678,13 +658,13 @@ class Ansel_Api extends Horde_Registry_Api public function getGalleries($ids = array(), $app = null, $slugs = array()) { if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } if (count($slugs)) { - $results = $GLOBALS['ansel_storage']->getGalleriesBySlugs($slugs); + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleriesBySlugs($slugs); } else { - $results = $GLOBALS['ansel_storage']->getGalleries($ids); + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleries($ids); } /* We can't just return the results of the getGalleries call - we need to @@ -718,14 +698,11 @@ class Ansel_Api extends Horde_Registry_Api $allLevels = true, $from = 0, $count = 0, $default = null) { - /* If no app is given use Ansel's own gallery which is initialized in - base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set($app); } - return Ansel::selectGalleries($default, $perm, null, $parent, $allLevels, - $from, $count); + return Ansel::selectGalleries($default, $perm, null, $parent, $allLevels, $from, $count); } /** @@ -752,16 +729,14 @@ class Ansel_Api extends Horde_Registry_Api $view = 'screen', $full = false, $from = 0, $count = 0, $style = null, $slug = '') { - /* If no app is given use Ansel's own gallery which is initialized in - base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } /* Determine the default gallery when none is given. The first gallery in the list is the default gallery. */ if (is_null($gallery_id) && empty($slug)) { - $galleries = $GLOBALS['ansel_storage']->listGalleries($perm); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries($perm); if (!count($galleries)) { return array(); } @@ -769,9 +744,9 @@ class Ansel_Api extends Horde_Registry_Api $gallery_names = array_keys($galleries[$keys[0]]['galleries']); $gallery_id = $gallery_names[0]; } elseif (!empty($slug)) { - $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug); } else { - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } $images = $gallery->listImages(); @@ -779,7 +754,7 @@ class Ansel_Api extends Horde_Registry_Api $counter = 0; $imagelist = array(); foreach ($images as $id) { - $image = $GLOBALS['ansel_storage']->getImage($id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); $imagelist[$id]['name'] = $image->filename; $imagelist[$id]['caption'] = $image->caption; $imagelist[$id]['type'] = $image->type; @@ -815,9 +790,9 @@ class Ansel_Api extends Horde_Registry_Api $slugs = array()) { if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - $images = $GLOBALS['ansel_storage']->getRecentImages($galleries, $limit, $slugs); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($galleries, $limit, $slugs); $imagelist = array(); foreach ($images as $image) { $id = $image->id; @@ -856,13 +831,11 @@ class Ansel_Api extends Horde_Registry_Api public function countGalleries($app = null, $perm = Horde_Perms::SHOW, $attributes = null, $parent = null, $allLevels = true) { - /* If no app is given use Ansel's own gallery which is initialized - * in base.php */ if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - return $GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), $perm, + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), $perm, $attributes, $parent, $allLevels); } @@ -906,13 +879,9 @@ class Ansel_Api extends Horde_Registry_Api */ public function searchTags($names, $max = 10, $from = 0, $resource_type = 'all', $user = null, $raw = false, - $app = null) + $app = 'ansel') { - if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); - } else { - $app = 'ansel'; - } + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); $results = Ansel_Tags::searchTags($names, $max, $from, $resource_type, $user); /* Check for error or if we requested the raw data array */ @@ -923,7 +892,7 @@ class Ansel_Api extends Horde_Registry_Api $return = array(); if (!empty($results['images'])) { foreach ($results['images'] as $image_id) { - $image = $GLOBALS['ansel_storage']->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $desc = $image->caption; $title = $image->filename; $view_url = Ansel::getUrlFor('view', @@ -932,16 +901,16 @@ class Ansel_Api extends Horde_Registry_Api 'view' => 'Image'), true); $return[] = array('title' => $image->filename, - 'desc'=> $image->caption, - 'view_url' => $view_url, - 'app' => $app); + 'desc'=> $image->caption, + 'view_url' => $view_url, + 'app' => $app); } } if (!empty($results['galleries'])) { foreach ($results['galleries'] as $gallery) { - $gal = $GLOBALS['ansel_storage']->getGallery($gallery); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery); $view_url = Horde::applicationUrl('view.php')->add( array('gallery' => $gallery, 'view' => 'Gallery')); @@ -967,10 +936,10 @@ class Ansel_Api extends Horde_Registry_Api public function galleryExists($app, $gallery_id = null, $slug = '') { if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } - return $GLOBALS['ansel_storage']->galleryExists($gallery_id, $slug); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($gallery_id, $slug); } /** @@ -995,11 +964,10 @@ class Ansel_Api extends Horde_Registry_Api * * @return array An array containing 'html' and 'crumbs' keys. */ - public function renderView($params = array(), $app = null, - $view = 'Gallery') + public function renderView($params = array(), $app = null, $view = 'Gallery') { if (!is_null($app)) { - $GLOBALS['ansel_storage'] = new Ansel_Storage($app); + $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app); } $classname = 'Ansel_View_' . basename($view); $params['api'] = true; diff --git a/ansel/lib/Application.php b/ansel/lib/Application.php index a22e9f112..38f54076a 100644 --- a/ansel/lib/Application.php +++ b/ansel/lib/Application.php @@ -48,7 +48,6 @@ class Ansel_Application extends Horde_Registry_Application * * Global variables defined: * $ansel_db - TODO - * $ansel_storage - TODO * * @throws Horde_Exception */ @@ -59,9 +58,9 @@ class Ansel_Application extends Horde_Registry_Application } $binders = array( - 'Ansel_Storage' => new Ansel_Injector_Binder_Storage(), 'Ansel_Styles' => new Ansel_Injector_Binder_Styles(), 'Ansel_Faces' => new Ansel_Injector_Binder_Faces(), + 'Ansel_Storage' => new Ansel_Injector_Binder_Storage() ); foreach ($binders as $interface => $binder) { $GLOBALS['injector']->addBinder($interface, $binder); @@ -69,7 +68,9 @@ class Ansel_Application extends Horde_Registry_Application // Create db, share, and vfs instances. $GLOBALS['ansel_db'] = Ansel::getDb(); - $GLOBALS['ansel_storage'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope('ansel'); + + /* Set up a default config */ + $GLOBALS['injector']->bindImplementation('Ansel_Config', 'Ansel_Config'); /* Set a logger for the Vfs */ $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images')->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger')); diff --git a/ansel/lib/Block/gallery.php b/ansel/lib/Block/gallery.php index 9416068a5..411b4d8cc 100644 --- a/ansel/lib/Block/gallery.php +++ b/ansel/lib/Block/gallery.php @@ -36,8 +36,8 @@ class Horde_Block_ansel_gallery extends Horde_Block { 'type' => 'checkbox', 'default' => true)); - if ($GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { - foreach ($GLOBALS['ansel_storage']->listGalleries() as $gal) { + if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { + foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries() as $gal) { $params['gallery']['values'][$gal->id] = $gal->get('name'); } } @@ -116,9 +116,9 @@ class Horde_Block_ansel_gallery extends Horde_Block { // Get the gallery object and cache it. if (isset($this->_params['gallery']) && $this->_params['gallery'] != '__random') { - $this->_gallery = $GLOBALS['ansel_storage']->getGallery($this->_params['gallery']); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_params['gallery']); } else { - $this->_gallery = $GLOBALS['ansel_storage']->getRandomGallery(); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery(); } // Protect at least a little bit against getting an empty gallery. We diff --git a/ansel/lib/Block/my_galleries.php b/ansel/lib/Block/my_galleries.php index 9fde9c1d9..a906c9d71 100644 --- a/ansel/lib/Block/my_galleries.php +++ b/ansel/lib/Block/my_galleries.php @@ -40,7 +40,7 @@ class Horde_Block_ansel_my_galleries extends Horde_Block { Horde::addScriptFile('tooltips.js', 'horde'); /* Get the top level galleries */ try { - $galleries = $GLOBALS['ansel_storage']->listGalleries( + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries( Horde_Perms::EDIT, $GLOBALS['registry']->getAuth(), null, false, 0, empty($this->_params['limit']) ? 0 : $this->_params['limit'], 'last_modified', 1); diff --git a/ansel/lib/Block/random_photo.php b/ansel/lib/Block/random_photo.php index d17f53f7f..e4a1afe2f 100644 --- a/ansel/lib/Block/random_photo.php +++ b/ansel/lib/Block/random_photo.php @@ -28,7 +28,7 @@ class Horde_Block_ansel_random_photo extends Horde_Block { function _content() { - $gallery = $GLOBALS['ansel_storage']->getRandomGallery(); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery(); if (!$gallery) { return _("There are no photo galleries available."); } diff --git a/ansel/lib/Block/recent_comments.php b/ansel/lib/Block/recent_comments.php index 8679f57ef..d09a9016d 100644 --- a/ansel/lib/Block/recent_comments.php +++ b/ansel/lib/Block/recent_comments.php @@ -29,8 +29,8 @@ class Horde_Block_ansel_recent_comments extends Horde_Block { 'default' => '__random', 'values' => array('all' => 'All'))); - if ($GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { - foreach ($GLOBALS['ansel_storage']->listGalleries(Horde_Perms::READ) as $id => $gal) { + if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { + foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::READ) as $id => $gal) { $params['gallery']['values'][$id] = $gal->get('name'); } } @@ -68,7 +68,7 @@ class Horde_Block_ansel_recent_comments extends Horde_Block { function _content() { - global $registry, $ansel_storage; + global $registry; if ($this->_params['gallery'] == 'all') { $threads = $registry->call('forums/list', array(0, 'ansel')); @@ -103,7 +103,7 @@ class Horde_Block_ansel_recent_comments extends Horde_Block { foreach ($results as $comment) { try { - $image = &$ansel_storage->getImage($comment['image_id']); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($comment['image_id']); $url = Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => abs($image->gallery), @@ -139,9 +139,9 @@ class Horde_Block_ansel_recent_comments extends Horde_Block { // Get the gallery object and cache it. if (isset($this->_params['gallery']) && $this->_params['gallery'] != '__random') { - $this->_gallery = $GLOBALS['ansel_storage']->getGallery($this->_params['gallery']); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_params['gallery']); } else { - $this->_gallery =$GLOBALS['ansel_storage']->getRandomGallery(); + $this->_gallery =$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery(); } if (empty($this->_gallery)) { diff --git a/ansel/lib/Block/recently_added.php b/ansel/lib/Block/recently_added.php index a2d45da2e..e8e4feae4 100644 --- a/ansel/lib/Block/recently_added.php +++ b/ansel/lib/Block/recently_added.php @@ -31,8 +31,8 @@ class Horde_Block_ansel_recently_added extends Horde_Block { 'default' => 10), ); - if ($GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { - foreach ($GLOBALS['ansel_storage']->listGalleries(Horde_Perms::READ) as $id => $gal) { + if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { + foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::READ) as $id => $gal) { if (!$gal->hasPasswd() && $gal->isOldEnough()) { $params['gallery']['values'][$id] = $gal->get('name'); } @@ -83,7 +83,7 @@ class Horde_Block_ansel_recently_added extends Horde_Block { // Retrieve the images, but protect against very large values for // limit. try { - $results = $GLOBALS['ansel_storage']->getRecentImages( + $results = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages( $galleries, min($this->_params['limit'], 100)); } catch (Ansel_Exception $e) { return $e->getMessage(); @@ -115,7 +115,7 @@ function previewImage(e, image_id) { HEADER; foreach ($results as $image) { - $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); // Don't show locked galleries in the block. if (!$gallery->isOldEnough() || $gallery->hasPasswd()) { @@ -171,9 +171,9 @@ HEADER; /* Get the gallery object and cache it. */ if (isset($this->_params['gallery']) && $this->_params['gallery'] != '__random') { - $this->_gallery = $GLOBALS['ansel_storage']->getGallery($this->_params['gallery']); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_params['gallery']); } else { - $this->_gallery = $GLOBALS['ansel_storage']->getRandomGallery(); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery(); } if (empty($this->_gallery)) { diff --git a/ansel/lib/Block/recently_added_geodata.php b/ansel/lib/Block/recently_added_geodata.php index e26b892db..27a70e146 100644 --- a/ansel/lib/Block/recently_added_geodata.php +++ b/ansel/lib/Block/recently_added_geodata.php @@ -35,8 +35,8 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block { 'default' => 250), ); - if ($GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { - foreach ($GLOBALS['ansel_storage']->listGalleries(Horde_Perms::READ) as $id => $gal) { + if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) { + foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::READ) as $id => $gal) { if (!$gal->hasPasswd() && $gal->isOldEnough()) { $params['gallery']['values'][$id] = $gal->get('name'); } @@ -87,14 +87,14 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block { } try { - $images = $GLOBALS['ansel_storage']->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100)); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100)); } catch (Ansel_Exception $e) { return $e->getMessage(); } $images = array_reverse($images); foreach ($images as $key => $image) { $id = $image['image_id']; - $gallery = $GLOBALS['ansel_storage']->getGallery($image['gallery_id']); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image['gallery_id']); /* Don't show locked galleries in the block. */ if (!$gallery->isOldEnough() || $gallery->hasPasswd()) { @@ -145,10 +145,10 @@ EOT; if (isset($this->_params['gallery']) && $this->_params['gallery'] != '__random') { - $this->_gallery = $GLOBALS['ansel_storage']->getGallery( + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery( $this->_params['gallery']); } else { - $this->_gallery = $GLOBALS['ansel_storage']->getRandomGallery(); + $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery(); } if (empty($this->_gallery)) { diff --git a/ansel/lib/Config.php b/ansel/lib/Config.php new file mode 100644 index 000000000..efc41aa1f --- /dev/null +++ b/ansel/lib/Config.php @@ -0,0 +1,32 @@ +_config['scope'] = 'ansel'; + } + + public function set($config, $value) + { + $this->_config[$config] = $value; + } + + public function get($config) + { + if (!isset($this->_config[$config])) { + throw InvalidArgumentException($config . _(" not found")); + } + return $this->_config[$config]; + } + +} \ No newline at end of file diff --git a/ansel/lib/Faces/Base.php b/ansel/lib/Faces/Base.php index aa3d4c51f..d3d35faae 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['ansel_storage']->shares->getShareCriteria( + $share = substr($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->getShareCriteria( $GLOBALS['registry']->getAuth(), Horde_Perms::READ), 5); $sql = 'SELECT f.face_id, f.gallery_id, f.image_id, f.face_name FROM ansel_faces f, ' @@ -209,7 +209,7 @@ class Ansel_Faces_Base { // add gallery permission // FIXME: Ditto on the REALLY ugly hack comment from above! - $share = substr($GLOBALS['ansel_storage']->shares->getShareCriteria( + $share = substr($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->getShareCriteria( $GLOBALS['registry']->getAuth(), Horde_Perms::READ), 5); $sql = 'SELECT COUNT(*) FROM ansel_faces f, ' @@ -352,7 +352,7 @@ class Ansel_Faces_Base return false; } $data = $this->getFaceById($face_id, true); - $image = $GLOBALS['ansel_storage']->getImage($image_id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); // Actually create the image. $this->createView( @@ -445,8 +445,8 @@ class Ansel_Faces_Base */ public function saveCustomFace($face_id, $image, $x1, $y1, $x2, $y2, $name = '') { - $image = $GLOBALS['ansel_storage']->getImage($image); - $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception_PermissionDenied('Access denied editing the photo.'); } @@ -534,8 +534,8 @@ class Ansel_Faces_Base { // get image if ID is passed if (!($image instanceof Ansel_Image)) { - $image = $GLOBALS['ansel_storage']->getImage($image); - $gallery = $GLOBALS['ansel_storage']->getGallery($image->gallery); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception_PermissionDenied('Access denied editing the photo.'); } @@ -730,7 +730,7 @@ class Ansel_Faces_Base */ public function getFromGallery($gallery_id, $create = false, $force = false) { - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception(sprintf("Access denied editing gallery \"%s\".", $gallery->get('name'))); } diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index 897fd78d0..f74bde16a 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -29,7 +29,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical { /* Pass on up the chain */ parent::__construct($attributes); - $this->setShareOb($GLOBALS['ansel_storage']->shares); + $this->setShareOb($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares); $mode = isset($attributes['attribute_view_mode']) ? $attributes['attribute_view_mode'] : 'Normal'; $this->_setModeHelper($mode); } @@ -128,7 +128,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical } // Check for slug uniqueness - $slugGalleryId = $GLOBALS['ansel_storage']->slugExists($this->data['attribute_slug']); + $slugGalleryId = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->slugExists($this->data['attribute_slug']); if ($slugGalleryId > 0 && $slugGalleryId <> $this->id) { throw InvalidArgumentException( sprintf(_("Could not save gallery, the slug, \"%s\", already exists."), @@ -169,7 +169,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical } } else { /* Updating other gallery */ - $g = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); $count = $g->get('images'); if ($add) { $count += $images; @@ -257,7 +257,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical /* Check for a supported multi-page image */ if ($image->isMultiPage() === true) { $params['name'] = $image->getImagePageCount() . ' page image: ' . $image->filename; - $mGallery = $GLOBALS['ansel_storage']->createGallery($params, $this->getPermission(), $this->getId()); + $mGallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery($params, $this->getPermission(), $this->getId()); $i = 1; foreach ($image as $page) { $page->caption = sprintf(_("Page %d"), $i++); @@ -562,7 +562,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical */ public function getRecentImages($limit = 10) { - return $GLOBALS['ansel_storage']->getRecentImages(array($this->id), + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages(array($this->id), $limit); } @@ -575,7 +575,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical */ public function &getImage($id) { - return $GLOBALS['ansel_storage']->getImage($id); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); } /** @@ -695,7 +695,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical if ($this->hasSubGalleries()) { // Fall through to a default image of a sub gallery. try { - $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $this, false); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $this, false); } catch (Horde_Exception $e) { return false; } @@ -868,7 +868,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical { /* Make sure we have a gallery object */ if (!is_null($parent) && !($parent instanceof Ansel_Gallery)) { - $parent = $GLOBALS['ansel_storage']->getGallery($parent); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($parent); } /* Check this now since we don't know if we are updating the DB or not */ @@ -985,7 +985,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical public function __wakeup() { - $this->setShareOb($GLOBALS['ansel_storage']->shares); + $this->setShareOb($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares); $mode = $this->get('view_mode'); $this->_setModeHelper($mode); } diff --git a/ansel/lib/GalleryMode/Date.php b/ansel/lib/GalleryMode/Date.php index 81170b2f5..33b76aeda 100644 --- a/ansel/lib/GalleryMode/Date.php +++ b/ansel/lib/GalleryMode/Date.php @@ -156,7 +156,7 @@ class Ansel_GalleryMode_Date { if (!is_array($this->_subGalleries)) { /* Get a list of all the subgalleries */ - $subs = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $this->_gallery); + $subs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $this->_gallery); $this->_subGalleries = array_keys($subs); } } @@ -172,13 +172,15 @@ class Ansel_GalleryMode_Date */ function getGalleryChildren($perm = Horde_Perms::SHOW, $from = 0, $to = 0, $noauto = false) { - global $ansel_db, $ansel_storage; + global $ansel_db; /* Cache the results */ static $children = array(); - $cache_key = md5($this->_gallery->id . serialize($this->_date) . $from . $to); + /* Ansel Storage */ + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope(); + $cache_key = md5($this->_gallery->id . serialize($this->_date) . $from . $to); if (!empty($children[$cache_key])) { return $children[$cache_key]; } @@ -429,7 +431,7 @@ class Ansel_GalleryMode_Date */ if ($this->_gallery->get('has_subgalleries')) { $gallery_ids = array(); - $images = $GLOBALS['ansel_storage']->getImages(array('ids' => $ids)); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => $ids)); foreach ($images as $image) { if (empty($gallery_ids[$image->gallery])) { $gallery_ids[$image->gallery] = 1; @@ -480,7 +482,7 @@ class Ansel_GalleryMode_Date { /* Make sure $image is an Ansel_Image; if not, try loading it. */ if (!($image instanceof Ansel_Image)) { - $image = $GLOBALS['ansel_storage']->getImage($image); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image); } /* Make sure the image is in this gallery. */ @@ -592,7 +594,7 @@ class Ansel_GalleryMode_Date $ids = array_merge($ids, $child->_images); } $ids = $this->_getArraySlice($ids, $from, $count); - $images = $GLOBALS['ansel_storage']->getImages(array('ids' => $ids)); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => $ids)); } return $images; @@ -824,7 +826,7 @@ class Ansel_Gallery_Date { */ function getRecentImages($limit = 10) { - return $GLOBALS['ansel_storage']->getRecentImages(array($this->id), + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages(array($this->id), $limit); } @@ -837,7 +839,7 @@ class Ansel_Gallery_Date { */ function &getImage($id) { - return $GLOBALS['ansel_storage']->getImage($id); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); } /** diff --git a/ansel/lib/GalleryMode/Normal.php b/ansel/lib/GalleryMode/Normal.php index 095a72821..cfac65a73 100644 --- a/ansel/lib/GalleryMode/Normal.php +++ b/ansel/lib/GalleryMode/Normal.php @@ -65,12 +65,12 @@ class Ansel_GalleryMode_Normal { /* Get the number of images and galleries */ $numimages = $this->countImages(); - $num_galleries = $GLOBALS['ansel_storage']->countGalleries( + $num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries( $GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, null, $this->_gallery, false); /* Now fetch the subgalleries, but only if we need to */ if ($num_galleries > $from) { - $galleries = $GLOBALS['ansel_storage']->listGalleries( + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries( Horde_Perms::SHOW, null, $this->_gallery, false, $from, $to); } } @@ -142,7 +142,7 @@ class Ansel_GalleryMode_Normal { return $this->_gallery->data['attribute_images']; } - $gCnt = $GLOBALS['ansel_storage']->countGalleries($GLOBALS['registry']->getAuth(), + $gCnt = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), $perm, null, $this->_gallery, false); @@ -163,7 +163,7 @@ class Ansel_GalleryMode_Normal { */ function listImages($from = 0, $count = 0) { - return $GLOBALS['ansel_storage']->listImages($this->_gallery->id, $from, + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listImages($this->_gallery->id, $from, $count); } @@ -295,7 +295,7 @@ class Ansel_GalleryMode_Normal { */ function getImages($from = 0, $count = 0) { - $images = $GLOBALS['ansel_storage']->getImages(array('gallery_id' => $this->_gallery->id, + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('gallery_id' => $this->_gallery->id, 'count' => $count, 'from' => $from)); @@ -325,7 +325,7 @@ class Ansel_GalleryMode_Normal { { if ($subgalleries && $this->hasSubGalleries()) { $count = $this->countImages(false); - $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, false, $this->_gallery, true); diff --git a/ansel/lib/Image.php b/ansel/lib/Image.php index 99a6b4427..b27ce2b25 100644 --- a/ansel/lib/Image.php +++ b/ansel/lib/Image.php @@ -521,11 +521,11 @@ class Ansel_Image Implements Iterator /* Existing image, just save and exit */ if ($this->id) { /* Save image details */ - return $GLOBALS['ansel_storage']->saveImage($this); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->saveImage($this); } /* New image, need to save the image files, exif etc... */ - $GLOBALS['ansel_storage']->saveImage($this); + $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->saveImage($this); /* The EXIF functions require a stream, so we need to save before we read */ $this->_writeData(); @@ -553,7 +553,7 @@ class Ansel_Image Implements Iterator /* Save again if EXIF changed any values */ if (!empty($needUpdate)) { - $GLOBALS['ansel_storage']->saveImage($this); + $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->saveImage($this); } return $this->id; @@ -671,7 +671,7 @@ class Ansel_Image Implements Iterator /* Save attributes. */ foreach ($exif_fields as $name => $value) { - $GLOBALS['ansel_storage']->saveImageAttribute($this->id, $name, $value); + $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->saveImageAttribute($this->id, $name, $value); $this->_exif[$name] = Horde_Image_Exif::getHumanReadable($name, $value); } @@ -838,7 +838,7 @@ class Ansel_Image Implements Iterator { if ($view == 'full' && !$this->_dirty) { // Check full photo permissions - $gallery = $GLOBALS['ansel_storage']->getGallery($this->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->gallery); if ($gallery instanceof PEAR_Error) { throw new Ansel_Exception($gallery); } @@ -1116,12 +1116,10 @@ class Ansel_Image Implements Iterator */ public function getTags() { - global $ansel_storage; - if (count($this->_tags)) { return $this->_tags; } - $gallery = $ansel_storage->getGallery($this->gallery); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->gallery); if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { return Ansel_Tags::readTags($this->id); } else { @@ -1139,9 +1137,7 @@ class Ansel_Image Implements Iterator */ public function setTags($tags) { - global $ansel_storage; - - $gallery = $ansel_storage->getGallery(abs($this->gallery)); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($this->gallery)); if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { // Clear the local cache. $this->_tags = array(); @@ -1200,17 +1196,13 @@ class Ansel_Image Implements Iterator */ public function getViewHash($view, $style = null) { - global $ansel_storage; - // These views do not care about style...just return the $view value. - if ($view == 'screen' || $view == 'thumb' || $view == 'mini' || - $view == 'full') { - + if ($view == 'screen' || $view == 'thumb' || $view == 'mini' || $view == 'full') { return $view; } if (is_null($style)) { - $gallery = $ansel_storage->getGallery(abs($this->gallery)); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($this->gallery)); $style = $gallery->getStyle(); } else { $style = Ansel::getStyleDefinition($style); @@ -1230,7 +1222,7 @@ class Ansel_Image Implements Iterator */ public function getAttributes($format = false) { - $attributes = $GLOBALS['ansel_storage']->getImageAttributes($this->id); + $attributes = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageAttributes($this->id); $exif = Horde_Image_Exif::factory($GLOBALS['conf']['exif']['driver'], !empty($GLOBALS['conf']['exif']['params']) ? $GLOBALS['conf']['exif']['params'] : array()); $fields = Horde_Image_Exif::getFields($exif); $output = array(); diff --git a/ansel/lib/ImageView.php b/ansel/lib/ImageView.php index f77c6bd5f..ec89ab1a3 100644 --- a/ansel/lib/ImageView.php +++ b/ansel/lib/ImageView.php @@ -127,7 +127,7 @@ class Ansel_ImageView */ protected function _getGalleryWithImages($parent) { - $galleries = $GLOBALS['ansel_storage']->listGalleries( + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries( Horde_Perms::SHOW, null, $parent, false); foreach ($galleries as $gallery) { diff --git a/ansel/lib/ImageView/PolaroidThumb.php b/ansel/lib/ImageView/PolaroidThumb.php index a392d8b3a..07486ca48 100644 --- a/ansel/lib/ImageView/PolaroidThumb.php +++ b/ansel/lib/ImageView/PolaroidThumb.php @@ -23,7 +23,7 @@ class Ansel_ImageView_PolaroidThumb extends Ansel_ImageView (which will have a negative gallery_id). */ if ($this->_image->gallery > 0) { if (is_null($this->_style)) { - $gal = $GLOBALS['ansel_storage']->getGallery($this->_image->gallery); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery); $styleDef = $gal->getStyle(); } else { $styleDef = Ansel::getStyleDefinition($this->_style); diff --git a/ansel/lib/ImageView/PrettyThumb.php b/ansel/lib/ImageView/PrettyThumb.php index bbf8df934..58d2bc1f2 100644 --- a/ansel/lib/ImageView/PrettyThumb.php +++ b/ansel/lib/ImageView/PrettyThumb.php @@ -23,7 +23,7 @@ class Ansel_ImageView_PrettyThumb extends Ansel_ImageView * (which will have a negative gallery_id). */ if ($this->_image->gallery > 0) { if (is_null($this->_style)) { - $gal = $GLOBALS['ansel_storage']->getGallery($this->_image->gallery); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery); $styleDef = $gal->getStyle(); } else { $styleDef = Ansel::getStyleDefinition($this->_style); diff --git a/ansel/lib/ImageView/ShadowSharpThumb.php b/ansel/lib/ImageView/ShadowSharpThumb.php index 8929f411d..d5b396b72 100644 --- a/ansel/lib/ImageView/ShadowSharpThumb.php +++ b/ansel/lib/ImageView/ShadowSharpThumb.php @@ -23,7 +23,7 @@ class Ansel_ImageView_ShadowSharpThumb extends Ansel_ImageView * (which will have a negative gallery_id). */ if ($this->_image->gallery > 0) { if (is_null($this->_style)) { - $gal = $GLOBALS['ansel_storage']->getGallery($this->_image->gallery); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery); $styleDef = $gal->getStyle(); } else { $styleDef = Ansel::getStyleDefinition($this->_style); diff --git a/ansel/lib/Injector/Factory/Storage.php b/ansel/lib/Injector/Factory/Storage.php index 5f403ea28..ecc62c315 100644 --- a/ansel/lib/Injector/Factory/Storage.php +++ b/ansel/lib/Injector/Factory/Storage.php @@ -10,40 +10,36 @@ class Ansel_Injector_Factory_Storage { /** - * + * Depends on the Ansel_Scope value being available to the injector. * @var array */ private $_instances = array(); - /** - * @var Horde_Injector - */ - private $_injector; - /** * - * @param Horde_Injector $injector - * - * @return Horde_Injector_Factory_Storage + * @var Horde_Injector */ + private $_injector; + public function __construct(Horde_Injector $injector) { $this->_injector = $injector; } /** - * Obtain a Ansel_Storage object for the requested scope. + * Return an Ansel_Storage instance scoped for the current Ansel scope * * @param string $scope The application scope * * @return Ansel_Storage */ - public function getScope($scope = 'ansel') + public function getScope() { - if (!isset($this->_instances[$scope])) { + $scope = $this->_injector->getInstance('Ansel_Config')->get('scope'); + if (empty($this->_instances[$scope])) { $this->_instances[$scope] = new Ansel_Storage($this->_injector->getInstance('Horde_Share')->getScope($scope, 'Sql_Hierarchical')); } - + return $this->_instances[$scope]; } diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index a805d68c4..2fcc4513c 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -13,13 +13,6 @@ class Ansel_Storage { /** - * Scope for this storage object. - * - * @var string - */ - private $_scope = 'ansel'; - - /** * database handle * * @var MDB2 @@ -959,7 +952,7 @@ class Ansel_Storage $image = $this->getImage($id); $gallery_id = abs($image->gallery); if (empty($galleries[$gallery_id])) { - $galleries[$gallery_id]['gallery'] = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } // Any authentication that needs to take place for any of the diff --git a/ansel/lib/Tags.php b/ansel/lib/Tags.php index 7a187f15c..d7d727f93 100644 --- a/ansel/lib/Tags.php +++ b/ansel/lib/Tags.php @@ -217,8 +217,8 @@ class Ansel_Tags $imgs = array(); foreach ($images as $id) { try { - $img = $GLOBALS['ansel_storage']->getImage($id); - $gal = $GLOBALS['ansel_storage']->getGallery($img->gallery); + $img = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($img->gallery); $owner = $gal->get('owner'); if ($gal->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW) && (!isset($user) || (isset($user) && $owner && $owner == $user))) { @@ -250,7 +250,7 @@ class Ansel_Tags /* Check perms */ foreach ($galleries as $id) { try { - $gallery = $GLOBALS['ansel_storage']->getGallery($id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($id); } catch (Ansel_Exception $e) { Horde::logMessage($e->getMessage(), 'ERR'); continue; @@ -514,7 +514,7 @@ class Ansel_Tags_Search { $this->_owner); $galleries = array(); foreach ($gresults['galleries'] as $gallery) { - $galleries[] = $GLOBALS['ansel_storage']->getGallery($gallery); + $galleries[] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery); } /* Do we need to get images? */ @@ -527,7 +527,7 @@ class Ansel_Tags_Search { 'images', $this->_owner); - $images = count($iresults['images']) ? array_values($GLOBALS['ansel_storage']->getImages(array('ids' => $iresults['images']))) : array(); + $images = count($iresults['images']) ? array_values($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => $iresults['images']))) : array(); if (($conf['comments']['allow'] == 'all' || ($conf['comments']['allow'] == 'authenticated' && $GLOBALS['registry']->getAuth())) && $registry->hasMethod('forums/numMessagesBatch')) { diff --git a/ansel/lib/Tile/Image.php b/ansel/lib/Tile/Image.php index d6cb4fee8..9df76c93a 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['ansel_storage']->getGallery($image->gallery); + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->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 9424d9ae8..ad7ad53e9 100644 --- a/ansel/lib/View/Base.php +++ b/ansel/lib/View/Base.php @@ -137,9 +137,9 @@ abstract class Ansel_View_Base // If we have a slug, use it. if (!empty($slug)) { - $gallery = $GLOBALS['ansel_storage']->getGalleryBySlug($slug); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug); } else { - $gallery = $GLOBALS['ansel_storage']->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { throw new Horde_Exception(sprintf(_("Access denied to gallery \"%s\"."), $gallery->get('name'))); diff --git a/ansel/lib/View/Embedded.php b/ansel/lib/View/Embedded.php index 165269e3b..b193eed26 100644 --- a/ansel/lib/View/Embedded.php +++ b/ansel/lib/View/Embedded.php @@ -54,10 +54,9 @@ class Ansel_View_Embedded { */ function makeView($params) { - global $ansel_storage; - $view = new Ansel_View_Embedded(); $view->_params = $params; + return $view; } diff --git a/ansel/lib/View/EmbeddedRenderer/GalleryLink.php b/ansel/lib/View/EmbeddedRenderer/GalleryLink.php index 42d824ba9..f1ef3beee 100644 --- a/ansel/lib/View/EmbeddedRenderer/GalleryLink.php +++ b/ansel/lib/View/EmbeddedRenderer/GalleryLink.php @@ -30,8 +30,6 @@ class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Gallery */ public function html() { - /* Read in parameters and set defaults */ - /* Required */ $node = $this->_params['container']; if (empty($node)) { @@ -83,7 +81,7 @@ class Ansel_View_EmbeddedRenderer_GalleryLink extends Ansel_View_Gallery $images[] = $gallery->getDefaultImage($gallery_style); } } - $json = $GLOBALS['ansel_storage']->getImageJson($images, null, true, $thumbsize, true); + $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageJson($images, null, true, $thumbsize, true); /* Some paths */ $cssurl = Horde::url($GLOBALS['registry']->get('themesuri', 'ansel') . '/jsembed.css', true); diff --git a/ansel/lib/View/EmbeddedRenderer/Mini.php b/ansel/lib/View/EmbeddedRenderer/Mini.php index 2e7abc44d..3ecf6ee55 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['ansel_storage']->getImageJson($images, null, true, $thumbsize, true); - $json_full = $GLOBALS['ansel_storage']->getImageJson($images, null, true, 'screen', true); + $json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageJson($images, null, true, $thumbsize, true); + $json_full = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImageJson($images, null, true, 'screen', true); } /* Some paths */ diff --git a/ansel/lib/View/GalleryRenderer/Gallery.php b/ansel/lib/View/GalleryRenderer/Gallery.php index 724a933df..44465f962 100644 --- a/ansel/lib/View/GalleryRenderer/Gallery.php +++ b/ansel/lib/View/GalleryRenderer/Gallery.php @@ -42,8 +42,9 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base if (empty($this->view->api)) { $option_edit = $this->view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT); $option_select = $option_delete = $this->view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE); - $option_move = ($option_delete && $GLOBALS['ansel_storage']->countGalleries(Horde_Perms::EDIT)); - $option_copy = ($option_edit && $GLOBALS['ansel_storage']->countGalleries(Horde_Perms::EDIT)); + $option_move = ($option_delete && $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(Horde_Perms::EDIT)); + $option_copy = ($option_edit && $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(Horde_Perms::EDIT)); + /* See if we requested a show_actions change */ if (Horde_Util::getFormData('actionID', '') == 'show_actions') { $prefs->setValue('show_actions', (int)!$prefs->getValue('show_actions')); diff --git a/ansel/lib/View/GalleryRenderer/GalleryLightbox.php b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php index d241281a9..af5d565db 100644 --- a/ansel/lib/View/GalleryRenderer/GalleryLightbox.php +++ b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php @@ -66,8 +66,8 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende Horde_Perms::EDIT); $option_select = $option_delete = $this->view->gallery->hasPermission( $GLOBALS['registry']->getAuth(), Horde_Perms::DELETE); - $option_move = ($option_delete && $GLOBALS['ansel_storage']->countGalleries(Horde_Perms::EDIT)); - $option_copy = ($option_edit && $GLOBALS['ansel_storage']->countGalleries(Horde_Perms::EDIT)); + $option_move = ($option_delete && $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(Horde_Perms::EDIT)); + $option_copy = ($option_edit && $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(Horde_Perms::EDIT)); /* See if we requested a show_actions change (fallback for non-js) */ if (Horde_Util::getFormData('actionID', '') == 'show_actions') { $prefs->setValue('show_actions', (int)!$prefs->getValue('show_actions')); diff --git a/ansel/lib/View/Image.php b/ansel/lib/View/Image.php index 5cfffd898..5fd8cbec9 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['ansel_storage']->getImage($params['image_id']); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($params['image_id']); /* Get the Ansel_Gallery */ $this->gallery = $this->_getGallery(); diff --git a/ansel/lib/View/List.php b/ansel/lib/View/List.php index 188f0b5fd..bc0d4dfdb 100644 --- a/ansel/lib/View/List.php +++ b/ansel/lib/View/List.php @@ -43,13 +43,16 @@ class Ansel_View_List extends Ansel_View_Base */ public function __construct($params = array()) { - global $prefs, $ansel_storage; + global $prefs; parent::__construct($params); /* Notifications */ $notification = $GLOBALS['injector']->getInstance('Horde_Notification'); + /* Ansel_Storage */ + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope(); + // We'll need this in the template. $this->_sortBy = !empty($this->_params['sort']) ? $this->_params['sort'] : 'name'; $this->_sortDir = isset($this->_params['sort_dir']) ? $this->_params['sort_dir'] : 0; @@ -186,7 +189,7 @@ class Ansel_View_List extends Ansel_View_Base */ public function html() { - global $conf, $prefs, $registry, $ansel_storage; + global $conf, $prefs, $registry; $vars = Horde_Variables::getDefaultVariables(); if (!empty($this->_params['page'])) { diff --git a/ansel/lib/View/Results.php b/ansel/lib/View/Results.php index e9cf14ee4..18dc4e836 100644 --- a/ansel/lib/View/Results.php +++ b/ansel/lib/View/Results.php @@ -35,9 +35,10 @@ class Ansel_View_Results extends Ansel_View_Base */ public function __construct() { - global $prefs, $conf, $ansel_storage; + global $prefs, $conf; $notification = $GLOBALS['injector']->getInstance('Horde_Notification'); + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope(); $this->_owner = Horde_Util::getFormData('owner', null); $this->_search = Ansel_Tags::getSearch(null, $this->_owner); @@ -212,7 +213,10 @@ class Ansel_View_Results extends Ansel_View_Base */ public function html() { - global $conf, $prefs, $ansel_storage; + global $conf, $prefs; + + /* Ansel Storage*/ + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope(); // Get the slice of galleries/images to view on this page. $results = $this->_search->getSlice($this->_page, $this->_perPage); diff --git a/ansel/lib/Widget/Geotag.php b/ansel/lib/Widget/Geotag.php index d0df96c9f..ee3cfe799 100644 --- a/ansel/lib/Widget/Geotag.php +++ b/ansel/lib/Widget/Geotag.php @@ -65,13 +65,11 @@ class Ansel_Widget_Geotag extends Ansel_Widget_Base /** * Build the HTML for the widget * - * @TODO inject $ansel_storage * @return string */ public function html() { - global $ansel_storage; - + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope(); $geodata = $ansel_storage->getImagesGeodata($this->_params['images']); $url = Horde::applicationUrl('map_edit.php', true); $rtext = _("Relocate this image"); @@ -262,7 +260,7 @@ EOT; */ protected function _getGalleryImagesWithGeodata() { - return $GLOBALS['ansel_storage']->getImagesGeodata(array(), $this->_view->gallery->id); + return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImagesGeodata(array(), $this->_view->gallery->id); } /** diff --git a/ansel/lib/Widget/OtherGalleries.php b/ansel/lib/Widget/OtherGalleries.php index a101ee111..2305df481 100644 --- a/ansel/lib/Widget/OtherGalleries.php +++ b/ansel/lib/Widget/OtherGalleries.php @@ -64,7 +64,7 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base $tree->setOption(array('class' => 'anselWidgets')); try { - $gals = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, $owner, + $gals = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, $owner, null, true, 0, 0, 'name', 0); } catch (Ansel_Exception $e) { diff --git a/ansel/lib/Widget/OwnerFaces.php b/ansel/lib/Widget/OwnerFaces.php index bd1f6e783..d04420871 100644 --- a/ansel/lib/Widget/OwnerFaces.php +++ b/ansel/lib/Widget/OwnerFaces.php @@ -28,7 +28,7 @@ class Ansel_Widget_OwnerFaces extends Ansel_Widget_Base try { $this->_count = $this->_faces->countOwnerFaces($this->_owner); } catch (Horde_Exception $e) { - Horde::logMessage($e->getMessage, 'ERR'); + Horde::logMessage($e->getMessage(), 'ERR'); $this->_count = 0; } if (empty($this->_count)) { diff --git a/ansel/lib/Widget/SimilarPhotos.php b/ansel/lib/Widget/SimilarPhotos.php index b6b4a38b9..08637800a 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() { - global $ansel_storage; + $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope(); $html = ''; $tags = array_values($this->_view->resource->getTags()); diff --git a/ansel/map_edit.php b/ansel/map_edit.php index 15e7afe0a..9e4806d02 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)) { Horde::fatal(_("An error has occured retrieving the image. Details have been logged."), __FILE__, __LINE__, true); } -$image = $ansel_storage->getImage($image_id); -$gallery = $ansel_storage->getGallery($image->gallery); +$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); +$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { throw new Horde_Exception_PermissionDenied(_("Not Authorized. Details have been logged for the server administrator.")); } @@ -72,7 +72,7 @@ $gtUrl = $gt->getUrl(); $loadingImg = Horde::img('loading.gif', _("Loading...")); /* Obtain other geotagged images to possibly locate this image at */ -$imgs = $GLOBALS['ansel_storage']->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); +$imgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); if (count($imgs) > 0) { $other_images = '
' . _("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 62c0121ad..22aca8d51 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 = $ansel_storage->getGallery(Horde_Util::getFormData('cid')); + $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(Horde_Util::getFormData('cid')); $form = 'edit.inc'; $perm = &$share->getPermission(); } catch (Horde_Share_Exception $e) { if (($share_name = Horde_Util::getFormData('share')) !== null) { try { - $share = $ansel_storage->shares->getShare($share_name); + $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->shares->getShare($share_name); $form = 'edit.inc'; $perm = $share->getPermission(); } catch (Horde_Share_Exception $e) { @@ -51,7 +51,7 @@ case 'edit': case 'editform': case 'editforminherit': try { - $share = &$ansel_storage->getGallery(Horde_Util::getFormData('cid')); + $share = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(Horde_Util::getFormData('cid')); } catch (Horde_Share_Exception $e) { $notification->push(_("Attempt to edit a non-existent share."), 'horde.error'); } @@ -250,7 +250,7 @@ case 'editforminherit': if (empty($share)) { $title = _("Edit Permissions"); } else { - $children = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::READ, false, $share); + $children = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::READ, false, $share); $title = sprintf(_("Edit Permissions for %s"), $share->get('name')); } diff --git a/ansel/preview.php b/ansel/preview.php index 99ff408d3..36eeb7220 100644 --- a/ansel/preview.php +++ b/ansel/preview.php @@ -13,8 +13,8 @@ Horde_Registry::appInit('ansel'); $imageId = Horde_Util::getFormData('image'); try { - $image = $ansel_storage->getImage($imageId); - $gal = $ansel_storage->getGallery(abs($image->gallery)); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($imageId); + $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(abs($image->gallery)); $img = Ansel::getImageUrl($imageId, 'thumb', false); } catch (Ansel_Exception $e) { Horde::logMessage($e->getMessage(), 'ERR'); diff --git a/ansel/protect.php b/ansel/protect.php index 8509b570b..e8a98c000 100644 --- a/ansel/protect.php +++ b/ansel/protect.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('ansel'); $vars = Horde_Variables::getDefaultVariables(); try { - $gallery = $ansel_storage->getGallery($vars->get('gallery')); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($vars->get('gallery')); } catch (Ansel_Exception $e) { $notification->push($e->getMessage()); header('Location: ' . Horde::applicationUrl('list.php')); diff --git a/ansel/report.php b/ansel/report.php index 7f24641fe..205ba3ad6 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 = $ansel_storage->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage()); header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); diff --git a/ansel/rss.php b/ansel/rss.php index 98ab659c9..332568177 100644 --- a/ansel/rss.php +++ b/ansel/rss.php @@ -41,7 +41,7 @@ if (empty($rss)) { switch ($stream_type) { case 'all': try { - $images = $ansel_storage->getRecentImages(); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages(); } catch (Ansel_Exception $e) { $images = array(); } @@ -73,22 +73,22 @@ if (empty($rss)) { // Retrieve latest from specified gallery // Try a slug first. if ($slug) { - $gallery = $ansel_storage->getGalleryBySlug($slug); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug); } elseif (is_numeric($id)) { - $gallery = $ansel_storage->getGallery($id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($id); } if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW) && !$gallery->hasPasswd() && $gallery->isOldEnough()) { if (!$gallery->countImages() && $gallery->hasSubGalleries()) { - $subgalleries = $ansel_storage->listGalleries(Horde_Perms::SHOW, + $subgalleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $gallery); $subs = array(); foreach ($subgalleries as $subgallery) { $subs[] = $subgallery->id; } - $images = $ansel_storage->getRecentImages($subs); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($subs); } else { $images = $gallery->getRecentImages(); $owner = &$gallery->getOwner(); @@ -104,7 +104,7 @@ if (empty($rss)) { array('view' => 'Gallery', 'gallery' => $id), true); - $img = &$ansel_storage->getImage($gallery->getDefaultImage('ansel_default')); + $img = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($gallery->getDefaultImage('ansel_default')); $params = array('last_modified' => $gallery->get('last_modified'), 'name' => sprintf(_("%s on %s"), $gallery->get('name'), @@ -125,7 +125,7 @@ if (empty($rss)) { case 'user': $galleries = array(); try { - $shares = $ansel_storage->listGalleries(Horde_Perms::SHOW, $id); + $shares = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, $id); foreach ($shares as $gallery) { if ($gallery->isOldEnough() && !$gallery->hasPasswd()) { $galleries[] = $gallery->id; @@ -137,7 +137,7 @@ if (empty($rss)) { $images = array(); if (isset($galleries) && count($galleries)) { try { - $images = $ansel_storage->getRecentImages($galleries); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages($galleries); } catch (Ansel_Exception $e) { Horde::logMessage($e->getMessage(), 'ERR'); } @@ -176,7 +176,7 @@ if (empty($rss)) { $images = Ansel_Tags::searchTagsById($tag_id, 10, 0, 'images'); $tag_id = array_pop($tag_id); try { - $images = $ansel_storage->getImages(array('ids' => $images['images'])); + $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => $images['images'])); } catch (Ansel_Exception $e) { Horde::logMessage($e->getMessage(), 'ERR'); $images = array(); @@ -213,7 +213,7 @@ if (empty($rss)) { $gallery_id = $images[$i]->gallery; if (empty($galleries[$gallery_id])) { try { - $galleries[$gallery_id]['gallery'] = $GLOBALS['ansel_storage']->getGallery($gallery_id); + $galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) {} } if (!isset($galleries[$gallery_id]['perm'])) { diff --git a/ansel/scripts/all_images_exif_to_tags.php b/ansel/scripts/all_images_exif_to_tags.php index 78ce05eeb..53391f566 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 = $ansel_storage->getImage($image_id['image_id']); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id['image_id']); $results = $image->exifToTags($exif_fields); $cli->message(sprintf(_("Extracted exif fields from %s"), $image->filename), 'cli.success'); } diff --git a/ansel/scripts/ansel.php b/ansel/scripts/ansel.php index 9a941c473..4e53cca2d 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 (!$ansel_storage->galleryExists($galleryId)) { + if (!$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) { $error = sprintf(_("Invalid gallery \"%s\" specified."), $galleryId); Horde::logMessage($error, 'WARN'); $cli->fatal($error); } else { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $error = sprintf(_("Access denied adding photos to \"%s\"."), $galleryId); Horde::logMessage($error, 'WARN'); @@ -128,7 +128,7 @@ if (!empty($createGallery)) { 'desc' => $gallery_desc, 'owner' => $gallery_owner); try { - $gallery = $ansel_storage->createGallery($attributes, null, $parent); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery($attributes, null, $parent); } catch (Ansel_Exception $e) { $galleryId = null; $error = sprintf(_("The gallery \"%s\" couldn't be created: %s"), @@ -150,11 +150,11 @@ if (!empty($list)) { $images = array_keys($images); foreach ($images as $id) { - $image = $ansel_storage->getImage($id); + $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id); $cli->writeln(str_pad($image->filename, 30) . $image->getVFSPath() . '/' . $id); } } else { - $galleries = $GLOBALS['ansel_storage']->listGalleries(); + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(); $cli->message(_("Listing Gallery/Name"), 'cli.success'); $cli->writeln(); foreach ($galleries as $id => $gallery) { diff --git a/ansel/scripts/recursive_import.php b/ansel/scripts/recursive_import.php index 6a74238d8..a1e262193 100755 --- a/ansel/scripts/recursive_import.php +++ b/ansel/scripts/recursive_import.php @@ -78,7 +78,7 @@ if (empty($dir)) { Horde_Nls::setCharset('utf-8'); $gallery_id = processDirectory($dir); if (!$keepEmpties) { - $gallery = $ansel_storage->getGallery($gallery_id); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); emptyGalleryCheck($gallery); } exit; @@ -91,20 +91,20 @@ exit; function emptyGalleryCheck($gallery) { if ($gallery->hasSubGalleries()) { - $children = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $gallery, false); + $children = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $gallery, false); foreach ($children as $child) { // First check all children to see if they are empty... emptyGalleryCheck($child); if (!$child->countImages() && !$child->hasSubGalleries()) { - $result = $GLOBALS['ansel_storage']->removeGallery($child); + $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($child); $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $child->get('name')), 'cli.success'); } // Refresh the gallery values since we mucked around a bit with it - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery->getId()); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery->getId()); // Now that any empty children are removed, see if we are empty if (!$gallery->countImages() && !$gallery->hasSubGalleries()) { - $result = $GLOBALS['ansel_storage']->removeGallery($gallery); + $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery); $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $gallery->get('name')), 'cli.success'); } } @@ -131,7 +131,7 @@ function processDirectory($dir, $parent = null) // Create a gallery for this directory level. $name = basename($dir); $cli->message(sprintf(_("Creating gallery: \"%s\""), $name), 'cli.message'); - $gallery = $GLOBALS['ansel_storage']->createGallery(array('name' => $name), null, $parent); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery(array('name' => $name), null, $parent); $cli->message(sprintf(_("The gallery \"%s\" was created successfully."), $name), 'cli.success'); // Read all the files into an array. diff --git a/ansel/scripts/remote_import.php b/ansel/scripts/remote_import.php index ef32cd0f6..018716f67 100755 --- a/ansel/scripts/remote_import.php +++ b/ansel/scripts/remote_import.php @@ -114,20 +114,20 @@ processDirectory($dir, null, $gallery_id, $gallery_slug, $useCompression); function emptyGalleryCheck($gallery) { if ($gallery->hasSubGalleries()) { - $children = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, $gallery, false); + $children = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, null, $gallery, false); foreach ($children as $child) { // First check all children to see if they are empty... emptyGalleryCheck($child); if (!$child->countImages() && !$child->hasSubGalleries()) { - $result = $GLOBALS['ansel_storage']->removeGallery($child); + $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($child); $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $child->get('name')), 'cli.success'); } // Refresh the gallery values since we mucked around a bit with it - $gallery = $GLOBALS['ansel_storage']->getGallery($gallery->getId()); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery->getId()); // Now that any empty children are removed, see if we are empty if (!$gallery->countImages() && !$gallery->hasSubGalleries()) { - $result = $GLOBALS['ansel_storage']->removeGallery($gallery); + $result = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery); $GLOBALS['cli']->message(sprintf(_("Deleting empty gallery, \"%s\""), $gallery->get('name')), 'cli.success'); } } diff --git a/ansel/templates/gallery/delete_confirmation.inc b/ansel/templates/gallery/delete_confirmation.inc index 8fd773729..dbfd99a60 100644 --- a/ansel/templates/gallery/delete_confirmation.inc +++ b/ansel/templates/gallery/delete_confirmation.inc @@ -1,5 +1,5 @@

- getGallery($galleryId); + getInstance('Ansel_Storage')->getScope()->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/category.inc b/ansel/templates/group/category.inc index 0308fd2df..927380a64 100644 --- a/ansel/templates/group/category.inc +++ b/ansel/templates/group/category.inc @@ -1,6 +1,6 @@ countGalleries( +$num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries( $GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, array('category' => $group), null, false); if (empty($group)) { @@ -20,10 +20,10 @@ $link = Horde::link($viewurl, $category_title, 'light'); $preview_gallery = array(); if ($num_galleries < 5) { - $preview_gallery = $GLOBALS['ansel_storage']->listGalleries( + $preview_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries( Horde_Perms::SHOW, array('category' => $group), null, false); } else { - $preview_gallery = $GLOBALS['ansel_storage']->listGalleries( + $preview_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries( Horde_Perms::SHOW, array('category' => $group), null, false, rand(0, $num_galleries - 4), 4); } diff --git a/ansel/templates/group/owner.inc b/ansel/templates/group/owner.inc index aebc26595..dbc3b53b4 100644 --- a/ansel/templates/group/owner.inc +++ b/ansel/templates/group/owner.inc @@ -25,13 +25,13 @@ $link = Horde::link(Ansel::getUrlFor('view', array('groupby' => $groupby, 'owner' => $group, 'view' => 'List'))); -$num_galleries = $ansel_storage->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, +$num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, $group, null, false); if ($num_galleries < 5) { - $mini_galleries = $ansel_storage->listGalleries(Horde_Perms::SHOW, + $mini_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(Horde_Perms::SHOW, $group, null, false); } else { - $mini_galleries = $GLOBALS['ansel_storage']->listGalleries( + $mini_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries( Horde_Perms::SHOW, $group, null, false, rand(0, $num_galleries - 4), 4); } $mini_galleries = array_values($mini_galleries); diff --git a/ansel/xppublish.php b/ansel/xppublish.php index c4d424873..7bc9a5a8f 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 || !$ansel_storage->galleryExists($galleryId)) { + if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) { $error = _("Invalid gallery specified.") . "
\n"; } else { try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); $error = false; } catch (Ansel_Exception $e) { $error = _("There was an error accessing the gallery"); @@ -114,7 +114,7 @@ if ($cmd == 'new') { if ($create) { /* Creating a new gallery. */ try { - $gallery = $ansel_storage->createGallery( + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery( array('name' => $gallery_name, 'desc' => $gallery_desc)); $galleryId = $gallery->id; $msg = sprintf(_("The gallery \"%s\" was created successfully."), $gallery_name); @@ -166,11 +166,11 @@ if ($cmd == 'add') { $galleryId = Horde_Util::getFormData('gallery'); $name = isset($_FILES['imagefile']['name']) ? Horde_Util::dispelMagicQuotes($_FILES['imagefile']['name']) : null; $file = isset($_FILES['imagefile']['tmp_name']) ? $_FILES['imagefile']['tmp_name'] : null; - if (!$galleryId || !$ansel_storage->galleryExists($galleryId)) { + if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) { $error = _("Invalid gallery specified.") . "
\n"; } else { try { - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $error = sprintf(_("Access denied adding photos to \"%s\"."), $gallery->get('name')); } else { @@ -191,7 +191,7 @@ if ($cmd == 'add') { $error = $e->getMessage(); } - $gallery = $ansel_storage->getGallery($galleryId); + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); try { $image_id = $gallery->addImage($image); $error = false;