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
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.