form_hotel_service::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
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
17
 */
18
class form_hotel_service extends XoopsThemeForm
19
{
20
    /**
21
     * form_hotel_service constructor.
22
     * @param $HotelServiceObj
23
     * @param $TypeList
24
     */
25 View Code Duplication
    public function __construct(&$HotelServiceObj, &$TypeList)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
26
    {
27
        $this->Obj      = &$HotelServiceObj;
28
        $this->TypeList = &$TypeList;
29
        parent::__construct(_AM_MARTIN_HOTEL_SERVICE, "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
        global $xoopsDB;
46
        $TypeElement = new XoopsFormSelect(_AM_MARTIN_SERVICE_TYPE, 'service_type_id', $this->Obj->service_type_id(), 1);
47
        $TypeElement->addOptionArray($this->TypeList);
48
        $this->addElement($TypeElement, true);
49
        $this->addElement(new XoopsFormText(_AM_MARTIN_SERVICE_UNITS . '<br>' . _AM_MARTIN_SERVICE_UNITS_DESC, 'service_unit', 45, 45, $this->Obj->service_unit()), true);
50
        $this->addElement(new XoopsFormText(_AM_MARTIN_SERVICE_NAME, 'service_name', 50, 255, $this->Obj->service_name()), true);
51
        $this->addElement(new XoopsFormTextArea(_AM_MARTIN_SERVICE_DESCRIPTION, 'service_instruction', $this->Obj->service_instruction()), true);
52
        $this->addElement(new XoopsFormHidden('id', $this->Obj->service_id()));
53
    }
54
55
    /**
56
     * @创建按钮
57
     * @license   http://www.blags.org/
58
     * @created   :2010年05月20日 23时52分
59
     * @copyright 1997-2010 The Martin Group
60
     * @author    Martin <[email protected]>
61
     * */
62 View Code Duplication
    public function createButtons()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
63
    {
64
        $button_tray = new XoopsFormElementTray('', '');
65
        // No ID for category -- then it's new category, button says 'Create'
66
        if (!$this->Obj->service_id()) {
67
            $butt_create = new XoopsFormButton('', '', _SUBMIT, 'submit');
68
            $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
69
            $button_tray->addElement($butt_create);
70
71
            $butt_clear = new XoopsFormButton('', '', _RESET, 'reset');
72
            $button_tray->addElement($butt_clear);
73
74
            $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button');
75
            $butt_cancel->setExtra('onclick="history.go(-1)"');
76
            $button_tray->addElement($butt_cancel);
77
78
            $this->addElement($button_tray);
79
        } else {
80
            // button says 'Update'
81
            $butt_create = new XoopsFormButton('', '', _EDIT, 'submit');
82
            $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
83
            $button_tray->addElement($butt_create);
84
85
            $butt_clear = new XoopsFormButton('', '', _RESET, 'reset');
86
            $button_tray->addElement($butt_clear);
87
88
            $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button');
89
            $butt_cancel->setExtra('onclick="history.go(-1)"');
90
            $button_tray->addElement($butt_cancel);
91
92
            $this->addElement($button_tray);
93
        }
94
    }
95
}
96