apcal_todays_schedule.php ➔ apcal_todays_schedule_edit()   B
last analyzed

Complexity

Conditions 5
Paths 12

Size

Total Lines 42

Duplication

Lines 42
Ratio 100 %

Importance

Changes 0
Metric Value
cc 5
nc 12
nop 1
dl 42
loc 42
rs 8.9368
c 0
b 0
f 0
1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright   {@link http://xoops.org/ XOOPS Project}
14
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team,
18
 * @author       GIJ=CHECKMATE (PEAK Corp. http://www.peak.ne.jp/)
19
 * @author       Antiques Promotion (http://www.antiquespromotion.ca)
20
 */
21
22
if (!defined('APCAL_BLOCK_TODAYS_SCHEDULE_INCLUDED')) {
23
    define('APCAL_BLOCK_TODAYS_SCHEDULE_INCLUDED', 1);
24
25
    /**
26
     * @param $options
27
     * @return array
28
     */
29
    function apcal_todays_schedule_show_tpl($options)
30
    {
31
        global $xoopsConfig, $xoopsDB;
32
33
        $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0];
34
        $now_cid       = empty($options[1]) ? 0 : (int)$options[1];
35
36
        // setting physical & virtual paths
37
        $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName";
38
        $mod_url  = XOOPS_URL . "/modules/$moduleDirName";
39
40
        // defining class of APCal
41
        if (!class_exists('APCal_xoops')) {
42
            require_once "$mod_path/class/APCal.php";
43
            require_once "$mod_path/class/APCal_xoops.php";
44
        }
45
46
        // creating an instance of APCal
47
        $cal                = new APCal_xoops(date('Y-n-j'), $xoopsConfig['language'], true);
48
        $cal->use_server_TZ = true;
49
50
        // cid ¤Ë¤è¤ë¹Ê¤ê¹þ¤ß
51
        $cal->now_cid = $now_cid;
52
53
        // setting properties of APCal
54
        $cal->conn = $GLOBALS['xoopsDB']->conn;
55
        include "$mod_path/include/read_configs.php";
56
        $cal->base_url    = $mod_url;
57
        $cal->base_path   = $mod_path;
58
        $cal->images_url  = "$mod_url/assets/images/$skin_folder";
0 ignored issues
show
Bug introduced by
The variable $skin_folder does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
59
        $cal->images_path = "$mod_path/assets/images/$skin_folder";
60
61
        $block = $cal->get_blockarray_date_event("$mod_url/index.php");
62
63
        return $block;
64
    }
65
66
    /**
67
     * @param $options
68
     * @return string
69
     */
70 View Code Duplication
    function apcal_todays_schedule_edit($options)
0 ignored issues
show
Duplication introduced by
This function 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...
71
    {
72
        global $xoopsDB, $xoopsConfig;
73
74
        $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0];
75
        $now_cid       = empty($options[1]) ? 0 : (int)$options[1];
76
77
        // setting physical & virtual paths
78
        $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName";
79
        $mod_url  = XOOPS_URL . "/modules/$moduleDirName";
80
81
        // defining class of APCal
82
        require_once "$mod_path/class/APCal.php";
83
        require_once "$mod_path/class/APCal_xoops.php";
84
85
        // creating an instance of APCal
86
        $cal                = new APCal_xoops(date('Y-n-j'), $xoopsConfig['language'], true);
87
        $cal->use_server_TZ = true;
88
89
        // setting properties of APCal
90
        $cal->conn = $GLOBALS['xoopsDB']->conn;
91
        include "$mod_path/include/read_configs.php";
92
        $cal->base_url    = $mod_url;
93
        $cal->base_path   = $mod_path;
94
        $cal->images_url  = "$mod_url/assets/images/$skin_folder";
0 ignored issues
show
Bug introduced by
The variable $skin_folder does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
95
        $cal->images_path = "$mod_path/assets/images/$skin_folder";
96
97
        $ret = "<input type='hidden' name='options[0]' value='$moduleDirName' />\n";
98
99
        // ¥«¥Æ¥´¥ê¡¼ÁªÂò¥Ü¥Ã¥¯¥¹¤ÎÀ¸À®
100
        $ret .= _MB_APCAL_CATSEL . ':';
101
        $ret .= "<select name='options[1]'>\n<option value='0'>" . _ALL . "</option>\n";
102
        foreach ($cal->categories as $cid => $cat) {
103
            $selected       = $now_cid == $cid ? 'selected' : '';
104
            $depth_desc     = str_repeat('-', (int)$cat->cat_depth);
105
            $cat_title4show = $cal->text_sanitizer_for_show($cat->cat_title);
106
            $ret            .= "\t<option value='$cid' $selected>$depth_desc $cat_title4show</option>\n";
107
        }
108
        $ret .= "</select>\n";
109
110
        return $ret;
111
    }
112
}
113