apcal_coming_schedule.php ➔ apcal_coming_schedule_show_tpl()   B
last analyzed

Complexity

Conditions 7
Paths 64

Size

Total Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
nc 64
nop 1
dl 0
loc 40
rs 8.3466
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       Antiques Promotion (http://www.antiquespromotion.ca)
19
 * @author       GIJ=CHECKMATE (PEAK Corp. http://www.peak.ne.jp/)
20
 */
21
22
if (!defined('APCAL_BLOCK_COMING_SCHEDULE_INCLUDED')) {
23
    define('APCAL_BLOCK_COMING_SCHEDULE_INCLUDED', 1);
24
25
    /**
26
     * @param $options
27
     * @return array
28
     */
29
    function apcal_coming_schedule_show_tpl($options)
30
    {
31
        global $xoopsConfig, $xoopsDB;
32
33
        $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0];
34
        $maxitem       = empty($options[1]) ? 10 : (int)$options[1];
35
        $now_cid       = empty($options[2]) ? 0 : (int)$options[2];
36
        $untildays     = empty($options[4]) ? 0 : (int)$options[4];
37
        $showPictures  = empty($options[3]) ? 0 : (int)$options[3];
38
39
        // setting physical & virtual paths
40
        $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName";
41
        $mod_url  = XOOPS_URL . "/modules/$moduleDirName";
42
43
        // defining class of APCal
44
        if (!class_exists('APCal_xoops')) {
45
            require_once "$mod_path/class/APCal.php";
46
            require_once "$mod_path/class/APCal_xoops.php";
47
        }
48
49
        // creating an instance of APCal
50
        $cal                = new APCal_xoops(date('Y-n-j'), $xoopsConfig['language'], true);
51
        $cal->use_server_TZ = true;
52
53
        // cid ¤Ë¤è¤ë¹Ê¤ê¹þ¤ß
54
        $cal->now_cid = $now_cid;
55
56
        // setting properties of APCal
57
        $cal->conn = $GLOBALS['xoopsDB']->conn;
58
        include "$mod_path/include/read_configs.php";
59
        $cal->base_url    = $mod_url;
60
        $cal->base_path   = $mod_path;
61
        $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...
62
        $cal->images_path = "$mod_path/assets/images/$skin_folder";
63
64
        $block                 = $cal->get_blockarray_coming_event("$mod_url/index.php", $maxitem, true, $untildays);
65
        $block['showPictures'] = $showPictures;
66
67
        return $block;
68
    }
69
70
    /**
71
     * @param $options
72
     * @return string
73
     */
74
    function apcal_coming_schedule_edit($options)
75
    {
76
        global $xoopsDB, $xoopsConfig;
77
78
        $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0];
79
        $maxitem       = empty($options[1]) ? 10 : (int)$options[1];
80
        $now_cid       = empty($options[2]) ? 0 : (int)$options[2];
81
        $untildays     = empty($options[4]) ? 0 : (int)$options[4];
82
        $showPictures  = empty($options[3]) ? 0 : (int)$options[3];
83
84
        // setting physical & virtual paths
85
        $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName";
86
        $mod_url  = XOOPS_URL . "/modules/$moduleDirName";
87
88
        // defining class of APCal
89
        require_once "$mod_path/class/APCal.php";
90
        require_once "$mod_path/class/APCal_xoops.php";
91
92
        // creating an instance of APCal
93
        $cal                = new APCal_xoops(date('Y-n-j'), $xoopsConfig['language'], true);
94
        $cal->use_server_TZ = true;
95
96
        // setting properties of APCal
97
        $cal->conn = $GLOBALS['xoopsDB']->conn;
98
        include "$mod_path/include/read_configs.php";
99
        $cal->base_url    = $mod_url;
100
        $cal->base_path   = $mod_path;
101
        $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...
102
        $cal->images_path = "$mod_path/assets/images/$skin_folder";
103
104
        $ret = "<input type='hidden' name='options[0]' value='$moduleDirName' />\n";
105
106
        // ɽ¼¨¸Ä¿ô
107
        $ret .= _MB_APCAL_MAXITEMS . ':';
108
        $ret .= "<input type='text' size='4' name='options[1]' value='$maxitem' style='text-align:right;' /><br>\n";
109
110
        // ¥«¥Æ¥´¥ê¡¼ÁªÂò¥Ü¥Ã¥¯¥¹¤ÎÀ¸À®
111
        $ret .= _MB_APCAL_CATSEL . ':';
112
        $ret .= "<select name='options[2]'>\n<option value='0'>" . _ALL . "</option>\n";
113
        foreach ($cal->categories as $cid => $cat) {
114
            $selected       = $now_cid == $cid ? 'selected' : '';
115
            $depth_desc     = str_repeat('-', (int)$cat->cat_depth);
116
            $cat_title4show = $cal->text_sanitizer_for_show($cat->cat_title);
117
            $ret            .= "\t<option value='$cid' $selected>$depth_desc $cat_title4show</option>\n";
118
        }
119
        $ret .= "</select><br>\n";
120
121
        // ¥µ¥Ö¥«¥Æ¥´¥ê¡¼É½¼¨¤Î¼ÂÁõ¤Ï¤Þ¤À¤Þ¤ÀÀè¡Ê°ì±þͽÌó¤À¤±¤·¤Æ¤ª¤¯¡Ë
122
        //$ret .= "<input type='hidden' name='options[3]' value='0' />\n" ;
123
124
        $ret .= _MB_APCAL_SHOWPICTURES . ':&nbsp;';
125
        $ret .= _MB_APCAL_YES . " <input type='radio' name='options[3]' value='1'" . ($showPictures == 1 ? 'checked' : '') . " style='text-align:right;' />&nbsp;";
126
        $ret .= _MB_APCAL_NO . " <input type='radio' name='options[3]' value='0'" . ($showPictures == 0 ? 'checked' : '') . " style='text-align:right;' /><br>\n";
127
128
        // ɽ¼¨¾å¸ÂÆü¿ô
129
        $ret .= sprintf(_MB_APCAL_UNTILDAYS, "<input type='text' size='4' name='options[4]' value='$untildays' style='text-align:right;' />") . "<br>\n";
130
131
        return $ret;
132
    }
133
}
134