XCL Web Application Platform
2.5.0
The XoopsCube Legacy Project
📘
Loading...
Searching...
No Matches
BannerAdminEditForm.class.php
1
<?php
6
7
if
(!defined(
'XOOPS_ROOT_PATH'
)) {
8
exit();
9
}
10
11
require_once XOOPS_ROOT_PATH .
'/core/XCube_ActionForm.class.php'
;
12
require_once XOOPS_MODULE_PATH .
'/legacy/class/Legacy_Validator.class.php'
;
13
14
/***
15
* @internal
16
* @todo This form doesn't validate the format of URL. Isn't OK?
17
*/
18
class
LegacyRender_BannerAdminEditForm
extends
XCube_ActionForm
19
{
20
public
function
getTokenName
()
21
{
22
return
'module.legacyRender.BannerAdminEditForm.TOKEN'
. $this->
get
(
'bid'
);
23
}
24
25
public
function
prepare
()
26
{
27
//
28
// Set form properties
29
//
30
$this->mFormProperties[
'bid'
] =
new
XCube_IntProperty
(
'bid'
);
31
$this->mFormProperties[
'cid'
] =
new
XCube_IntProperty
(
'cid'
);
32
$this->mFormProperties[
'imptotal'
] =
new
XCube_IntProperty
(
'imptotal'
);
33
$this->mFormProperties[
'imageurl'
] =
new
XCube_StringProperty
(
'imageurl'
);
34
$this->mFormProperties[
'clickurl'
] =
new
XCube_StringProperty
(
'clickurl'
);
35
$this->mFormProperties[
'htmlbanner'
] =
new
XCube_BoolProperty
(
'htmlbanner'
);
36
$this->mFormProperties[
'htmlcode'
] =
new
XCube_TextProperty
(
'htmlcode'
);
37
38
//
39
// Set field properties
40
//
41
$this->mFieldProperties[
'bid'
] =
new
XCube_FieldProperty
($this);
42
$this->mFieldProperties[
'bid'
]->setDependsByArray([
'required'
]);
43
$this->mFieldProperties[
'bid'
]->addMessage(
'required'
, _AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_BID);
44
45
$this->mFieldProperties[
'cid'
] =
new
XCube_FieldProperty
($this);
46
$this->mFieldProperties[
'cid'
]->setDependsByArray([
'required'
,
'objectExist'
]);
47
$this->mFieldProperties[
'cid'
]->addMessage(
'required'
, _AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_CID);
48
$this->mFieldProperties[
'cid'
]->addMessage(
'objectExist'
, _AD_LEGACYRENDER_ERROR_OBJECT_EXIST, _AD_LEGACYRENDER_LANG_CID);
49
$this->mFieldProperties[
'cid'
]->addVar(
'handler'
,
'bannerclient'
);
50
$this->mFieldProperties[
'cid'
]->addVar(
'module'
,
'legacyRender'
);
51
52
$this->mFieldProperties[
'imptotal'
] =
new
XCube_FieldProperty
($this);
53
$this->mFieldProperties[
'imptotal'
]->setDependsByArray([
'required'
]);
54
$this->mFieldProperties[
'imptotal'
]->addMessage(
'required'
, _AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_IMPTOTAL);
55
56
$this->mFieldProperties[
'imageurl'
] =
new
XCube_FieldProperty
($this);
57
$this->mFieldProperties[
'imageurl'
]->setDependsByArray([
'maxlength'
]);
58
$this->mFieldProperties[
'imageurl'
]->addMessage(
'maxlength'
, _AD_LEGACYRENDER_ERROR_MAXLENGTH, _AD_LEGACYRENDER_LANG_IMAGEURL,
'255'
);
59
$this->mFieldProperties[
'imageurl'
]->addVar(
'maxlength'
,
'255'
);
60
61
$this->mFieldProperties[
'clickurl'
] =
new
XCube_FieldProperty
($this);
62
$this->mFieldProperties[
'clickurl'
]->setDependsByArray([
'maxlength'
]);
63
$this->mFieldProperties[
'clickurl'
]->addMessage(
'maxlength'
, _AD_LEGACYRENDER_ERROR_MAXLENGTH, _AD_LEGACYRENDER_LANG_CLICKURL,
'255'
);
64
$this->mFieldProperties[
'clickurl'
]->addVar(
'maxlength'
,
'255'
);
65
}
66
67
public
function
validate
()
68
{
69
parent::validate();
70
71
//
72
// If htmlbanner is clicked, htmlbanner is requreid.
73
//
74
if
($this->
get
(
'htmlbanner'
)) {
75
if
(0 == strlen($this->
get
(
'htmlcode'
))) {
76
$this->
addErrorMessage
(
XCube_Utils::formatString
(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_HTMLCODE));
77
}
78
}
else
{
79
if
(0 == strlen($this->
get
(
'imageurl'
))) {
80
$this->
addErrorMessage
(
XCube_Utils::formatString
(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_IMAGEURL));
81
}
82
if
(0 == strlen($this->
get
(
'clickurl'
))) {
83
$this->
addErrorMessage
(
XCube_Utils::formatString
(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_CLICKURL));
84
}
85
}
86
}
87
88
public
function
load
(&$obj)
89
{
90
$this->
set
(
'bid'
, $obj->get(
'bid'
));
91
$this->
set
(
'cid'
, $obj->get(
'cid'
));
92
$this->
set
(
'imptotal'
, $obj->get(
'imptotal'
));
93
$this->
set
(
'imageurl'
, $obj->get(
'imageurl'
));
94
$this->
set
(
'clickurl'
, $obj->get(
'clickurl'
));
95
$this->
set
(
'htmlbanner'
, $obj->get(
'htmlbanner'
));
96
$this->
set
(
'htmlcode'
, $obj->get(
'htmlcode'
));
97
}
98
99
public
function
update
(&$obj)
100
{
101
$obj->set(
'bid'
, $this->
get
(
'bid'
));
102
$obj->set(
'cid'
, $this->
get
(
'cid'
));
103
$obj->set(
'imptotal'
, $this->
get
(
'imptotal'
));
104
$obj->set(
'imageurl'
, $this->
get
(
'imageurl'
));
105
$obj->set(
'clickurl'
, $this->
get
(
'clickurl'
));
106
$obj->set(
'htmlbanner'
, $this->
get
(
'htmlbanner'
));
107
$obj->set(
'htmlcode'
, $this->
get
(
'htmlcode'
));
108
}
109
}
LegacyRender_BannerAdminEditForm
Definition
BannerAdminEditForm.class.php:19
LegacyRender_BannerAdminEditForm\validate
validate()
Validates fetched values.
Definition
BannerAdminEditForm.class.php:67
LegacyRender_BannerAdminEditForm\update
update(&$obj)
[Abstract] Updates an object with properties values.
Definition
BannerAdminEditForm.class.php:99
LegacyRender_BannerAdminEditForm\getTokenName
getTokenName()
Gets the token name of this actionform's token.
Definition
BannerAdminEditForm.class.php:20
LegacyRender_BannerAdminEditForm\prepare
prepare()
[Abstract] Set up form properties and field properties.
Definition
BannerAdminEditForm.class.php:25
LegacyRender_BannerAdminEditForm\load
load(&$obj)
[Abstract] Initializes properties' values from an object.
Definition
BannerAdminEditForm.class.php:88
XCube_ActionForm
Definition
XCube_ActionForm.class.php:51
XCube_ActionForm\addErrorMessage
addErrorMessage( $message)
Adds a message to the form's error message buffer.
Definition
XCube_ActionForm.class.php:386
XCube_BoolProperty
Represents bool property.
Definition
XCube_Property.class.php:440
XCube_FieldProperty
[Abstract] Used for validating member property values of XCube_ActionForm.
Definition
XCube_ActionForm.class.php:438
XCube_IntProperty
Represents int property.
Definition
XCube_Property.class.php:461
XCube_StringProperty
Represents string property.
Definition
XCube_Property.class.php:506
XCube_TextProperty
Represents string property which allows CR and LF.
Definition
XCube_Property.class.php:540
XCube_Utils\formatString
static formatString()
[Static] Formats string with special care for international.
Definition
XCube_Utils.class.php:70
html
modules
legacyRender
admin
forms
BannerAdminEditForm.class.php
Generated by
1.13.2