apcal_new_event.php ➔ apcal_new_event_show_tpl()   A
last analyzed

Complexity

Conditions 5
Paths 16

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 16
nop 1
dl 0
loc 37
rs 9.0168
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_NEW_EVENT_INCLUDED')) {
23
    define('APCAL_BLOCK_NEW_EVENT_INCLUDED', 1);
24
25
    /**
26
     * @param $options
27
     * @return array
28
     */
29
    function apcal_new_event_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
37
        // setting physical & virtual paths
38
        $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName";
39
        $mod_url  = XOOPS_URL . "/modules/$moduleDirName";
40
41
        // defining class of APCal
42
        if (!class_exists('APCal_xoops')) {
43
            require_once "$mod_path/class/APCal.php";
44
            require_once "$mod_path/class/APCal_xoops.php";
45
        }
46
47
        // creating an instance of APCal
48
        $cal                = new APCal_xoops(date('Y-n-j'), $xoopsConfig['language'], true);
49
        $cal->use_server_TZ = true;
50
51
        // cid ¤Ë¤è¤ë¹Ê¤ê¹þ¤ß
52
        $cal->now_cid = $now_cid;
53
54
        // setting properties of APCal
55
        $cal->conn = $GLOBALS['xoopsDB']->conn;
56
        include "$mod_path/include/read_configs.php";
57
        $cal->base_url    = $mod_url;
58
        $cal->base_path   = $mod_path;
59
        $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...
60
        $cal->images_path = "$mod_path/assets/images/$skin_folder";
61
62
        $block = $cal->get_blockarray_new_event("$mod_url/index.php", $maxitem);
63
64
        return $block;
65
    }
66
67
    /**
68
     * @param $options
69
     * @return string
70
     */
71
    function apcal_new_event_edit($options)
72
    {
73
        global $xoopsDB, $xoopsConfig;
74
75
        $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0];
76
        $maxitem       = empty($options[1]) ? 10 : (int)$options[1];
77
        $now_cid       = empty($options[2]) ? 0 : (int)$options[2];
78
79
        // setting physical & virtual paths
80
        $mod_path = XOOPS_ROOT_PATH . "/modules/$moduleDirName";
81
        $mod_url  = XOOPS_URL . "/modules/$moduleDirName";
82
83
        // defining class of APCal
84
        require_once "$mod_path/class/APCal.php";
85
        require_once "$mod_path/class/APCal_xoops.php";
86
87
        // creating an instance of APCal
88
        $cal                = new APCal_xoops(date('Y-n-j'), $xoopsConfig['language'], true);
89
        $cal->use_server_TZ = true;
90
91
        // setting properties of APCal
92
        $cal->conn = $GLOBALS['xoopsDB']->conn;
93
        include "$mod_path/include/read_configs.php";
94
        $cal->base_url    = $mod_url;
95
        $cal->base_path   = $mod_path;
96
        $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...
97
        $cal->images_path = "$mod_path/assets/images/$skin_folder";
98
99
        $ret = "<input type='hidden' name='options[0]' value='$moduleDirName' />\n";
100
101
        // ɽ¼¨¸Ä¿ô
102
        $ret .= _MB_APCAL_MAXITEMS . ':';
103
        $ret .= "<input type='text' size='4' name='options[1]' value='$maxitem' style='text-align:right;' /><br>\n";
104
105
        // ¥«¥Æ¥´¥ê¡¼ÁªÂò¥Ü¥Ã¥¯¥¹¤ÎÀ¸À®
106
        $ret .= _MB_APCAL_CATSEL . ':';
107
        $ret .= "<select name='options[2]'>\n<option value='0'>" . _ALL . "</option>\n";
108
        foreach ($cal->categories as $cid => $cat) {
109
            $selected       = $now_cid == $cid ? 'selected' : '';
110
            $depth_desc     = str_repeat('-', (int)$cat->cat_depth);
111
            $cat_title4show = $cal->text_sanitizer_for_show($cat->cat_title);
112
            $ret            .= "\t<option value='$cid' $selected>$depth_desc $cat_title4show</option>\n";
113
        }
114
        $ret .= "</select><br>\n";
115
116
        return $ret;
117
    }
118
}
119