Completed
Push — master ( 5be1c3...395766 )
by Michael
26:05
created

form_hotel_promotion::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %
Metric Value
dl 10
loc 10
rs 9.4286
cc 1
eloc 7
nc 1
nop 2
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 10.

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.

Loading history...
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
19
{
20
    /**
21
     * form_hotel_promotion constructor.
22
     * @param $HotelPromotionObj
23
     * @param $HotelList
24
     */
25 View Code Duplication
    public function __construct(&$HotelPromotionObj, &$HotelList)
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       = &$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';
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
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"];
0 ignored issues
show
Bug introduced by
The variable $xoopsModuleConfig seems to never exist, and therefore empty should always return true. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
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()
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...
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