$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));
/* 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(
$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;
}
foreach ($keys as $key) {
$html .= '<img src="' . Ansel::getImageUrl($key, 'mini', false) . '" style="margin:2px;" alt="[thumbnail]" />';
}
-$image = $ansel_storage->getImage(array_pop($keys));
+$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage(array_pop($keys));
/* Display the form */
$vars->set('image', $images);
$vars->set('gallery', $gallery_id);
$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'),
$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)));
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)));
// 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);
$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.');
}
} 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'),
// 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));
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)) {
$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');
$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 {
}
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;
}
// 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)));
$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,
$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';
// 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));
// 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));
// 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));
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));
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.
$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');
$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: '
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));
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 {
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,
/* 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));
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;
}
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',
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');
} 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')));
}
/* 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);
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');
'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));
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));
$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);
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);
$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\"",
$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",
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()) {
$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);
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();
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__);
}
}
/* 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')) {
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."));
}
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."));
}
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."));
}
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."));
}
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."));
}
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."));
}
$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));
$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');
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();
}
/* 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;
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 {
// 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);
}
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.');
}
}
$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');
}
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);
}
// 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);
}
// Now get the "add geotag" stuff
$addurl = Horde::applicationUrl('map_edit.php')->add('image', $img);
$addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::applicationUrl('map_edit.php'), array('params' => array('image' => $img), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;'));
- $imgs = $GLOBALS['ansel_storage']->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
+ $imgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
if (count($imgs) > 0) {
$imgsrc = '<div class="ansel_location_sameas">';
foreach ($imgs as $id => $data) {
/* 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 {
$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);
}
return array();
}
try {
- $locs = $GLOBALS['ansel_storage']->searchLocations($input);
+ $locs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->searchLocations($input);
if (!count($locs)) {
$locs = new StdClass();
}
/* 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) {
$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)) {
// 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);
*/
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
// 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);
*/
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');
$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;
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;
}
}
}
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,
}
$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\"."));
}
}
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) {
$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."));
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')));
);
}
- 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
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')));
}
}
if (!is_null($app)) {
- $GLOBALS['ansel_storage'] = new Ansel_Storage($app);
+ $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $app);
}
if (!empty($perm)) {
$permobj = null;
}
- $gallery = $GLOBALS['ansel_storage']->createGallery($attributes, $permobj, $parent);
+ $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery($attributes, $permobj, $parent);
return $gallery->id;
}
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 {
}
}
- return $GLOBALS['ansel_storage']->removeGallery($gallery);
+ return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->removeGallery($gallery);
}
}
*/
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) {
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);
*
* @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);
$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()) {
/* 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();
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
$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);
}
/**
$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();
}
$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();
$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;
$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;
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);
}
*/
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 */
$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',
'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'));
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);
}
/**
*
* @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;
*
* Global variables defined:
* $ansel_db - TODO
- * $ansel_storage - TODO
*
* @throws Horde_Exception
*/
}
$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);
// 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'));
'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');
}
}
// 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
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);
function _content()
{
- $gallery = $GLOBALS['ansel_storage']->getRandomGallery();
+ $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery();
if (!$gallery) {
return _("There are no photo galleries available.");
}
'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');
}
}
function _content()
{
- global $registry, $ansel_storage;
+ global $registry;
if ($this->_params['gallery'] == 'all') {
$threads = $registry->call('forums/list', array(0, 'ansel'));
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),
// 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)) {
'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');
}
// 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();
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()) {
/* 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)) {
'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');
}
}
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()) {
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)) {
--- /dev/null
+<?php
+/**
+ * Utility class for specifying scope-specific ansel configuration.
+ *
+ */
+class Ansel_Config
+{
+ protected $_config = array();
+
+ /**
+ * Const'r - set the default scope to ansel.
+ *
+ */
+ public function __construct()
+ {
+ $this->_config['scope'] = 'ansel';
+ }
+
+ public function set($config, $value)
+ {
+ $this->_config[$config] = $value;
+ }
+
+ public function get($config)
+ {
+ if (!isset($this->_config[$config])) {
+ throw InvalidArgumentException($config . _(" not found"));
+ }
+ return $this->_config[$config];
+ }
+
+}
\ No newline at end of file
// 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, '
{
// 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, '
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(
*/
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.');
}
{
// 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.');
}
*/
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')));
}
{
/* 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);
}
}
// 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."),
}
} 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;
/* 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++);
*/
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);
}
*/
public function &getImage($id)
{
- return $GLOBALS['ansel_storage']->getImage($id);
+ return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
}
/**
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;
}
{
/* 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 */
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);
}
{
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);
}
}
*/
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];
}
*/
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;
{
/* 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. */
$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;
*/
function getRecentImages($limit = 10)
{
- return $GLOBALS['ansel_storage']->getRecentImages(array($this->id),
+ return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages(array($this->id),
$limit);
}
*/
function &getImage($id)
{
- return $GLOBALS['ansel_storage']->getImage($id);
+ return $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($id);
}
/**
/* 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);
}
}
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);
*/
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);
}
*/
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));
{
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);
/* 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();
/* 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;
/* 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);
}
{
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);
}
*/
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 {
*/
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();
*/
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);
*/
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();
*/
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) {
(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);
* (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);
* (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);
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];
}
class Ansel_Storage
{
/**
- * Scope for this storage object.
- *
- * @var string
- */
- private $_scope = 'ansel';
-
- /**
* database handle
*
* @var MDB2
$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
$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))) {
/* 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;
$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? */
'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')) {
{
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();
}
// 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')));
*/
function makeView($params)
{
- global $ansel_storage;
-
$view = new Ansel_View_Embedded();
$view->_params = $params;
+
return $view;
}
*/
public function html()
{
- /* Read in parameters and set defaults */
-
/* Required */
$node = $this->_params['container'];
if (empty($node)) {
$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);
'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 */
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'));
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'));
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();
*/
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;
*/
public function html()
{
- global $conf, $prefs, $registry, $ansel_storage;
+ global $conf, $prefs, $registry;
$vars = Horde_Variables::getDefaultVariables();
if (!empty($this->_params['page'])) {
*/
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);
*/
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);
/**
* 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");
*/
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);
}
/**
$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) {
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)) {
*/
public function _getRelatedImages()
{
- global $ansel_storage;
+ $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope();
$html = '';
$tags = array_values($this->_view->resource->getTags());
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."));
}
$loadingImg = Horde::img('loading.gif', _("Loading..."));
/* Obtain other geotagged images to possibly locate this image at */
-$imgs = $GLOBALS['ansel_storage']->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
+$imgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata($GLOBALS['registry']->getAuth());
if (count($imgs) > 0) {
$other_images = '<div class="ansel_location_sameas">' . _("Click on a thumbnail to locate at the same point.") . '<br />';
foreach ($imgs as $id => $data) {
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) {
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');
}
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'));
}
$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');
$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'));
$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));
switch ($stream_type) {
case 'all':
try {
- $images = $ansel_storage->getRecentImages();
+ $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImages();
} catch (Ansel_Exception $e) {
$images = array();
}
// 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();
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'),
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;
$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');
}
$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();
$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'])) {
$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');
}
// 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');
'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"),
$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) {
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;
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');
}
}
// 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.
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');
}
}
<h1 class="header">
- <?php $gallery = $ansel_storage->getGallery($galleryId);
+ <?php $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
printf($actionID == 'delete' ? _("Really delete %s and all of its subgalleries?") : _("Really empty %s?"), htmlspecialchars($gallery->get('name')))
?>
</h1>
<?php
-$num_galleries = $GLOBALS['ansel_storage']->countGalleries(
+$num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries(
$GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, array('category' => $group), null, false);
if (empty($group)) {
$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);
}
'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);
// Check if a gallery was selected from the list.
if ($cmd == 'select') {
- if (!$galleryId || !$ansel_storage->galleryExists($galleryId)) {
+ if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) {
$error = _("Invalid gallery specified.") . "<br />\n";
} else {
try {
- $gallery = $ansel_storage->getGallery($galleryId);
+ $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
$error = false;
} catch (Ansel_Exception $e) {
$error = _("There was an error accessing the gallery");
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);
$galleryId = Horde_Util::getFormData('gallery');
$name = isset($_FILES['imagefile']['name']) ? Horde_Util::dispelMagicQuotes($_FILES['imagefile']['name']) : null;
$file = isset($_FILES['imagefile']['tmp_name']) ? $_FILES['imagefile']['tmp_name'] : null;
- if (!$galleryId || !$ansel_storage->galleryExists($galleryId)) {
+ if (!$galleryId || !$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) {
$error = _("Invalid gallery specified.") . "<br />\n";
} else {
try {
- $gallery = $ansel_storage->getGallery($galleryId);
+ $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
$error = sprintf(_("Access denied adding photos to \"%s\"."), $gallery->get('name'));
} else {
$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;