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_service_relation |
17
|
|
|
*/ |
18
|
|
|
class form_hotel_service_relation extends XoopsThemeForm |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* form_hotel_service_relation constructor. |
22
|
|
|
* @param $Relation |
23
|
|
|
* @param $serviceList |
24
|
|
|
* @param $hotelList |
25
|
|
|
*/ |
26
|
|
|
public function __construct(&$Relation, &$serviceList, &$hotelList) |
27
|
|
|
{ |
28
|
|
|
$this->Obj = &$Relation; |
29
|
|
|
$this->serviceList = &$serviceList; |
30
|
|
|
$this->hotelList = &$hotelList; |
31
|
|
|
parent::__construct(_AM_MARTIN_HOTEL_ASSOCIATION, "op", xoops_getenv('PHP_SELF') . "?action=hotelsave&hotel_id={$Relation['hotel_id']}&service_id={$Relation['service_id']}"); |
32
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
33
|
|
|
$this->createElements(); |
34
|
|
|
$this->createButtons(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* created elements |
39
|
|
|
* @license http://www.blags.org/ |
40
|
|
|
* @created :2010年05月21日 20时40分 |
41
|
|
|
* @copyright 1997-2010 The Martin Group |
42
|
|
|
* @author Martin <[email protected]> |
43
|
|
|
* */ |
44
|
|
|
public function createElements() |
45
|
|
|
{ |
46
|
|
|
global $xoopsDB; |
|
|
|
|
47
|
|
|
$Relation = &$this->Obj; |
48
|
|
|
|
49
|
|
|
$HotelElement = new XoopsFormSelect(_AM_MARTIN_HOTEL_NAME, 'hotel_id', $Relation['hotel_id'], 1); |
50
|
|
|
$HotelElement->addOptionArray($this->hotelList); |
51
|
|
|
$this->addElement($HotelElement, true); |
52
|
|
|
|
53
|
|
|
$ServiceElement = new XoopsFormSelect(_AM_MARTIN_SERVICE_NAME, 'service_id', $Relation['service_id'], 1); |
54
|
|
|
$ServiceElement->addOptionArray($this->serviceList); |
55
|
|
|
$this->addElement($ServiceElement, true); |
56
|
|
|
|
57
|
|
|
$this->addElement(new XoopsFormText(_AM_MARTIN_SERVICE_PRICES, 'service_extra_price', 11, 11, $Relation['service_extra_price']), true); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @创建按钮 |
62
|
|
|
* @license http://www.blags.org/ |
63
|
|
|
* @created :2010年05月20日 23时52分 |
64
|
|
|
* @copyright 1997-2010 The Martin Group |
65
|
|
|
* @author Martin <[email protected]> |
66
|
|
|
* */ |
67
|
|
View Code Duplication |
public function createButtons() |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
70
|
|
|
// No ID for category -- then it's new category, button says 'Create' |
71
|
|
|
if (!$this->Obj) { |
72
|
|
|
$butt_create = new XoopsFormButton('', '', _SUBMIT, 'submit'); |
73
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
74
|
|
|
$button_tray->addElement($butt_create); |
75
|
|
|
|
76
|
|
|
$butt_clear = new XoopsFormButton('', '', _RESET, 'reset'); |
77
|
|
|
$button_tray->addElement($butt_clear); |
78
|
|
|
|
79
|
|
|
$butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button'); |
80
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
81
|
|
|
$button_tray->addElement($butt_cancel); |
82
|
|
|
|
83
|
|
|
$this->addElement($button_tray); |
84
|
|
|
} else { |
85
|
|
|
// button says 'Update' |
86
|
|
|
$butt_create = new XoopsFormButton('', '', _EDIT, 'submit'); |
87
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
88
|
|
|
$button_tray->addElement($butt_create); |
89
|
|
|
|
90
|
|
|
$butt_clear = new XoopsFormButton('', '', _RESET, 'reset'); |
91
|
|
|
$button_tray->addElement($butt_clear); |
92
|
|
|
|
93
|
|
|
$butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button'); |
94
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
95
|
|
|
$button_tray->addElement($butt_cancel); |
96
|
|
|
|
97
|
|
|
$this->addElement($button_tray); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
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.