form_hotel_city::createButtons()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 33

Duplication

Lines 33
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 33
loc 33
rs 9.392
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_city
17
 */
18
class form_hotel_city extends XoopsThemeForm
19
{
20
    /**
21
     * form_hotel_city constructor.
22
     * @param $HotelCityObj
23
     */
24 View Code Duplication
    public function __construct(&$HotelCityObj)
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...
25
    {
26
        $this->Obj = &$HotelCityObj;
27
        parent::__construct(_AM_MARTIN_HOTEL_CITY, "op", xoops_getenv('PHP_SELF') . "?action=save");
28
        $this->setExtra('enctype="multipart/form-data"');
29
30
        $this->createElements();
31
        $this->createButtons();
32
    }
33
34
    /**
35
     * created elements
36
     * @license   http://www.blags.org/
37
     * @created   :2010年05月21日 20时40分
38
     * @copyright 1997-2010 The Martin Group
39
     * @author    Martin <[email protected]>
40
     * */
41
    public function createElements()
42
    {
43
        global $xoopsDB;
44
        $mytree = new XoopsTree($xoopsDB->prefix("martin_hotel_city"), "city_id", "city_parentid");
45
        // Parent Category
46
        ob_start();
47
        $mytree->makeMySelBox("city_name", "", $this->Obj->city_parentid(), 1, 'city_parentid');
48
        //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="")
49
        $this->addElement(new XoopsFormLabel(_AM_MARTIN_PARENT, ob_get_contents()));
50
        ob_end_clean();
51
        // City Name
52
        $this->addElement(new XoopsFormText(_AM_MARTIN_CITY_NAME, 'city_name', 50, 255, $this->Obj->city_name()), true);
53
        $this->addElement(new XoopsFormText(_AM_MARTIN_CITY_ALIAS, 'city_alias', 50, 255, $this->Obj->city_alias()), true);
54
        $this->addElement(new XoopsFormHidden('id', $this->Obj->city_id()));
55
    }
56
57
    /**
58
     * @创建按钮
59
     * @license   http://www.blags.org/
60
     * @created   :2010年05月20日 23时52分
61
     * @copyright 1997-2010 The Martin Group
62
     * @author    Martin <[email protected]>
63
     * */
64 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...
65
    {
66
        $button_tray = new XoopsFormElementTray('', '');
67
        // No ID for category -- then it's new category, button says 'Create'
68
        if (!$this->Obj->city_id()) {
69
            $butt_create = new XoopsFormButton('', '', _SUBMIT, 'submit');
70
            $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
71
            $button_tray->addElement($butt_create);
72
73
            $butt_clear = new XoopsFormButton('', '', _RESET, 'reset');
74
            $button_tray->addElement($butt_clear);
75
76
            $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button');
77
            $butt_cancel->setExtra('onclick="history.go(-1)"');
78
            $button_tray->addElement($butt_cancel);
79
80
            $this->addElement($button_tray);
81
        } else {
82
            // button says 'Update'
83
            $butt_create = new XoopsFormButton('', '', _SUBMIT, 'submit');
84
            $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
85
            $button_tray->addElement($butt_create);
86
87
            $butt_clear = new XoopsFormButton('', '', _RESET, 'reset');
88
            $button_tray->addElement($butt_clear);
89
90
            $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button');
91
            $butt_cancel->setExtra('onclick="history.go(-1)"');
92
            $button_tray->addElement($butt_cancel);
93
94
            $this->addElement($button_tray);
95
        }
96
    }
97
}
98