From 19e941787b5bd7251d6f36c249a447e473e7c283 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 16 Feb 2010 11:56:05 -0500 Subject: [PATCH] Use injector to get notification object --- ansel/lib/View/Image.php | 2 +- ansel/lib/View/List.php | 7 +++++-- ansel/lib/View/Results.php | 27 ++++++++++++--------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ansel/lib/View/Image.php b/ansel/lib/View/Image.php index b552f564f..976b7defd 100644 --- a/ansel/lib/View/Image.php +++ b/ansel/lib/View/Image.php @@ -30,7 +30,7 @@ class Ansel_View_Image extends Ansel_View_Base public function __construct($params = array()) { parent::__construct($params); - + /* Get the Ansel_Image */ $image = &$GLOBALS['ansel_storage']->getImage($params['image_id']); diff --git a/ansel/lib/View/List.php b/ansel/lib/View/List.php index 55a27c384..459b5c4ca 100644 --- a/ansel/lib/View/List.php +++ b/ansel/lib/View/List.php @@ -43,10 +43,13 @@ class Ansel_View_List extends Ansel_View_Base */ public function __construct($params = array()) { - global $prefs, $ansel_storage, $notification; + global $prefs, $ansel_storage; parent::__construct($params); + /* Notifications */ + $notification = $GLOBALS['injector']->getInstance('Horde_Notification'); + // We'll need this in the template. $this->_sortBy = !empty($this->_params['sort']) ? $this->_params['sort'] : 'name'; $this->_sortDir = isset($this->_params['sort_dir']) ? $this->_params['sort_dir'] : 0; @@ -186,7 +189,7 @@ class Ansel_View_List extends Ansel_View_Base */ public function html() { - global $conf, $prefs, $registry, $ansel_storage, $notification; + global $conf, $prefs, $registry, $ansel_storage; $vars = Horde_Variables::getDefaultVariables(); if (!empty($this->_params['page'])) { diff --git a/ansel/lib/View/Results.php b/ansel/lib/View/Results.php index 1567d52b1..2e78fe2c3 100644 --- a/ansel/lib/View/Results.php +++ b/ansel/lib/View/Results.php @@ -34,6 +34,8 @@ class Ansel_View_Results extends Ansel_View_Base { global $prefs, $conf, $ansel_storage; + $notification = $GLOBALS['injector']->getInstance('Horde_Notification'); + $this->_owner = Horde_Util::getFormData('owner', null); $this->_search = Ansel_Tags::getSearch(null, $this->_owner); $this->_page = Horde_Util::getFormData('page', 0); @@ -61,18 +63,16 @@ class Ansel_View_Results extends Ansel_View_Base $img = $ansel_storage->getImage($image); $gallery = $ansel_storage->getgallery($img->gallery); if (!$gallery->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE)) { - $GLOBALS['notification']->push( + $notification->push( sprintf(_("Access denied deleting photos from \"%s\"."), $image), 'horde.error'); } else { $result = $gallery->removeImage($image); if (is_a($result, 'PEAR_Error')) { - $GLOBALS['notification']->push( - sprintf(_("There was a problem deleting photos: %s"), - $result->getMessage()), 'horde.error'); + $notification->push( + sprintf(_("There was a problem deleting photos: %s"), $result->getMessage()), 'horde.error'); } else { - $GLOBALS['notification']->push(_("Deleted the photo."), - 'horde.success'); + $notification->push(_("Deleted the photo."), 'horde.success'); Ansel_Tags::clearCache(); } } @@ -97,8 +97,7 @@ class Ansel_View_Results extends Ansel_View_Base if ($images && $newGallery) { $newGallery = $ansel_storage->getGallery($newGallery); if (is_a($newGallery, 'PEAR_Error')) { - $GLOBALS['notification']->push(_("Bad input."), - 'horde.error'); + $notification->push(_("Bad input."), 'horde.error'); } else { // Group by gallery first, then process in bulk by gallery. $galleries = array(); @@ -110,9 +109,9 @@ class Ansel_View_Results extends Ansel_View_Base $gallery = $ansel_storage->getGallery($gallery_id); $result = $gallery->moveImagesTo($images, $newGallery); if (is_a($result, 'PEAR_Error')) { - $GLOBALS['notification']->push($result, 'horde.error'); + $notification->push($result, 'horde.error'); } else { - $GLOBALS['notification']->push( + $notification->push( sprintf(ngettext("Moved %d photo from \"%s\" to \"%s\"", "Moved %d photos from \"%s\" to \"%s\"", count($images)), @@ -145,8 +144,7 @@ class Ansel_View_Results extends Ansel_View_Base if ($images && $newGallery) { $newGallery = $ansel_storage->getGallery($newGallery); if (is_a($newGallery, 'PEAR_Error')) { - $GLOBALS['notification']->push(_("Bad input."), - 'horde.error'); + $notification->push(_("Bad input."), 'horde.error'); } else { // Group by gallery first, then process in bulk by gallery. $galleries = array(); @@ -158,10 +156,9 @@ class Ansel_View_Results extends Ansel_View_Base $gallery = $ansel_storage->getGallery($gallery_id); $result = $gallery->copyImagesTo($images, $newGallery); if (is_a($result, 'PEAR_Error')) { - $GLOBALS['notification']->push($result, - 'horde.error'); + $notification->push($result, 'horde.error'); } else { - $GLOBALS['notification']->push( + $notification->push( sprintf(ngettext("Copied %d photo from %s to %s", "Copied %d photos from %s to %s", count($images)), -- 2.11.0