1: <?php
2:
3: if (!defined('XOOPS_ROOT_PATH')) exit();
4:
5: require_once XOOPS_ROOT_PATH . "/core/XCube_ActionForm.class.php";
6: require_once XOOPS_MODULE_PATH . "/legacy/class/Legacy_Validator.class.php";
7:
8: class Legacy_ModuleEditForm extends XCube_ActionForm
9: {
10: function getTokenName()
11: {
12: return "module.legacy.ModuleEditForm.TOKEN" . $this->get('mid');
13: }
14:
15: function prepare()
16: {
17:
18:
19:
20: $this->mFormProperties['mid'] =new XCube_IntProperty('mid');
21: $this->mFormProperties['name'] =new XCube_StringProperty('name');
22: $this->mFormProperties['weight'] =new XCube_IntProperty('weight');
23: $this->mFormProperties['read_groupid'] =new XCube_IntArrayProperty('read_groupid');
24: $this->mFormProperties['admin_groupid'] =new XCube_IntArrayProperty('admin_groupid');
25: $this->mFormProperties['module_cache'] =new XCube_StringProperty('module_cache');
26:
27:
28:
29:
30: $this->mFieldProperties['mid'] =new XCube_FieldProperty($this);
31: $this->mFieldProperties['mid']->setDependsByArray(array('required'));
32: $this->mFieldProperties['mid']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_MOD_MID);
33:
34: $this->mFieldProperties['name'] =new XCube_FieldProperty($this);
35: $this->mFieldProperties['name']->setDependsByArray(array('required','maxlength'));
36: $this->mFieldProperties['name']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_NAME, '255');
37: $this->mFieldProperties['name']->addMessage('maxlength', _MD_LEGACY_ERROR_MAXLENGTH, _AD_LEGACY_LANG_NAME, '255');
38: $this->mFieldProperties['name']->addVar('maxlength', '255');
39:
40: $this->mFieldProperties['weight'] =new XCube_FieldProperty($this);
41: $this->mFieldProperties['weight']->setDependsByArray(array('required', 'intRange'));
42: $this->mFieldProperties['weight']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_WEIGHT);
43: $this->mFieldProperties['weight']->addMessage('intRange', _AD_LEGACY_ERROR_INTRANGE, _AD_LEGACY_LANG_WEIGHT);
44: $this->mFieldProperties['weight']->addVar('min', '0');
45: $this->mFieldProperties['weight']->addVar('max', '255');
46:
47: $this->mFieldProperties['read_groupid'] =new XCube_FieldProperty($this);
48: $this->mFieldProperties['read_groupid']->setDependsByArray(array('objectExist'));
49: $this->mFieldProperties['read_groupid']->addMessage('objectExist', _AD_LEGACY_ERROR_OBJECTEXIST, _AD_LEGACY_LANG_GROUPID);
50: $this->mFieldProperties['read_groupid']->addVar('handler', 'group');
51:
52: $this->mFieldProperties['admin_groupid'] =new XCube_FieldProperty($this);
53: $this->mFieldProperties['admin_groupid']->setDependsByArray(array('objectExist'));
54: $this->mFieldProperties['admin_groupid']->addMessage('objectExist', _AD_LEGACY_ERROR_OBJECTEXIST, _AD_LEGACY_LANG_GROUPID);
55: $this->mFieldProperties['admin_groupid']->addVar('handler', 'group');
56:
57: $this->mFieldProperties['module_cache'] =new XCube_FieldProperty($this);
58: $this->mFieldProperties['module_cache']->setDependsByArray(array('required', 'objectExist'));
59: $this->mFieldProperties['module_cache']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _MD_AM_MODCACHE);
60: $this->mFieldProperties['module_cache']->addMessage('objectExist', _AD_LEGACY_ERROR_OBJECTEXIST, _MD_AM_MODCACHE);
61: $this->mFieldProperties['module_cache']->addVar('handler', 'cachetime');
62:
63: }
64:
65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82:
83: function load(&$obj)
84: {
85: $this->set('mid', $obj->get('mid'));
86: $this->set('name', $obj->get('name'));
87: $this->set('weight', $obj->get('weight'));
88:
89: $root =& XCube_Root::getSingleton();
90: $module_cache = !empty($root->mContext->mXoopsConfig['module_cache'][$obj->get('mid')]) ? $root->mContext->mXoopsConfig['module_cache'][$obj->get('mid')]: 0;
91: $this->set('module_cache', $module_cache);
92: }
93:
94: function update(&$obj)
95: {
96:
97: $obj->set('name', $this->get('name'));
98: $obj->set('weight', $this->get('weight'));
99: }
100: }
101:
102: ?>
103: