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:
15: class Legacy_SmilesAdminEditForm extends XCube_ActionForm
16: {
17: var $mOldFileName = null;
18: var $_mIsNew = null;
19: var $mFormFile = null;
20:
21: function getTokenName()
22: {
23: return "module.legacy.SmilesAdminEditForm.TOKEN" . $this->get('id');
24: }
25:
26: function prepare()
27: {
28:
29:
30:
31: $this->mFormProperties['id'] =new XCube_IntProperty('id');
32: $this->mFormProperties['code'] =new XCube_StringProperty('code');
33: $this->mFormProperties['smile_url'] =new XCube_ImageFileProperty('smile_url');
34: $this->mFormProperties['emotion'] =new XCube_StringProperty('emotion');
35: $this->mFormProperties['display'] =new XCube_BoolProperty('display');
36:
37:
38:
39:
40: $this->mFieldProperties['id'] =new XCube_FieldProperty($this);
41: $this->mFieldProperties['id']->setDependsByArray(array('required'));
42: $this->mFieldProperties['id']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_ID);
43:
44: $this->mFieldProperties['code'] =new XCube_FieldProperty($this);
45: $this->mFieldProperties['code']->setDependsByArray(array('required','maxlength'));
46: $this->mFieldProperties['code']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _MD_LEGACY_LANG_CODE, '50');
47: $this->mFieldProperties['code']->addMessage('maxlength', _MD_LEGACY_ERROR_MAXLENGTH, _MD_LEGACY_LANG_CODE, '50');
48: $this->mFieldProperties['code']->addVar('maxlength', '50');
49:
50: $this->mFieldProperties['smile_url'] =new XCube_FieldProperty($this);
51: $this->mFieldProperties['smile_url']->setDependsByArray(array('extension'));
52: $this->mFieldProperties['smile_url']->addMessage('extension', _AD_LEGACY_ERROR_EXTENSION);
53: $this->mFieldProperties['smile_url']->addVar('extension', 'jpg,gif,png');
54:
55: $this->mFieldProperties['emotion'] =new XCube_FieldProperty($this);
56: $this->mFieldProperties['emotion']->setDependsByArray(array('required','maxlength'));
57: $this->mFieldProperties['emotion']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _MD_LEGACY_LANG_EMOTION, '75');
58: $this->mFieldProperties['emotion']->addMessage('maxlength', _MD_LEGACY_ERROR_MAXLENGTH, _MD_LEGACY_LANG_EMOTION, '75');
59: $this->mFieldProperties['emotion']->addVar('maxlength', '75');
60: }
61:
62: function validateSmile_url()
63: {
64: if ($this->_mIsNew && $this->get('smile_url') == null) {
65: $this->addErrorMessage(XCube_Utils::formatMessage(_MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_SMILE_URL));
66: }
67: }
68:
69: function load(&$obj)
70: {
71: $this->set('id', $obj->get('id'));
72: $this->set('code', $obj->get('code'));
73: $this->set('emotion', $obj->get('emotion'));
74: $this->set('display', $obj->get('display'));
75:
76: $this->_mIsNew = $obj->isNew();
77: $this->mOldFileName = $obj->get('smile_url');
78: }
79:
80: function update(&$obj)
81: {
82: $obj->set('id', $this->get('id'));
83: $obj->set('code', $this->get('code'));
84: $obj->set('emotion', $this->get('emotion'));
85: $obj->set('display', $this->get('display'));
86:
87: $this->mFormFile = $this->get('smile_url');
88: if ($this->mFormFile != null) {
89: $this->mFormFile->setRandomToBodyName('smil');
90: $obj->set('smile_url', $this->mFormFile->getFileName());
91: }
92: }
93: }
94:
95: ?>
96: