1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19:
20: class ImagesImage_imagemanagerForm extends Xoops\Form\ThemeForm
21: {
22:
23: 24: 25: 26: 27: 28:
29: public function __construct($param)
30: {
31: $xoops = Xoops::getInstance();
32: $helper = Xoops\Module\Helper::getHelper('images');
33:
34:
35: extract($param);
36:
37: $groups = $xoops->getUserGroups();
38:
39: if ($obj->isNew()) {
40: $title = _AM_IMAGES_IMG_ADD;
41: } else {
42: $title = _AM_IMAGES_IMG_EDIT;
43: }
44:
45: parent::__construct($title, 'image', $xoops->getEnv('PHP_SELF'), 'post', true);
46: $this->setExtra('enctype="multipart/form-data"');
47:
48: $this->addElement(new Xoops\Form\Text(_AM_IMAGES_NAME, 'image_nicename', 50, 255, $obj->getVar('image_nicename')), true);
49:
50: $categories = $helper->getHandlerCategories()->getListByPermission($groups, 'imgcat_write');
51: $select = new Xoops\Form\Select(_AM_IMAGES_CAT_SELECT, 'imgcat_id', $obj->getVar('imgcat_id'));
52: $select->addOption('', _AM_IMAGES_CAT_SELECT);
53: $select->addOptionArray($categories);
54: $this->addElement($select, true);
55:
56: $this->addElement(new Xoops\Form\File(_AM_IMAGES_IMG_FILE, 'image_file'));
57:
58: $this->addElement(new Xoops\Form\Hidden('image_weight', $obj->getVar('image_weight')));
59: $this->addElement(new Xoops\Form\Hidden('image_display', $obj->getVar('image_display')));
60: $this->addElement(new Xoops\Form\Hidden('image_name', $obj->getVar('image_name')));
61: $this->addElement(new Xoops\Form\Hidden('image_id', $obj->getVar('image_id')));
62: $this->addElement(new Xoops\Form\Hidden('target', $target));
63:
64: 65: 66:
67: $buttonTray = new Xoops\Form\ElementTray('', '');
68: $buttonTray->addElement(new Xoops\Form\Hidden('op', 'save'));
69:
70: $buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
71: $buttonSubmit->setClass('btn btn-success');
72: $buttonTray->addElement($buttonSubmit);
73:
74: $buttonReset = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
75: $buttonReset->setClass('btn btn-warning');
76: $buttonTray->addElement($buttonReset);
77:
78: switch (basename($xoops->getEnv('PHP_SELF'), '.php')) {
79: case 'xoops_images':
80: $buttonClose = new Xoops\Form\Button('', 'button', XoopsLocale::A_CLOSE, 'button');
81: $buttonClose->setExtra('onclick="tinyMCEPopup.close();"');
82: $buttonClose->setClass('btn btn-danger');
83: $buttonTray->addElement($buttonClose);
84: break;
85:
86: case 'images':
87: default:
88: $buttonCancel = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
89: $buttonCancel->setExtra("onclick='javascript:history.go(-1);'");
90: $buttonCancel->setClass('btn btn-danger');
91: $buttonTray->addElement($buttonCancel);
92: break;
93: }
94:
95: $this->addElement($buttonTray);
96: }
97: }
98: