From: Michael J. Rubinsky Date: Fri, 31 Jul 2009 17:55:42 +0000 (-0400) Subject: Rename Ansel's Form objects for autoloading X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=36745b49da2bf9045c25f10376638e2f98a58120;p=horde.git Rename Ansel's Form objects for autoloading --- diff --git a/ansel/edit_dates.php b/ansel/edit_dates.php index 1c8ddf718..e3c5a2082 100644 --- a/ansel/edit_dates.php +++ b/ansel/edit_dates.php @@ -7,7 +7,6 @@ * * @author Michael J. Rubinsky */ - require_once dirname(__FILE__) . '/lib/base.php'; $images = Horde_Util::getFormData('image', array()); @@ -35,13 +34,9 @@ if (!count($images)) { exit; } -/* Includes */ -require_once ANSEL_BASE . '/lib/Forms/ImageDate.php'; -require_once 'Horde/Form/Renderer.php'; - /* Set up the form */ $vars = Horde_Variables::getDefaultVariables(); -$form = new ImageDateForm($vars, _("Edit Dates")); +$form = new Ansel_Form_ImageDate($vars, _("Edit Dates")); /* Are we doing the edit now? */ if ($actionID == 'edit_dates') { $count = 0; diff --git a/ansel/image.php b/ansel/image.php index db64b0f3e..4121bf9c4 100644 --- a/ansel/image.php +++ b/ansel/image.php @@ -13,7 +13,6 @@ */ require_once dirname(__FILE__) . '/lib/base.php'; -require_once 'Horde/Form/Renderer.php'; /* Get all the form data */ $actionID = Horde_Util::getFormData('actionID'); @@ -145,7 +144,7 @@ case 'modify': } else { $vars->set('actionID', 'savecloseimage'); } - $form = new ImageForm($vars, $title); + $form = new Ansel_Form_Image($vars, $title); $renderer = new Horde_Form_Renderer(); /* Set up the gallery attributes. */ @@ -185,7 +184,7 @@ case 'save': $vars = Horde_Variables::getDefaultVariables(); $vars->set('actionID', 'save'); $renderer = new Horde_Form_Renderer(); - $form = new ImageForm($vars, _("Edit a photo")); + $form = new Ansel_Form_Image($vars, _("Edit a photo")); /* Update existing image. */ if ($form->validate($vars)) { @@ -463,7 +462,7 @@ case 'setwatermark': require_once ANSEL_BASE . '/lib/Forms/Watermark.php'; $vars = Horde_Variables::getDefaultVariables(); $vars->set('actionID', 'previewcustomwatermark'); - $form = new WatermarkForm($vars, _("Watermark")); + $form = new Ansel_Form_Watermark($vars, _("Watermark")); $renderer = new Horde_Form_Renderer(); require ANSEL_TEMPLATES . '/common-header.inc'; diff --git a/ansel/img/ecard.php b/ansel/img/ecard.php index 4e344d1f2..9cbc58776 100644 --- a/ansel/img/ecard.php +++ b/ansel/img/ecard.php @@ -9,8 +9,6 @@ */ require_once dirname(__FILE__) . '/../lib/base.php'; -require_once ANSEL_BASE . '/lib/Forms/Ecard.php'; -require_once 'Horde/Form/Renderer.php'; /* Abort if ecard sending is disabled. */ if (empty($conf['ecard']['enable'])) { @@ -99,7 +97,7 @@ $title = sprintf(_("Send Ecard :: %s"), $image->filename); $vars = Horde_Variables::getDefaultVariables(); $vars->set('actionID', 'send'); $vars->set('image_desc', strlen($image->caption) ? $image->caption : $image->filename); -$form = new EcardForm($vars, $title); +$form = new Ansel_Form_Ecard($vars, $title); $renderer = new Horde_Form_Renderer(); if ($browser->hasFeature('rte')) { diff --git a/ansel/img/upload.php b/ansel/img/upload.php index 70e2c0bf5..c975cdb16 100644 --- a/ansel/img/upload.php +++ b/ansel/img/upload.php @@ -9,8 +9,6 @@ */ require_once dirname(__FILE__) . '/../lib/base.php'; -require_once ANSEL_BASE . '/lib/Forms/Upload.php'; -require_once 'Horde/Form/Renderer.php'; $gallery_id = Horde_Util::getFormData('gallery'); $gallery = &$ansel_storage->getGallery($gallery_id); @@ -23,7 +21,7 @@ if (is_a($gallery, 'PEAR_Error')) { $page = Horde_Util::getFormData('page', 0); $vars = Horde_Variables::getDefaultVariables(); -$form = new UploadForm($vars, _("Upload photos")); +$form = new Ansel_Form_Upload($vars, _("Upload photos")); if ($form->validate($vars)) { $valid = true; $uploaded = 0; diff --git a/ansel/lib/Form/Ecard.php b/ansel/lib/Form/Ecard.php new file mode 100644 index 000000000..bf50f3f2f --- /dev/null +++ b/ansel/lib/Form/Ecard.php @@ -0,0 +1,37 @@ +setButtons(_("Send")); + $this->addHidden('', 'actionID', 'text', false); + $this->addHidden('', 'gallery', 'text', false); + $this->addHidden('', 'image', 'text', false); + $this->addHidden('', 'image_desc', 'text', false); + + $user = Horde_Auth::getAuth(); + if (empty($user)) { + $this->addVariable(_("Use the following return address:"), 'ecard_retaddr', 'text', true); + } else { + require_once 'Horde/Identity.php'; + $identity = Identity::singleton(); + $from_addr = $identity->getDefaultFromAddress(); + $vars->set('ecard_retaddr', $from_addr); + $this->addHidden('', 'ecard_retaddr', 'text', true); + } + + $this->addVariable(_("Send ecard to the following address:"), 'ecard_addr', 'text', true); + $this->addVariable(_("Comments:"), 'ecard_comments', 'longtext', false, false, null, array('15', '60')); + } + +} diff --git a/ansel/lib/Form/Image.php b/ansel/lib/Form/Image.php new file mode 100644 index 000000000..77d1d2989 --- /dev/null +++ b/ansel/lib/Form/Image.php @@ -0,0 +1,67 @@ + + */ +class Ansel_Form_Image extends Horde_Form +{ + protected $_useFormToken = false; + + public function __construct(&$vars, $title) + { + global $gallery; + + parent::Horde_Form($vars, $title); + + $this->setButtons(_("Save")); + $this->addHidden('', 'actionID', 'text', false); + $this->addHidden('', 'gallery', 'text', false); + $this->addHidden('', 'image', 'text', false); + $this->addHidden('', 'page', 'text', false); + + $filesize = ini_get('upload_max_filesize'); + if (substr($filesize, -1) == 'M') { + $filesize = $filesize * 1048576; + } + $filesize = $this->_get_size($filesize); + $this->addVariable(_("Make this the default photo for this gallery?"), + 'image_default', 'boolean', false); + $this->addVariable(_("Caption"), 'image_desc', 'longtext', false, false, + null, array('4', '40')); + + $this->addVariable(_("Original Date"), 'image_originalDate', + 'monthdayyear', true, false, null, + array('start_year' => 1900)); + + $this->addVariable(_("Tags"), 'image_tags', 'text', false); + + $this->addHidden('', 'image0', 'text', false); + $upload = &$this->addVariable( + _("Replace photo with this file"), 'file0', 'image', false, false, + _("Maximum photo size:") . ' ' . $filesize, array(false)); + $upload->setHelp('upload'); + } + + /** + * Format file size + */ + protected function _get_size($size) + { + $bytes = array('B', 'KB', 'MB', 'GB', 'TB'); + + foreach ($bytes as $val) { + if ($size > 1024) { + $size = $size / 1024; + } else { + break; + } + } + + return round($size, 2) . ' ' . $val; + } + +} diff --git a/ansel/lib/Form/ImageDate.php b/ansel/lib/Form/ImageDate.php new file mode 100644 index 000000000..19e26dc8f --- /dev/null +++ b/ansel/lib/Form/ImageDate.php @@ -0,0 +1,31 @@ + + */ +class Ansel_Form_ImageDate extends Horde_Form +{ + protected $_useFormToken = false; + + public function __construct(&$vars, $title) + { + global $gallery; + + parent::Horde_Form($vars, $title); + + $this->setButtons(_("Save")); + $this->addHidden('', 'actionID', 'text', false); + $this->addHidden('', 'gallery', 'text', false); + $this->addHidden('', 'image', 'text', false); + $this->addHidden('', 'page', 'text', false); + $this->addVariable(_("Editing dates for the following photos"), 'image_list', 'html', false, true); + $this->addVariable(_("Original Date"), 'image_originalDate', + 'monthdayyear', true, false, null, + array('start_year' => 1900)); + } + +} diff --git a/ansel/lib/Form/Upload.php b/ansel/lib/Form/Upload.php new file mode 100644 index 000000000..7f1ca2520 --- /dev/null +++ b/ansel/lib/Form/Upload.php @@ -0,0 +1,93 @@ +_get_size($filesize); + + $postsize = ini_get('post_max_size'); + if (substr($postsize, -1) == 'M') { + $postsize = $postsize * 1048576; + } + $postsize = $this->_get_size($postsize); + + $this->setButtons(array(_("Upload"), _("Cancel"))); + $this->addHidden('', 'gallery', 'text', false); + $this->addHidden('', 'page', 'text', false); + + $this->setSection('single_file', _("Single Photo")); + $this->addHidden('', 'image0', 'text', false); + if (!strlen($vars->get('image0'))) { + $upload = &$this->addVariable( + _("File to upload"), 'file0', 'image', false, false, + _("Maximum photo size:") . ' ' . $filesize, array(false)); + $upload->setHelp('upload'); + } + $this->addVariable(_("Make this the default photo for this gallery?"), 'image0_default', 'boolean', false); + $this->addVariable(_("Caption"), 'image0_desc', 'longtext', false, false, null, array('4', '40')); + $this->addVariable(_("Tags"), 'image0_tags', 'text', false, false, _("Separate tags with commas.")); + + $this->setSection('multi_file', _("Multiple Photos")); + + if (!strlen($vars->get('image0'))) { + $msg = sprintf(_("Maximum photo size: %s; with a total of: %s"), + $filesize, $postsize); + $this->addVariable($msg, 'description', 'description', false); + } + + // start at $i = 1 because 0 is used above. + for ($i = 1; $i <= $conf['image']['num_uploads']; $i++) { + $this->addHidden('', 'image' . $i, 'text', false); + if (!strlen($vars->get('image' . $i))) { + $upload = &$this->addVariable(sprintf(_("File %s"), $i), 'file' . $i, 'image', false, false, null, array(false)); + $upload->setHelp('upload'); + } + } + + $this->setSection('zip_file', _("Zip File Upload")); + $this->addHidden('', 'image' . ($conf['image']['num_uploads'] + 1), 'text', false); + if (!strlen($vars->get('zip'))) { + $upload = &$this->addVariable( + _("File to upload"), + 'file' . ($conf['image']['num_uploads'] + 1), + 'file', false, false, + _("Maximum file size:") . ' ' . $filesize); + $upload->setHelp('upload'); + } + } + + /** + * Format file size + */ + protected function _get_size($size) + { + $bytes = array('B', 'KB', 'MB', 'GB', 'TB'); + + foreach ($bytes as $val) { + if ($size > 1024) { + $size = $size / 1024; + } else { + break; + } + } + + return round($size, 2) . ' ' . $val; + } + +} diff --git a/ansel/lib/Form/Watermark.php b/ansel/lib/Form/Watermark.php new file mode 100644 index 000000000..128ffde10 --- /dev/null +++ b/ansel/lib/Form/Watermark.php @@ -0,0 +1,54 @@ + + */ +class Ansel_Form_Watermark extends Horde_Form +{ + protected $_useFormToken = false; + + public function __construct(&$vars, $title) + { + global $gallery, $prefs; + + parent::Horde_Form($vars, $title); + + $this->setButtons(_("Save")); + $this->addHidden('', 'actionID', 'text', false); + $this->addHidden('', 'gallery', 'text', false); + $this->addHidden('', 'image', 'text', false); + $this->addHidden('', 'page', 'text', false); + + $w = &$this->addVariable(_("Custom Watermark"), 'watermark', 'text', + false, false, null); + $w->setDefault($prefs->getValue('watermark_text')); + + $fonts = array('tiny' => _("Tiny"), + 'small' => _("Small"), + 'medium' => _("Medium"), + 'large' => _("Large"), + 'giant' => _("Giant")); + $f = &$this->addVariable(_("Watermark Font"), 'font', 'enum', false, + false, null, array($fonts)); + $f->setDefault($prefs->getValue('watermark_font')); + + $ha = array('left' => _("Left"), + 'center' => _("Center"), + 'right' => _("Right")); + $wha = &$this->addVariable(_("Horizontal Alignment"), 'whalign', 'enum', + false, false, null, array($ha)); + $wha->setDefault($prefs->getValue('watermark_horizontal')); + + $va = array('top' => _("Top"), + 'center' => _("Center"), + 'bottom' => _("Bottom")); + $wva = &$this->addVariable(_("Vertical Alignment"), 'wvalign', 'enum', + false, false, null, array($va)); + $wva->setDefault($prefs->getValue('watermark_vertical')); + } + +} diff --git a/ansel/lib/Forms/Ecard.php b/ansel/lib/Forms/Ecard.php deleted file mode 100644 index 6fc69a373..000000000 --- a/ansel/lib/Forms/Ecard.php +++ /dev/null @@ -1,37 +0,0 @@ -setButtons(_("Send")); - $this->addHidden('', 'actionID', 'text', false); - $this->addHidden('', 'gallery', 'text', false); - $this->addHidden('', 'image', 'text', false); - $this->addHidden('', 'image_desc', 'text', false); - - $user = Horde_Auth::getAuth(); - if (empty($user)) { - $this->addVariable(_("Use the following return address:"), 'ecard_retaddr', 'text', true); - } else { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton(); - $from_addr = $identity->getDefaultFromAddress(); - $vars->set('ecard_retaddr', $from_addr); - $this->addHidden('', 'ecard_retaddr', 'text', true); - } - - $this->addVariable(_("Send ecard to the following address:"), 'ecard_addr', 'text', true); - $this->addVariable(_("Comments:"), 'ecard_comments', 'longtext', false, false, null, array('15', '60')); - } - -} diff --git a/ansel/lib/Forms/Image.php b/ansel/lib/Forms/Image.php deleted file mode 100644 index 416a16fd0..000000000 --- a/ansel/lib/Forms/Image.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ -class ImageForm extends Horde_Form { - - var $_useFormToken = false; - - function ImageForm(&$vars, $title) - { - global $gallery; - - parent::Horde_Form($vars, $title); - - $this->setButtons(_("Save")); - $this->addHidden('', 'actionID', 'text', false); - $this->addHidden('', 'gallery', 'text', false); - $this->addHidden('', 'image', 'text', false); - $this->addHidden('', 'page', 'text', false); - - $filesize = ini_get('upload_max_filesize'); - if (substr($filesize, -1) == 'M') { - $filesize = $filesize * 1048576; - } - $filesize = $this->_get_size($filesize); - $this->addVariable(_("Make this the default photo for this gallery?"), - 'image_default', 'boolean', false); - $this->addVariable(_("Caption"), 'image_desc', 'longtext', false, false, - null, array('4', '40')); - - $this->addVariable(_("Original Date"), 'image_originalDate', - 'monthdayyear', true, false, null, - array('start_year' => 1900)); - - $this->addVariable(_("Tags"), 'image_tags', 'text', false); - - $this->addHidden('', 'image0', 'text', false); - $upload = &$this->addVariable( - _("Replace photo with this file"), 'file0', 'image', false, false, - _("Maximum photo size:") . ' ' . $filesize, array(false)); - $upload->setHelp('upload'); - } - - /** - * Format file size - */ - function _get_size($size) - { - $bytes = array('B', 'KB', 'MB', 'GB', 'TB'); - - foreach ($bytes as $val) { - if ($size > 1024) { - $size = $size / 1024; - } else { - break; - } - } - - return round($size, 2) . ' ' . $val; - } - -} diff --git a/ansel/lib/Forms/ImageDate.php b/ansel/lib/Forms/ImageDate.php deleted file mode 100644 index a0944fd68..000000000 --- a/ansel/lib/Forms/ImageDate.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ -class ImageDateForm extends Horde_Form { - - var $_useFormToken = false; - - function ImageDateForm(&$vars, $title) - { - global $gallery; - - parent::Horde_Form($vars, $title); - - $this->setButtons(_("Save")); - $this->addHidden('', 'actionID', 'text', false); - $this->addHidden('', 'gallery', 'text', false); - $this->addHidden('', 'image', 'text', false); - $this->addHidden('', 'page', 'text', false); - $this->addVariable(_("Editing dates for the following photos"), 'image_list', 'html', false, true); - $this->addVariable(_("Original Date"), 'image_originalDate', - 'monthdayyear', true, false, null, - array('start_year' => 1900)); - } - -} diff --git a/ansel/lib/Forms/Upload.php b/ansel/lib/Forms/Upload.php deleted file mode 100644 index d165a300e..000000000 --- a/ansel/lib/Forms/Upload.php +++ /dev/null @@ -1,93 +0,0 @@ -_get_size($filesize); - - $postsize = ini_get('post_max_size'); - if (substr($postsize, -1) == 'M') { - $postsize = $postsize * 1048576; - } - $postsize = $this->_get_size($postsize); - - $this->setButtons(array(_("Upload"), _("Cancel"))); - $this->addHidden('', 'gallery', 'text', false); - $this->addHidden('', 'page', 'text', false); - - $this->setSection('single_file', _("Single Photo")); - $this->addHidden('', 'image0', 'text', false); - if (!strlen($vars->get('image0'))) { - $upload = &$this->addVariable( - _("File to upload"), 'file0', 'image', false, false, - _("Maximum photo size:") . ' ' . $filesize, array(false)); - $upload->setHelp('upload'); - } - $this->addVariable(_("Make this the default photo for this gallery?"), 'image0_default', 'boolean', false); - $this->addVariable(_("Caption"), 'image0_desc', 'longtext', false, false, null, array('4', '40')); - $this->addVariable(_("Tags"), 'image0_tags', 'text', false, false, _("Separate tags with commas.")); - - $this->setSection('multi_file', _("Multiple Photos")); - - if (!strlen($vars->get('image0'))) { - $msg = sprintf(_("Maximum photo size: %s; with a total of: %s"), - $filesize, $postsize); - $this->addVariable($msg, 'description', 'description', false); - } - - // start at $i = 1 because 0 is used above. - for ($i = 1; $i <= $conf['image']['num_uploads']; $i++) { - $this->addHidden('', 'image' . $i, 'text', false); - if (!strlen($vars->get('image' . $i))) { - $upload = &$this->addVariable(sprintf(_("File %s"), $i), 'file' . $i, 'image', false, false, null, array(false)); - $upload->setHelp('upload'); - } - } - - $this->setSection('zip_file', _("Zip File Upload")); - $this->addHidden('', 'image' . ($conf['image']['num_uploads'] + 1), 'text', false); - if (!strlen($vars->get('zip'))) { - $upload = &$this->addVariable( - _("File to upload"), - 'file' . ($conf['image']['num_uploads'] + 1), - 'file', false, false, - _("Maximum file size:") . ' ' . $filesize); - $upload->setHelp('upload'); - } - } - - /** - * Format file size - */ - function _get_size($size) - { - $bytes = array('B', 'KB', 'MB', 'GB', 'TB'); - - foreach ($bytes as $val) { - if ($size > 1024) { - $size = $size / 1024; - } else { - break; - } - } - - return round($size, 2) . ' ' . $val; - } - -} diff --git a/ansel/lib/Forms/Watermark.php b/ansel/lib/Forms/Watermark.php deleted file mode 100644 index ae1f89e09..000000000 --- a/ansel/lib/Forms/Watermark.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -class WatermarkForm extends Horde_Form { - - var $_useFormToken = false; - - function WatermarkForm(&$vars, $title) - { - global $gallery, $prefs; - - parent::Horde_Form($vars, $title); - - $this->setButtons(_("Save")); - $this->addHidden('', 'actionID', 'text', false); - $this->addHidden('', 'gallery', 'text', false); - $this->addHidden('', 'image', 'text', false); - $this->addHidden('', 'page', 'text', false); - - $w = &$this->addVariable(_("Custom Watermark"), 'watermark', 'text', - false, false, null); - $w->setDefault($prefs->getValue('watermark_text')); - - $fonts = array('tiny' => _("Tiny"), - 'small' => _("Small"), - 'medium' => _("Medium"), - 'large' => _("Large"), - 'giant' => _("Giant")); - $f = &$this->addVariable(_("Watermark Font"), 'font', 'enum', false, - false, null, array($fonts)); - $f->setDefault($prefs->getValue('watermark_font')); - - $ha = array('left' => _("Left"), - 'center' => _("Center"), - 'right' => _("Right")); - $wha = &$this->addVariable(_("Horizontal Alignment"), 'whalign', 'enum', - false, false, null, array($ha)); - $wha->setDefault($prefs->getValue('watermark_horizontal')); - - $va = array('top' => _("Top"), - 'center' => _("Center"), - 'bottom' => _("Bottom")); - $wva = &$this->addVariable(_("Vertical Alignment"), 'wvalign', 'enum', - false, false, null, array($va)); - $wva->setDefault($prefs->getValue('watermark_vertical')); - } - -}