XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
ModuleEditForm.class.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
15require_once XOOPS_ROOT_PATH . '/core/XCube_ActionForm.class.php';
16require_once XOOPS_MODULE_PATH . '/legacy/class/Legacy_Validator.class.php';
17
19{
20 public function getTokenName()
21 {
22 return 'module.legacy.ModuleEditForm.TOKEN' . $this->get('mid');
23 }
24
25 public function prepare()
26 {
27 //
28 // Set form properties
29 //
30 $this->mFormProperties['mid'] =new XCube_IntProperty('mid');
31 $this->mFormProperties['name'] =new XCube_StringProperty('name');
32 $this->mFormProperties['weight'] =new XCube_IntProperty('weight');
33 $this->mFormProperties['read_groupid'] =new XCube_IntArrayProperty('read_groupid');
34 $this->mFormProperties['admin_groupid'] =new XCube_IntArrayProperty('admin_groupid');
35 $this->mFormProperties['module_cache'] =new XCube_StringProperty('module_cache');
36
37 //
38 // Set field properties
39 //
40 $this->mFieldProperties['mid'] =new XCube_FieldProperty($this);
41 $this->mFieldProperties['mid']->setDependsByArray(['required']);
42 $this->mFieldProperties['mid']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_MOD_MID);
43
44 $this->mFieldProperties['name'] =new XCube_FieldProperty($this);
45 $this->mFieldProperties['name']->setDependsByArray(['required', 'maxlength']);
46 $this->mFieldProperties['name']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_NAME, '191');
47 $this->mFieldProperties['name']->addMessage('maxlength', _MD_LEGACY_ERROR_MAXLENGTH, _AD_LEGACY_LANG_NAME, '191');
48 $this->mFieldProperties['name']->addVar('maxlength', '191');
49
50 $this->mFieldProperties['weight'] =new XCube_FieldProperty($this);
51 $this->mFieldProperties['weight']->setDependsByArray(['required', 'intRange']);
52 $this->mFieldProperties['weight']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_WEIGHT);
53 $this->mFieldProperties['weight']->addMessage('intRange', _AD_LEGACY_ERROR_INTRANGE, _AD_LEGACY_LANG_WEIGHT);
54 $this->mFieldProperties['weight']->addVar('min', '0');
55 $this->mFieldProperties['weight']->addVar('max', '65535');
56
57 $this->mFieldProperties['read_groupid'] =new XCube_FieldProperty($this);
58 $this->mFieldProperties['read_groupid']->setDependsByArray(['objectExist']);
59 $this->mFieldProperties['read_groupid']->addMessage('objectExist', _AD_LEGACY_ERROR_OBJECTEXIST, _AD_LEGACY_LANG_GROUPID);
60 $this->mFieldProperties['read_groupid']->addVar('handler', 'group');
61
62 $this->mFieldProperties['admin_groupid'] =new XCube_FieldProperty($this);
63 $this->mFieldProperties['admin_groupid']->setDependsByArray(['objectExist']);
64 $this->mFieldProperties['admin_groupid']->addMessage('objectExist', _AD_LEGACY_ERROR_OBJECTEXIST, _AD_LEGACY_LANG_GROUPID);
65 $this->mFieldProperties['admin_groupid']->addVar('handler', 'group');
66
67 $this->mFieldProperties['module_cache'] =new XCube_FieldProperty($this);
68 $this->mFieldProperties['module_cache']->setDependsByArray(['required', 'objectExist']);
69 $this->mFieldProperties['module_cache']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _MD_AM_MODCACHE);
70 $this->mFieldProperties['module_cache']->addMessage('objectExist', _AD_LEGACY_ERROR_OBJECTEXIST, _MD_AM_MODCACHE);
71 $this->mFieldProperties['module_cache']->addVar('handler', 'cachetime');
72 }
73
74/*
75//Umm...some modules have no readgroup or no admingroup
76 function validateRead_groupid()
77 {
78 $groupid = $this->get('read_groupid');
79 if (!(count($groupid))) {
80 $this->addErrorMessage(_AD_LEGACY_ERROR_GROUPID);
81 }
82 }
83
84 function validateAdmin_groupid()
85 {
86 $groupid = $this->get('admin_groupid');
87 if (!(count($groupid))) {
88 $this->addErrorMessage(_AD_LEGACY_ERROR_GROUPID);
89 }
90 }
91*/
92 public function load(&$obj)
93 {
94 $this->set('mid', $obj->get('mid'));
95 $this->set('name', $obj->get('name'));
96 $this->set('weight', $obj->get('weight'));
97
98 $root =& XCube_Root::getSingleton();
99 $module_cache = !empty($root->mContext->mXoopsConfig['module_cache'][$obj->get('mid')]) ? $root->mContext->mXoopsConfig['module_cache'][$obj->get('mid')]: 0;
100 $this->set('module_cache', $module_cache);
101 }
102
103 public function update(&$obj)
104 {
105 $obj->set('name', $this->get('name'));
106 $obj->set('weight', $this->get('weight'));
107 }
108}
update(&$obj)
[Abstract] Updates an object with properties values.
getTokenName()
Gets the token name of this actionform's token.
prepare()
[Abstract] Set up form properties and field properties.
load(&$obj)
[Abstract] Initializes properties' values from an object.
[Abstract] Used for validating member property values of XCube_ActionForm.
Represents int[] property. XCube_GenericArrayProperty<XCube_IntProperty>.
Represents int property.
Represents string property.