1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: require_once XOOPS_ROOT_PATH . "/core/XCube_ActionForm.class.php";
14: require_once XOOPS_MODULE_PATH . "/legacy/class/Legacy_Validator.class.php";
15:
16: class Legacy_ImagecategoryAdminEditForm extends XCube_ActionForm
17: {
18: function getTokenName()
19: {
20: return "module.legacy.ImagecategoryAdminEditForm.TOKEN" . $this->get('imgcat_id');
21: }
22:
23: function prepare()
24: {
25:
26:
27:
28: $this->mFormProperties['imgcat_id'] =new XCube_IntProperty('imgcat_id');
29: $this->mFormProperties['imgcat_name'] =new XCube_StringProperty('imgcat_name');
30: $this->mFormProperties['imgcat_maxsize'] =new XCube_IntProperty('imgcat_maxsize');
31: $this->mFormProperties['imgcat_maxwidth'] =new XCube_IntProperty('imgcat_maxwidth');
32: $this->mFormProperties['imgcat_maxheight'] =new XCube_IntProperty('imgcat_maxheight');
33: $this->mFormProperties['imgcat_display'] =new XCube_BoolProperty('imgcat_display');
34: $this->mFormProperties['imgcat_weight'] =new XCube_IntProperty('imgcat_weight');
35: $this->mFormProperties['readgroups'] =new XCube_IntArrayProperty('readgroups');
36: $this->mFormProperties['uploadgroups'] =new XCube_IntArrayProperty('uploadgroups');
37:
38:
39:
40:
41: $this->mFieldProperties['imgcat_id'] =new XCube_FieldProperty($this);
42: $this->mFieldProperties['imgcat_id']->setDependsByArray(array('required'));
43: $this->mFieldProperties['imgcat_id']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_IMGCAT_ID);
44:
45: $this->mFieldProperties['imgcat_name'] =new XCube_FieldProperty($this);
46: $this->mFieldProperties['imgcat_name']->setDependsByArray(array('required','maxlength'));
47: $this->mFieldProperties['imgcat_name']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_IMGCAT_NAME, '100');
48: $this->mFieldProperties['imgcat_name']->addMessage('maxlength', _MD_LEGACY_ERROR_MAXLENGTH, _AD_LEGACY_LANG_IMGCAT_NAME, '100');
49: $this->mFieldProperties['imgcat_name']->addVar('maxlength', '100');
50:
51: $this->mFieldProperties['imgcat_maxsize'] =new XCube_FieldProperty($this);
52: $this->mFieldProperties['imgcat_maxsize']->setDependsByArray(array('required'));
53: $this->mFieldProperties['imgcat_maxsize']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_IMGCAT_MAXSIZE);
54:
55: $this->mFieldProperties['imgcat_maxwidth'] =new XCube_FieldProperty($this);
56: $this->mFieldProperties['imgcat_maxwidth']->setDependsByArray(array('required'));
57: $this->mFieldProperties['imgcat_maxwidth']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_IMGCAT_MAXWIDTH);
58:
59: $this->mFieldProperties['imgcat_maxheight'] =new XCube_FieldProperty($this);
60: $this->mFieldProperties['imgcat_maxheight']->setDependsByArray(array('required'));
61: $this->mFieldProperties['imgcat_maxheight']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_IMGCAT_MAXHEIGHT);
62:
63: $this->mFieldProperties['imgcat_weight'] =new XCube_FieldProperty($this);
64: $this->mFieldProperties['imgcat_weight']->setDependsByArray(array('required'));
65: $this->mFieldProperties['imgcat_weight']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_IMGCAT_WEIGHT);
66:
67: $this->mFieldProperties['readgroups'] =new XCube_FieldProperty($this);
68: $this->mFieldProperties['readgroups']->setDependsByArray(array('objectExist'));
69: $this->mFieldProperties['readgroups']->addMessage('objectExist', _AD_LEGACY_ERROR_OBJECTEXIST, _AD_LEGACY_LANG_IMGCAT_READ_GROUPS);
70: $this->mFieldProperties['readgroups']->addVar('handler', 'group');
71:
72: $this->mFieldProperties['uploadgroups'] =new XCube_FieldProperty($this);
73: $this->mFieldProperties['uploadgroups']->setDependsByArray(array('objectExist'));
74: $this->mFieldProperties['uploadgroups']->addMessage('objectExist', _AD_LEGACY_ERROR_OBJECTEXIST, _AD_LEGACY_LANG_IMGCAT_UPLOAD_GROUPS);
75: $this->mFieldProperties['uploadgroups']->addVar('handler', 'group');
76: }
77:
78: function validateReadgroups()
79: {
80: $readgroups = $this->get('readgroups');
81: if (count($readgroups) == 0) {
82: $this->addErrorMessage(_AD_LEGACY_ERROR_READGROUPS);
83: }
84: }
85:
86: function validateUploadgroups()
87: {
88: $uploadgroups = $this->get('uploadgroups');
89: if (count($uploadgroups) == 0) {
90: $this->addErrorMessage(_AD_LEGACY_ERROR_UPLOADGROUPS);
91: }
92: }
93:
94: function load(&$obj)
95: {
96: $this->set('imgcat_id', $obj->get('imgcat_id'));
97: $this->set('imgcat_name', $obj->get('imgcat_name'));
98: $this->set('imgcat_maxsize', $obj->get('imgcat_maxsize'));
99: $this->set('imgcat_maxwidth', $obj->get('imgcat_maxwidth'));
100: $this->set('imgcat_maxheight', $obj->get('imgcat_maxheight'));
101: $this->set('imgcat_display', $obj->get('imgcat_display'));
102: $this->set('imgcat_weight', $obj->get('imgcat_weight'));
103:
104: $i = 0;
105: foreach ($obj->mReadGroups as $group) {
106: $this->set('readgroups', $i++, $group->get('groupid'));
107: }
108:
109: $i = 0;
110: foreach ($obj->mUploadGroups as $group) {
111: $this->set('uploadgroups', $i++, $group->get('groupid'));
112: }
113: }
114:
115: function update(&$obj)
116: {
117: $obj->set('imgcat_id', $this->get('imgcat_id'));
118: $obj->set('imgcat_name', $this->get('imgcat_name'));
119: $obj->set('imgcat_maxsize', $this->get('imgcat_maxsize'));
120: $obj->set('imgcat_maxwidth', $this->get('imgcat_maxwidth'));
121: $obj->set('imgcat_maxheight', $this->get('imgcat_maxheight'));
122: $obj->set('imgcat_display', $this->get('imgcat_display'));
123: $obj->set('imgcat_weight', $this->get('imgcat_weight'));
124:
125: $handler =& xoops_gethandler('group');
126:
127: unset($obj->mReadGroups);
128: foreach ($this->get('readgroups') as $groupid) {
129: $obj->mReadGroups[] =& $handler->get($groupid);
130: }
131:
132: unset($obj->mUploadGroups);
133: foreach ($this->get('uploadgroups') as $groupid) {
134: $obj->mUploadGroups[] =& $handler->get($groupid);
135: }
136: }
137: }
138:
139: ?>
140: