1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11: class Ansel_Form_Image extends Horde_Form
12: {
13: protected $_useFormToken = false;
14:
15: public function __construct(&$vars, $title)
16: {
17: global $gallery;
18:
19: parent::Horde_Form($vars, $title);
20:
21: $this->setButtons(_("Save"));
22: $this->addHidden('', 'actionID', 'text', false);
23: $this->addHidden('', 'gallery', 'text', false);
24: $this->addHidden('', 'image', 'text', false);
25: $this->addHidden('', 'page', 'text', false);
26:
27: $filesize = ini_get('upload_max_filesize');
28: if (substr($filesize, -1) == 'M') {
29: $filesize = $filesize * 1048576;
30: }
31: $filesize = $this->_get_size($filesize);
32: $this->addVariable(_("Make this the default photo for this gallery?"),
33: 'image_default', 'boolean', false);
34: $this->addVariable(_("Caption"), 'image_desc', 'longtext', false, false,
35: null, array('4', '40'));
36:
37: $this->addVariable(_("Original Date"), 'image_originalDate',
38: 'monthdayyear', true, false, null,
39: array('start_year' => 1900));
40:
41: $this->addVariable(_("Tags"), 'image_tags', 'text', false);
42:
43: $this->addHidden('', 'image0', 'text', false);
44: $upload = &$this->addVariable(
45: _("Replace photo with this file"), 'file0', 'file', false, false,
46: _("Maximum photo size:") . ' ' . $filesize, array(false));
47: $upload->setHelp('upload');
48: }
49:
50: 51: 52:
53: protected function _get_size($size)
54: {
55: $bytes = array('B', 'KB', 'MB', 'GB', 'TB');
56:
57: foreach ($bytes as $val) {
58: if ($size > 1024) {
59: $size = $size / 1024;
60: } else {
61: break;
62: }
63: }
64:
65: return round($size, 2) . ' ' . $val;
66: }
67:
68: }
69: