From: Michael J. Rubinsky Date: Tue, 14 Sep 2010 15:10:07 +0000 (-0400) Subject: Move gallery property page to an Ansel_View. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5e4cc535f3399360b1fbb7bdc3d20d5fb7891d11;p=horde.git Move gallery property page to an Ansel_View. Also, start moving style information to be stored as a serialized array within the gallery object. An empty style would mean to use the user preference for default style. Gallery property page will implement showing/editing style properties shortly. --- diff --git a/ansel/gallery.php b/ansel/gallery.php index 6cc9a1c29..8c151de8e 100644 --- a/ansel/gallery.php +++ b/ansel/gallery.php @@ -6,6 +6,8 @@ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. * * @author Chuck Hagenbuch + * @author Michael J. Rubinsky + * @package Ansel */ require_once dirname(__FILE__) . '/lib/Application.php'; @@ -18,67 +20,16 @@ if (is_null($actionID)) { exit; } -// Run through the action handlers. switch ($actionID) { case 'add': - // Set up the gallery attributes. - $gallery_name = ''; - $gallery_desc = ''; - $gallery_tags = ''; - $gallery_thumbstyle = ''; - $gallery_slug = ''; - $gallery_age = 0; - $gallery_download = $prefs->getValue('default_download'); - $gallery_parent = null; - $galleryId = null; - $gallery_mode = 'Normal'; - $gallery_passwd = ''; - - Horde::addInlineScript(array( - '$("gallery_name").focus()' - ), 'dom'); - - $title = _("Adding A New Gallery"); - break; - case 'addchild': - // Get the parent and make sure that it exists and that we have - // permissions to add to it. - $parentId = Horde_Util::getFormData('gallery'); - try { - $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($parentId); - } catch (Ansel_Exception $e) { - $notification->push($e->getMessage(), 'horde.error'); - Horde::url('view.php?view=List', true)->redirect(); - exit; - } - - if (!$parent->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { - $notification->push(sprintf(_("Access denied adding a gallery to \"%s\"."), - $parent->get('name')), 'horde.error'); - Horde::url('view.php?view=List', true)->redirect(); - exit; - } - - // Set up the gallery attributes. - $gallery_name = ''; - $gallery_desc = ''; - $gallery_tags = ''; - $gallery_slug = ''; - $gallery_age = 0; - $gallery_thumbstyle = $parent->get('style'); - $gallery_download = $prefs->getValue('default_download'); - $gallery_parent = $parentId; - $galleryId = null; - $gallery_mode = 'Normal'; - $gallery_passwd = ''; - - Horde::addInlineScript(array( - '$("gallery_name").focus()' - ), 'dom'); - - $title = sprintf(_("Adding A Subgallery to %s"), $parent->get('name')); - break; +case 'save': +case 'modify': + $view = new Ansel_View_GalleryProperties(array('actionID' => $actionID, + 'url' => new Horde_Url(Horde_Util::getFormData('url')), + 'gallery' => Horde_Util::getFormData('gallery'))); + $view->run(); + exit; case 'downloadzip': $galleryId = Horde_Util::getFormData('gallery'); @@ -94,191 +45,6 @@ case 'downloadzip': Ansel::downloadImagesAsZip($gallery); exit; -case 'modify': - $galleryId = Horde_Util::getFormData('gallery'); - - try { - $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_tags = implode(',', $gallery->getTags()); - $gallery_thumbstyle = $gallery->get('style'); - $gallery_slug = $gallery->get('slug'); - $gallery_age = (int)$gallery->get('age'); - $gallery_download = $gallery->get('download'); - $title = sprintf(_("Modifying: %s"), $gallery_name); - $gallery_parent = $gallery->getParent(); - if (!is_null($gallery_parent)) { - $gallery_parent = $gallery_parent->getId(); - } - $gallery_mode = $gallery->get('view_mode'); - $gallery_passwd = $gallery->get('passwd'); - } catch (Ansel_Exception $e) { - $title = _("Unknown Gallery"); - } - - break; - -case 'save': - // Check general permissions. - if (!$registry->isAdmin() && - ($injector->getInstance('Horde_Perms')->exists('ansel') && - !$injector->getInstance('Horde_Perms')->hasPermission('ansel', $registry->getAuth(), Horde_Perms::EDIT))) { - $notification->push(_("Access denied editing galleries."), 'horde.error'); - Horde::url('view.php?view=List', true)->redirect(); - exit; - } - - // Get the form values. - $galleryId = Horde_Util::getFormData('gallery'); - $gallery_name = Horde_Util::getFormData('gallery_name'); - $gallery_desc = Horde_Util::getFormData('gallery_desc'); - $gallery_slug = Horde_Util::getFormData('gallery_slug'); - $gallery_age = (int)Horde_Util::getFormData('gallery_age', 0); - $gallery_download = Horde_Util::getFormData('gallery_download'); - $gallery_mode = Horde_Util::getFormData('view_mode', 'Normal'); - $gallery_passwd = Horde_Util::getFormData('gallery_passwd'); - $gallery_tags = Horde_Util::getFormData('gallery_tags'); - $gallery_thumbstyle = Horde_Util::getFormData('gallery_style'); - $gallery_parent = Horde_Util::getFormData('gallery_parent'); - // Double check for an empty string instead of null - if (empty($gallery_parent)) { - $gallery_parent = null; - } - if ($galleryId && - ($exists = ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) === true)) { - - // Modifying an existing gallery. - $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 { - // Don't allow the display name to be nulled out. - if ($gallery_name) { - $gallery->set('name', $gallery_name); - } - - $gallery->set('desc', $gallery_desc); - $gallery->setTags(explode(',', $gallery_tags)); - $gallery->set('style', $gallery_thumbstyle); - $gallery->set('slug', $gallery_slug); - $gallery->set('age', $gallery_age); - $gallery->set('download', $gallery_download); - $gallery->set('view_mode', $gallery_mode); - if ($registry->getAuth() && - $gallery->get('owner') == $registry->getAuth()) { - $gallery->set('passwd', $gallery_passwd); - } - - // Did the parent change? - $old_parent = $gallery->getParent(); - if (!is_null($old_parent)) { - $old_parent_id = $old_parent->getId(); - } else { - $old_parent_id = null; - } - if ($gallery_parent != $old_parent_id) { - if (!is_null($gallery_parent)) { - $new_parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent); - } else { - $new_parent = null; - } - try { - $result = $gallery->setParent($new_parent); - } catch (Ansel_Exception $e) { - $notification->push($e->getMessage(), 'horde.error'); - Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); - exit; - } - } - try { - $result = $gallery->save(); - $notification->push(_("The gallery was saved."),'horde.success'); - } catch (Ansel_Exception $e) { - $notification->push($e->getMessage(), 'horde.error'); - } - } - } else { - // Is this a new subgallery? - if ($gallery_parent) { - try { - $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent); - } catch (Ansel_Exception $e) { - $notification->push($e->getMessage(), 'horde.error'); - Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); - exit; - } - if (!$parent->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { - $notification->push(sprintf( - _("You do not have permission to add children to %s."), - $parent->get('name')), 'horde.error'); - - Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); - exit; - } - } - - // Require a display name. - if (!$gallery_name) { - $notification->push( - _("You must provide a display name for your new gallery."), - 'horde.warning'); - $actionId = 'add'; - $title = _("Adding A New Gallery"); - break; - } - - // Create the new gallery. - $perm = (!empty($parent)) ? $parent->getPermission() : null; - $parent = (!empty($gallery_parent)) ? $gallery_parent : null; - - try { - $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery( - array('name' => $gallery_name, - 'desc' => $gallery_desc, - 'tags' => explode(',', $gallery_tags), - 'style' => $gallery_thumbstyle, - 'slug' => $gallery_slug, - 'age' => $gallery_age, - 'download' => $gallery_download, - 'view_mode' => $gallery_mode, - 'passwd' => $gallery_passwd, - ), - $perm, $parent); - - $galleryId = $gallery->getId(); - $msg = sprintf(_("The gallery \"%s\" was created successfully."), $gallery_name); - Horde::logMessage($msg, 'DEBUG'); - $notification->push($msg, 'horde.success'); - } catch (Ansel_Exception $e) { - $galleryId = null; - $error = sprintf(_("The gallery \"%s\" couldn't be created: %s"), - $gallery_name, $gallery->getMessage()); - Horde::logMessage($error, 'ERR'); - $notification->push($error, 'horde.error'); - } - - } - - // Clear the OtherGalleries widget cache - if ($conf['ansel_cache']['usecache']) { - $injector->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner')); - } - - // Return to the last view. - $url = Horde_Util::getFormData('url'); - if (empty($url) && empty($exists)) { - // Redirect to the images upload page for newly creted galleries - $url = Horde::url('img/upload.php')->add('gallery', $galleryId); - } elseif (empty($url)) { - $url = Horde::url('index.php', true); - } else { - $url = new Horde_Url($url); - } - $url->redirect(); - exit; - case 'delete': case 'empty': // Print the confirmation screen. @@ -351,16 +117,3 @@ default: exit; } -Horde::addScriptFile('stripe.js', 'horde'); -require ANSEL_TEMPLATES . '/common-header.inc'; - -/* Attach the slug check action to the form */ -$injector->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'GallerySlugCheck'), array( - 'bindTo' => 'gallery_slug', - 'slug' => $gallery_slug -)); -Horde::addScriptFile('popup.js', 'horde'); -echo Horde::menu(); -$notification->notify(array('listeners' => 'status')); -require ANSEL_TEMPLATES . '/gallery/gallery.inc'; -require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index 5e4da3ba5..545420537 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -721,11 +721,12 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical public function getStyle() { if (empty($this->data['attribute_style'])) { - $style = $GLOBALS['prefs']->getValue('default_gallerystyle'); + $style = Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle')); } else { - $style = $this->data['attribute_style']; + $style = unserialize($this->data['attribute_style']); } - return Ansel::getStyleDefinition($style); + + return $style; } diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index 6dd5c3582..5787edaf5 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -94,7 +94,7 @@ class Ansel_Storage $attributes['default_type'] = isset($attributes['default_type']) ? $attributes['default_type'] : 'auto'; $attributes['default'] = isset($attributes['default']) ? (int)$attributes['default'] : 0; $attributes['default_prettythumb'] = isset($attributes['default_prettythumb']) ? $attributes['default_prettythumb'] : ''; - $attributes['style'] = isset($attributes['style']) ? $attributes['style'] : $GLOBALS['prefs']->getValue('default_gallerystyle'); + $attributes['style'] = isset($attributes['style']) ? $attributes['style'] : '';//$GLOBALS['prefs']->getValue('default_gallerystyle'); $attributes['date_created'] = time(); $attributes['last_modified'] = $attributes['date_created']; $attributes['images'] = isset($attributes['images']) ? (int)$attributes['images'] : 0; diff --git a/ansel/lib/View/Gallery.php b/ansel/lib/View/Gallery.php index c49b0faae..ca45c441a 100644 --- a/ansel/lib/View/Gallery.php +++ b/ansel/lib/View/Gallery.php @@ -102,6 +102,7 @@ class Ansel_View_Gallery extends Ansel_View_Base } else { $renderer = (!empty($style['gallery_view'])) ? $style['gallery_view'] : 'Gallery'; } + /* Load the helper */ $classname = 'Ansel_View_GalleryRenderer_' . basename($renderer); $this->_renderer = new $classname($this); diff --git a/ansel/lib/View/GalleryProperties.php b/ansel/lib/View/GalleryProperties.php new file mode 100644 index 000000000..6ed9ba666 --- /dev/null +++ b/ansel/lib/View/GalleryProperties.php @@ -0,0 +1,374 @@ + + * @author Michael J. Rubinsky + * @package Ansel + */ + +/** + * Description of GalleryProperties + * + * @author mrubinsk + */ +class Ansel_View_GalleryProperties +{ + /** + * View parameters + * + * @var array + */ + protected $_params; + + /** + * Hash of gallery properties. + * + * @var array + */ + protected $_properties; + + /** + * The view title + * + * @var string + */ + protected $_title; + + /** + * Const'r + * + * @param array $params Parameters for the view + */ + public function __construct($params = array()) + { + $this->_params = $params; + + /*Gallery properties */ + $this->_properties = array( + 'name' => '', + 'desc' => '', + 'tags' => '', + 'style' => '', + 'slug' => '', + 'age' => 0, + 'download' => $GLOBALS['prefs']->getValue('default_download'), + 'parent' => null, + 'id' => null, + 'mode' => 'Normal', + 'passwd' => '', + 'owner' => '' + ); + } + + /** + * Runs the view + * + * @return void + */ + public function run() + { + switch ($this->_params['actionID']) { + case 'add': + $this->_runNew(); + $this->_output(); + break; + case 'addchild': + $this->_runNewChild(); + $this->_output(); + break; + case 'modify': + $this->_runEdit(); + $this->_output(); + break; + case 'save': + $this->_runSave(); + break; + } + } + + /** + * Outputs the view to the browser. + * + * @return void + */ + private function _output() + { + + $view = new Horde_View(array('templatePath' => array(ANSEL_TEMPLATES . '/gallery', + ANSEL_TEMPLATES . '/gallery/partial', + ANSEL_TEMPLATES . '/gallery/layout'))); + $view->addHelper('Text'); + $view->properties = $this->_properties; + $view->title = $this->_title; + $view->action = $this->_params['actionID']; + $view->url = $this->_params['url']; + + Horde::addInlineScript(array('$("gallery_name").focus()'), 'dom'); + Horde::addScriptFile('stripe.js', 'horde'); + Horde::addScriptFile('popup.js', 'horde'); + + /* Attach the slug check action to the form */ + $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'GallerySlugCheck'), array( + 'bindTo' => 'gallery_slug', + 'slug' => $this->_properties['slug'] + )); + + require ANSEL_TEMPLATES . '/common-header.inc'; + echo Horde::menu(); + $GLOBALS['notification']->notify(array('listeners' => 'status')); + echo $view->render('properties'); + require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'; + } + + /** + * Set up for adding new galleries. + * + * @return void + */ + private function _runNew() + { + $this->_title = _("Adding a New Gallery"); + $this->_properties['owner'] = $GLOBALS['registry']->getAuth(); + } + + /** + * Set up for adding a new child gallery. + * + * @return void + */ + private function _runNewChild() + { + // Get the parent and make sure that it exists and that we have + // permissions to add to it. + $parentId = $this->_params['gallery']; + try { + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($parentId); + } catch (Ansel_Exception $e) { + $GLOBALS['notification']->push($e->getMessage(), 'horde.error'); + Horde::url('view.php?view=List', true)->redirect(); + exit; + } + + if (!$parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { + $GLOBALS['notification']->push(sprintf(_("Access denied adding a gallery to \"%s\"."), + $parent->get('name')), 'horde.error'); + Horde::url('view.php?view=List', true)->redirect(); + exit; + } + + // Set up the gallery attributes. + $this->_properties['style'] = $parent->get('style'); + $this->_properties['parent'] = $parentId; + $this->_title = sprintf(_("Adding A Subgallery to %s"), $parent->get('name')); + } + + /** + * Handle setting up the form for editing an existing gallery + * + * @return void + * @throws InvalidArgumentException + */ + private function _runEdit() + { + if (empty($this->_params['gallery'])) { + throw new InvalidArgumentException(_("Missing gallery parameter")); + } + + try { + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_params['gallery']); + $parent = $gallery->getParent(); + $this->_properties = array( + 'name' => $gallery->get('name'), + 'desc' => $gallery->get('desc'), + 'tags' => implode(',', $gallery->getTags()), + 'slug' => $gallery->get('slug'), + 'age' => (int)$gallery->get('age'), + 'download' => $gallery->get('download'), + 'mode' => $gallery->get('view_mode'), + 'passwd' => $gallery->get('passwd'), + 'parent' => !is_null($parent) ? $parent->getId() : $parent, + 'id' => $gallery->getId(), + 'owner' => $gallery->get('owner') + ); + + //$gallery_thumbstyle = $gallery->get('style'); + $this->_title = sprintf(_("Modifying: %s"), $this->_properties['name']); + } catch (Ansel_Exception $e) { + $title = _("Unknown Gallery"); + } + } + + /** + * Handles saving the gallery information from the form submission, and + * redirects back to previous view when complete. + * + * @return void + */ + private function _runSave() + { + // Check general permissions. + if (!$GLOBALS['registry']->isAdmin() && + ($GLOBALS['injector']->getInstance('Horde_Perms')->exists('ansel') && + !$GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('ansel', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT))) { + + $GLOBALS['notification']->push(_("Access denied editing galleries."), 'horde.error'); + Horde::url('view.php?view=List', true)->redirect(); + exit; + } + + // Get the form values. + $galleryId = Horde_Util::getFormData('gallery'); + $gallery_name = Horde_Util::getFormData('gallery_name'); + $gallery_desc = Horde_Util::getFormData('gallery_desc'); + $gallery_slug = Horde_Util::getFormData('gallery_slug'); + $gallery_age = (int)Horde_Util::getFormData('gallery_age', 0); + $gallery_download = Horde_Util::getFormData('gallery_download'); + $gallery_mode = Horde_Util::getFormData('view_mode', 'Normal'); + $gallery_passwd = Horde_Util::getFormData('gallery_passwd'); + $gallery_tags = Horde_Util::getFormData('gallery_tags'); + $gallery_thumbstyle = Horde_Util::getFormData('gallery_style'); + $gallery_parent = Horde_Util::getFormData('gallery_parent'); + + // Double check for an empty string instead of null + if (empty($gallery_parent)) { + $gallery_parent = null; + } + if ($galleryId && + ($exists = ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->galleryExists($galleryId)) === true)) { + + // Modifying an existing gallery. + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); + if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { + $GLOBALS['notification']->push(sprintf(_("Access denied saving gallery \"%s\"."), $gallery->get('name')), 'horde.error'); + } else { + // Don't allow the display name to be nulled out. + if ($gallery_name) { + $gallery->set('name', $gallery_name); + } + $gallery->set('desc', $gallery_desc); + $gallery->setTags(explode(',', $gallery_tags)); + //$gallery->set('style', $style); + $gallery->set('slug', $gallery_slug); + $gallery->set('age', $gallery_age); + $gallery->set('download', $gallery_download); + $gallery->set('view_mode', $gallery_mode); + if ($GLOBALS['registry']->getAuth() && + $gallery->get('owner') == $GLOBALS['registry']->getAuth()) { + $gallery->set('passwd', $gallery_passwd); + } + + // Did the parent change? + $old_parent = $gallery->getParent(); + if (!is_null($old_parent)) { + $old_parent_id = $old_parent->getId(); + } else { + $old_parent_id = null; + } + if ($gallery_parent != $old_parent_id) { + if (!is_null($gallery_parent)) { + $new_parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent); + } else { + $new_parent = null; + } + try { + $result = $gallery->setParent($new_parent); + } catch (Ansel_Exception $e) { + $GLOBALS['notification']->push($e->getMessage(), 'horde.error'); + Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); + exit; + } + } + try { + $result = $gallery->save(); + $GLOBALS['notification']->push(_("The gallery was saved."),'horde.success'); + } catch (Ansel_Exception $e) { + $GLOBALS['notification']->push($e->getMessage(), 'horde.error'); + } + } + } else { + // Is this a new subgallery? + if ($gallery_parent) { + try { + $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent); + } catch (Ansel_Exception $e) { + $GLOBALS['notification']->push($e->getMessage(), 'horde.error'); + Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); + exit; + } + if (!$parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { + $GLOBALS['notification']->push(sprintf( + _("You do not have permission to add children to %s."), + $parent->get('name')), 'horde.error'); + + Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); + exit; + } + } + + // Require a display name. + if (!$gallery_name) { + $GLOBALS['notification']->push( + _("You must provide a display name for your new gallery."), + 'horde.warning'); + $actionId = 'add'; + $title = _("Adding A New Gallery"); + break; + } + + // Create the new gallery. + $perm = (!empty($parent)) ? $parent->getPermission() : null; + $parent = (!empty($gallery_parent)) ? $gallery_parent : null; + + try { + $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->createGallery( + array('name' => $gallery_name, + 'desc' => $gallery_desc, + 'tags' => explode(',', $gallery_tags), + //'style' => $style, + 'slug' => $gallery_slug, + 'age' => $gallery_age, + 'download' => $gallery_download, + 'view_mode' => $gallery_mode, + 'passwd' => $gallery_passwd, + ), + $perm, $parent); + + $galleryId = $gallery->getId(); + $msg = sprintf(_("The gallery \"%s\" was created successfully."), $gallery_name); + Horde::logMessage($msg, 'DEBUG'); + $GLOBALS['notification']->push($msg, 'horde.success'); + } catch (Ansel_Exception $e) { + $galleryId = null; + $error = sprintf(_("The gallery \"%s\" couldn't be created: %s"), + $gallery_name, $gallery->getMessage()); + Horde::logMessage($error, 'ERR'); + $GLOBALS['notification']->push($error, 'horde.error'); + } + + } + + // Clear the OtherGalleries widget cache + if ($GLOBALS['conf']['ansel_cache']['usecache']) { + $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner')); + } + + // Return to the last view. + $url = Horde_Util::getFormData('url'); + if (empty($url) && empty($exists)) { + // Redirect to the images upload page for newly creted galleries + $url = Horde::url('img/upload.php')->add('gallery', $galleryId); + } elseif (empty($url)) { + $url = Horde::url('index.php', true); + } else { + $url = new Horde_Url($url); + } + $url->redirect(); + } +} + diff --git a/ansel/scripts/sql/ansel.sql b/ansel/scripts/sql/ansel.sql index 2d6f29299..2c95432d3 100644 --- a/ansel/scripts/sql/ansel.sql +++ b/ansel/scripts/sql/ansel.sql @@ -68,7 +68,7 @@ CREATE TABLE ansel_shares ( attribute_default INT, attribute_default_type VARCHAR(6), attribute_default_prettythumb TEXT, - attribute_style VARCHAR(255), + attribute_style TEXT, attribute_category VARCHAR(255) DEFAULT '' NOT NULL, attribute_last_modified INT, attribute_date_created INT, diff --git a/ansel/templates/common-header.inc b/ansel/templates/common-header.inc index 7140be40b..6615acf66 100644 --- a/ansel/templates/common-header.inc +++ b/ansel/templates/common-header.inc @@ -12,7 +12,7 @@ if (isset($language)) { get('name'); +$page_title = $GLOBALS['registry']->get('name'); if (!empty($title)) { $page_title .= ' :: ' . $title; } diff --git a/ansel/templates/gallery/gallery.inc b/ansel/templates/gallery/gallery.inc deleted file mode 100644 index bf5ba0d7d..000000000 --- a/ansel/templates/gallery/gallery.inc +++ /dev/null @@ -1,123 +0,0 @@ -
- - - - - - - - - -

