1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* @城市表单 |
4
|
|
|
* @license http://www.blags.org/ |
5
|
|
|
* @created :2010年05月20日 23时52分 |
6
|
|
|
* @copyright 1997-2010 The Martin Group |
7
|
|
|
* @author Martin <[email protected]> |
8
|
|
|
* */ |
9
|
|
|
if (!defined('XOOPS_ROOT_PATH')) { |
10
|
|
|
return; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class form_hotel_promotion |
17
|
|
|
*/ |
18
|
|
|
class form_hotel_promotion extends XoopsThemeForm |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* form_hotel_promotion constructor. |
22
|
|
|
* @param $HotelPromotionObj |
23
|
|
|
* @param $HotelList |
24
|
|
|
*/ |
25
|
|
View Code Duplication |
public function __construct(&$HotelPromotionObj, &$HotelList) |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
$this->Obj = &$HotelPromotionObj; |
28
|
|
|
$this->HotelList = &$HotelList; |
29
|
|
|
parent::__construct(_AM_MARTIN_HOTEL_CITY_LIST, "op", xoops_getenv('PHP_SELF') . "?action=save"); |
30
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
31
|
|
|
|
32
|
|
|
$this->createElements(); |
33
|
|
|
$this->createButtons(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* created elements |
38
|
|
|
* @license http://www.blags.org/ |
39
|
|
|
* @created :2010年05月21日 20时40分 |
40
|
|
|
* @copyright 1997-2010 The Martin Group |
41
|
|
|
* @author Martin <[email protected]> |
42
|
|
|
* */ |
43
|
|
|
public function createElements() |
44
|
|
|
{ |
45
|
|
|
//include_once MARTIN_ROOT_PATH . '/include/formdatetime.php'; |
|
|
|
|
46
|
|
|
include_once XOOPS_ROOT_PATH . "/modules/martin/class/xoopsformloader.php"; |
47
|
|
|
|
48
|
|
|
$js = '<script type=\'text/javascript\'> |
49
|
|
|
jQuery.noConflict(); |
50
|
|
|
</script>'; |
51
|
|
|
$RoomElement = new XoopsFormSelect($js . _AM_MARTIN_PROMO_HOTELS, 'hotel_id', $this->HotelList, 0, false); |
52
|
|
|
$RoomElement->addOptionArray($this->HotelList); |
53
|
|
|
$this->addElement($RoomElement, false); |
54
|
|
|
|
55
|
|
|
$this->addElement(new XoopsFormTextDateSelect(_AM_MARTIN_PROMO_START, 'promotion_start_date', $size = 15, $this->Obj->promotion_start_date(), false), true); |
56
|
|
|
|
57
|
|
|
$this->addElement(new XoopsFormTextDateSelect(_AM_MARTIN_PROMO_END, 'promotion_end_date', $size = 15, $this->Obj->promotion_end_date(), false), true); |
58
|
|
|
|
59
|
|
|
$editor = 'tinymce'; |
60
|
|
|
$editor_configs = array(); |
61
|
|
|
$editor_configs["name"] = "promotion_description"; |
62
|
|
|
$editor_configs["value"] = $this->Obj->promotion_description(); |
63
|
|
|
$editor_configs["rows"] = empty($xoopsModuleConfig["editor_rows"]) ? 35 : $xoopsModuleConfig["editor_rows"]; |
|
|
|
|
64
|
|
|
$editor_configs["cols"] = empty($xoopsModuleConfig["editor_cols"]) ? 60 : $xoopsModuleConfig["editor_cols"]; |
65
|
|
|
$editor_configs["width"] = empty($xoopsModuleConfig["editor_width"]) ? "100%" : $xoopsModuleConfig["editor_width"]; |
66
|
|
|
$editor_configs["height"] = empty($xoopsModuleConfig["editor_height"]) ? "400px" : $xoopsModuleConfig["editor_height"]; |
67
|
|
|
$this->addElement(new XoopsFormEditor(_AM_MARTIN_PROMOTION_DETAILS, $editor, $editor_configs, false, $onfailure = null), false); |
68
|
|
|
|
69
|
|
|
$this->addElement(new XoopsFormHidden('id', $this->Obj->promotion_id())); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @创建按钮 |
74
|
|
|
* @license http://www.blags.org/ |
75
|
|
|
* @created :2010年05月20日 23时52分 |
76
|
|
|
* @copyright 1997-2010 The Martin Group |
77
|
|
|
* @author Martin <[email protected]> |
78
|
|
|
* */ |
79
|
|
View Code Duplication |
public function createButtons() |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
82
|
|
|
// No ID for category -- then it's new category, button says 'Create' |
83
|
|
|
if (!$this->Obj->promotion_id()) { |
84
|
|
|
$butt_create = new XoopsFormButton('', '', _SUBMIT, 'submit'); |
85
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
86
|
|
|
$button_tray->addElement($butt_create); |
87
|
|
|
|
88
|
|
|
$butt_clear = new XoopsFormButton('', '', _RESET, 'reset'); |
89
|
|
|
$button_tray->addElement($butt_clear); |
90
|
|
|
|
91
|
|
|
$butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button'); |
92
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
93
|
|
|
$button_tray->addElement($butt_cancel); |
94
|
|
|
|
95
|
|
|
$this->addElement($button_tray); |
96
|
|
|
} else { |
97
|
|
|
// button says 'Update' |
98
|
|
|
$butt_create = new XoopsFormButton('', '', _EDIT, 'submit'); |
99
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
100
|
|
|
$button_tray->addElement($butt_create); |
101
|
|
|
|
102
|
|
|
$butt_clear = new XoopsFormButton('', '', _RESET, 'reset'); |
103
|
|
|
$button_tray->addElement($butt_clear); |
104
|
|
|
|
105
|
|
|
$butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button'); |
106
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
107
|
|
|
$button_tray->addElement($butt_cancel); |
108
|
|
|
|
109
|
|
|
$this->addElement($button_tray); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.