XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
SmilesAdminEditForm.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
16require_once XOOPS_ROOT_PATH . '/core/XCube_ActionForm.class.php';
17
19{
20 public $mOldFileName = null;
21 public $_mIsNew = null;
22 public $mFormFile = null;
23
24 public function getTokenName()
25 {
26 return 'module.legacy.SmilesAdminEditForm.TOKEN' . $this->get('id');
27 }
28
29 public function prepare()
30 {
31 //
32 // Set form properties
33 //
34 $this->mFormProperties['id'] =new XCube_IntProperty('id');
35 $this->mFormProperties['code'] =new XCube_StringProperty('code');
36 $this->mFormProperties['smile_url'] =new XCube_ImageFileProperty('smile_url');
37 $this->mFormProperties['emotion'] =new XCube_StringProperty('emotion');
38 $this->mFormProperties['display'] =new XCube_BoolProperty('display');
39
40 //
41 // Set field properties
42 //
43 $this->mFieldProperties['id'] =new XCube_FieldProperty($this);
44 $this->mFieldProperties['id']->setDependsByArray(['required']);
45 $this->mFieldProperties['id']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_ID);
46
47 $this->mFieldProperties['code'] =new XCube_FieldProperty($this);
48 $this->mFieldProperties['code']->setDependsByArray(['required', 'maxlength']);
49 $this->mFieldProperties['code']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _MD_LEGACY_LANG_CODE, '50');
50 $this->mFieldProperties['code']->addMessage('maxlength', _MD_LEGACY_ERROR_MAXLENGTH, _MD_LEGACY_LANG_CODE, '50');
51 $this->mFieldProperties['code']->addVar('maxlength', '50');
52
53 $this->mFieldProperties['smile_url'] =new XCube_FieldProperty($this);
54 $this->mFieldProperties['smile_url']->setDependsByArray(['extension']);
55 $this->mFieldProperties['smile_url']->addMessage('extension', _AD_LEGACY_ERROR_EXTENSION);
56 $this->mFieldProperties['smile_url']->addVar('extension', 'jpg,gif,png');
57
58 $this->mFieldProperties['emotion'] =new XCube_FieldProperty($this);
59 $this->mFieldProperties['emotion']->setDependsByArray(['required', 'maxlength']);
60 $this->mFieldProperties['emotion']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _MD_LEGACY_LANG_EMOTION, '75');
61 $this->mFieldProperties['emotion']->addMessage('maxlength', _MD_LEGACY_ERROR_MAXLENGTH, _MD_LEGACY_LANG_EMOTION, '75');
62 $this->mFieldProperties['emotion']->addVar('maxlength', '75');
63 }
64
65 public function validateSmile_url()
66 {
67 if ($this->_mIsNew && null == $this->get('smile_url')) {
68 $this->addErrorMessage(XCube_Utils::formatString(_MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_SMILE_URL));
69 }
70 }
71
72 public function load(&$obj)
73 {
74 $this->set('id', $obj->get('id'));
75 $this->set('code', $obj->get('code'));
76 $this->set('emotion', $obj->get('emotion'));
77 $this->set('display', $obj->get('display'));
78
79 $this->_mIsNew = $obj->isNew();
80 $this->mOldFileName = $obj->get('smile_url');
81 }
82
83 public function update(&$obj)
84 {
85 $obj->set('id', $this->get('id'));
86 $obj->set('code', $this->get('code'));
87 $obj->set('emotion', $this->get('emotion'));
88 $obj->set('display', $this->get('display'));
89
90 $this->mFormFile = $this->get('smile_url');
91 if (null != $this->mFormFile) {
92 $this->mFormFile->setRandomToBodyName('smil'); // Fix your prefix
93 $obj->set('smile_url', $this->mFormFile->getFileName());
94 }
95 }
96}
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.
addErrorMessage( $message)
Adds a message to the form's error message buffer.
Represents bool property.
[Abstract] Used for validating member property values of XCube_ActionForm.
This is extended XCube_FileProperty and limits uploaded files by image files.
Represents int property.
Represents string property.
static formatString()
[Static] Formats string with special care for international.