- getCharset()) ?> -

- - - - - - -isLocked('default_gallerystyle')) { - echo ''; -} else { -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -isLocked('default_download')) { - echo ''; -} else { -?> - - - - - -getAuth() && !empty($gallery) && $GLOBALS['registry']->getAuth() == $gallery->get('owner')): ?> - - - - - - - - - -
  - -
  - -
- -
  - -
  - -
  -
-
- -
 
- -
  -
  - -
 
- " />  - " />  -
-
diff --git a/ansel/templates/gallery/properties.html.php b/ansel/templates/gallery/properties.html.php new file mode 100644 index 000000000..44f37c974 --- /dev/null +++ b/ansel/templates/gallery/properties.html.php @@ -0,0 +1,131 @@ + + * (string)action The current actionID + * (int)parent The parent id + * (int)id The current gallery id, if not new. + * (Horde_Url)url The return url + * (string)title The form title + * (string)mode The gallery mode + * (array)properties The gallery properties + * + * + * + */ +?> +
+ + +action == 'addchild'): ?> + +action != 'add'): ?> + + + +

+ h($this->title); ?> +

+ + + + + +isLocked('default_gallerystyle')): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +isLocked('default_download')): ?> + '; + + + + + + +getAuth() && $GLOBALS['registry']->getAuth() == $this->properties['owner']): ?> + + + + + + + + + +
  + +
  + style) ?> +
+ +
  + +
  + +
  +
+
+ +
 
+ +
  +
  + +
 
+ " />  + " />  +
+