XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
CustomBlockEditForm.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
16require_once XOOPS_ROOT_PATH . '/core/XCube_ActionForm.class.php';
17require_once XOOPS_MODULE_PATH . '/legacy/class/Legacy_Validator.class.php';
18require_once XOOPS_MODULE_PATH . '/legacy/admin/forms/BlockEditForm.class.php';
19
21{
22 public function getTokenName()
23 {
24 return 'module.legacy.CustomBlockEditForm.TOKEN' . $this->get('bid');
25 }
26
27 public function prepare()
28 {
29 parent::prepare();
30
31 //
32 // Set form properties
33 //
34 $this->mFormProperties['content'] =new XCube_TextProperty('content');
35 $this->mFormProperties['c_type'] =new XCube_StringProperty('c_type');
36
37 //
38 // Set field properties
39 //
40 $this->mFieldProperties['content'] =new XCube_FieldProperty($this);
41 $this->mFieldProperties['content']->setDependsByArray(['required']);
42 $this->mFieldProperties['content']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_CONTENT);
43
44 $this->mFieldProperties['c_type'] =new XCube_FieldProperty($this);
45 $this->mFieldProperties['c_type']->setDependsByArray(['required', 'maxlength']);
46 $this->mFieldProperties['c_type']->addMessage('required', _MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_C_TYPE, '1');
47 $this->mFieldProperties['c_type']->addMessage('maxlength', _MD_LEGACY_ERROR_MAXLENGTH, _AD_LEGACY_LANG_C_TYPE, '1');
48 $this->mFieldProperties['c_type']->addVar('maxlength', '1');
49 }
50
51 public function load(&$obj)
52 {
53 parent::load($obj);
54 $this->set('content', $obj->get('content'));
55 $this->set('c_type', $obj->get('c_type'));
56 }
57
58 public function update(&$obj)
59 {
60 parent::update($obj);
61 $obj->set('content', $this->get('content'));
62 $obj->set('block_type', 'C');
63 $obj->set('c_type', $this->get('c_type'));
64 $obj->set('visible', 1);
65 $obj->set('isactive', 1);
66
67 switch ($this->get('c_type')) {
68 case 'H':
69 $obj->set('name', _AD_LEGACY_LANG_CUSTOM_HTML);
70 break;
71
72 case 'P':
73 $obj->set('name', _AD_LEGACY_LANG_CUSTOM_PHP);
74 break;
75
76 case 'S':
77 $obj->set('name', _AD_LEGACY_LANG_CUSTOM_WITH_SMILIES);
78 break;
79
80 case 'T':
81 $obj->set('name', _AD_LEGACY_LANG_CUSTOM_WITHOUT_SMILIES);
82 break;
83 }
84 }
85}
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 string property.
Represents string property which allows CR and LF.