1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\FixedGroups;
13:
14: 15: 16: 17: 18: 19: 20: 21:
22: class ImagesCategoryForm extends Xoops\Form\ThemeForm
23: {
24: 25: 26:
27: public function __construct(ImagesCategory $obj)
28: {
29: $xoops = Xoops::getInstance();
30:
31: $perm_handler = $xoops->getHandlerGroupPermission();
32:
33: if ($obj->isNew()) {
34: $title = _AM_IMAGES_CAT_ADD;
35: $read = FixedGroups::ADMIN;
36: $write = FixedGroups::ADMIN;
37: } else {
38: $title = _AM_IMAGES_CAT_EDIT;
39: $read = $perm_handler->getGroupIds('imgcat_read', $obj->getVar('imgcat_id'), $xoops->module->getVar('mid'));
40: $write = $perm_handler->getGroupIds('imgcat_write', $obj->getVar('imgcat_id'), $xoops->module->getVar('mid'));
41: }
42:
43: parent::__construct($title, 'imagecat_form', $xoops->getEnv('PHP_SELF'), 'post', true);
44:
45: $tabTray = new Xoops\Form\TabTray('', 'uniqueid');
46:
47: $tab1 = new Xoops\Form\Tab(_MI_IMAGES_CATEGORIES, 'tabid-1');
48: $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_NAME, 'imgcat_name', 50, 255, $obj->getVar('imgcat_name')), true);
49: $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_SIZE, 'imgcat_maxsize', 2, 8, $obj->getVar('imgcat_maxsize')));
50: $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_WIDTH, 'imgcat_maxwidth', 1, 4, $obj->getVar('imgcat_maxwidth')));
51: $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_HEIGHT, 'imgcat_maxheight', 1, 4, $obj->getVar('imgcat_maxheight')));
52: $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_WEIGHT, 'imgcat_weight', 1, 5, $obj->getVar('imgcat_weight')));
53: $tab1->addElement(new Xoops\Form\RadioYesNo(_AM_IMAGES_CAT_DISPLAY, 'imgcat_display', $obj->getVar('imgcat_display')));
54: if ($obj->isNew()) {
55: $store = new Xoops\Form\Radio(_AM_IMAGES_CAT_STR_TYPE . '<div class="red">' . _AM_IMAGES_CAT_STR_TYOPENG . '</div>', 'imgcat_storetype', 'file');
56: $store->addOptionArray(array('file' => _AM_IMAGES_CAT_ASFILE, 'db' => _AM_IMAGES_CAT_INDB));
57: $tab1->addElement($store);
58: } else {
59: $store = array('db' => _AM_IMAGES_CAT_INDB, 'file' => _AM_IMAGES_CAT_ASFILE);
60: $tab1->addElement(new Xoops\Form\Label(_AM_IMAGES_CAT_STR_TYPE, $store[$obj->getVar('imgcat_storetype')]));
61: $this->addElement(new Xoops\Form\Hidden('imgcat_storetype', $obj->getVar('imgcat_storetype')));
62: }
63:
64: $tab2 = new Xoops\Form\Tab(_MI_IMAGES_PERMISSIONS, 'tabid-2');
65: $tab2->addElement(new Xoops\Form\SelectGroup(_AM_IMAGES_CAT_READ_GRP, 'readgroup', true, $read, 5, true));
66: $tab2->addElement(new Xoops\Form\SelectGroup(_AM_IMAGES_CAT_WRITE_GRP, 'writegroup', true, $write, 5, true));
67:
68: $tabTray->addElement($tab1);
69: $tabTray->addElement($tab2);
70: $this->addElement($tabTray);
71:
72: $this->addElement(new Xoops\Form\Hidden('imgcat_id', $obj->getVar('imgcat_id')));
73:
74: 75: 76:
77: $buttonTray = new Xoops\Form\ElementTray('', '');
78: $buttonTray->addElement(new Xoops\Form\Hidden('op', 'save'));
79:
80: $buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
81: $buttonSubmit->setClass('btn btn-success');
82: $buttonTray->addElement($buttonSubmit);
83:
84: $buttonReset = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
85: $buttonReset->setClass('btn btn-warning');
86: $buttonTray->addElement($buttonReset);
87:
88: $buttonCancel = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
89: $buttonCancel->set('onclick', 'javascript:history.go(-1);');
90: $buttonCancel->setClass('btn btn-danger');
91: $buttonTray->addElement($buttonCancel);
92:
93: $this->addElement($buttonTray);
94: }
95: }
96: