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: require_once XOOPS_MODULE_PATH . "/legacy/forms/ImageUploadForm.class.php";
16:
17: class Legacy_ImageAdminCreateForm extends Legacy_ImageUploadForm
18: {
19: var $_mImgcatId = 0;
20:
21: function getTokenName()
22: {
23: return "module.legacy.ImageAdminEditForm.TOKEN" . $this->get('image_id');
24: }
25:
26: function prepare()
27: {
28: parent::prepare();
29:
30:
31:
32:
33: $this->mFormProperties['image_id'] =new XCube_IntProperty('image_id');
34: $this->mFormProperties['image_display'] =new XCube_BoolProperty('image_display');
35: $this->mFormProperties['image_weight'] =new XCube_IntProperty('image_weight');
36:
37:
38:
39:
40: $this->mFieldProperties['image_id'] =new XCube_FieldProperty($this);
41: $this->mFieldProperties['image_id']->setDependsByArray(array('required'));
42: $this->mFieldProperties['image_id']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_IMAGE_ID);
43:
44: $this->mFieldProperties['image_weight'] =new XCube_FieldProperty($this);
45: $this->mFieldProperties['image_weight']->setDependsByArray(array('required'));
46: $this->mFieldProperties['image_weight']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_IMAGE_WEIGHT);
47: }
48:
49: function load(&$obj)
50: {
51: parent::load($obj);
52: $this->set('image_id', $obj->get('image_id'));
53: $this->set('image_display', $obj->get('image_display'));
54: $this->set('image_weight', $obj->get('image_weight'));
55:
56: $this->_mImgcatId = $obj->get('imgcat_id');
57: }
58:
59: function update(&$obj)
60: {
61: parent::update($obj);
62: $obj->set('image_id', $this->get('image_id'));
63: $obj->set('image_display', $this->get('image_display'));
64: $obj->set('image_weight', $this->get('image_weight'));
65: }
66: }
67:
68: class Legacy_ImageAdminEditForm extends Legacy_ImageAdminCreateForm
69: {
70: function validateImgcat_id()
71: {
72: parent::validateImgcat_id();
73:
74: $handler =& xoops_getmodulehandler('imagecategory', 'legacy');
75: $currentCategory =& $handler->get($this->_mImgcatId);
76:
77: $specificCategory =& $handler->get($this->get('imgcat_id'));
78: if ($currentCategory->get('imgcat_storetype') != $specificCategory->get('imgcat_storetype')) {
79: $this->set('imgcat_id', $this->_mImgcatId);
80: }
81: }
82: }
83:
84: ?>
85: