Completed
Branch master (b50208)
by Michael
11:07 queued 07:20
created

blocks/apcal_map.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
 */
20
21
if (!defined('APCAL_BLOCK_MAP_INCLUDED')) {
22
    define('APCAL_BLOCK_MAP_INCLUDED', 1);
23
24
    /**
25
     * @param $options
26
     * @return array
27
     */
28
    function apcal_map_show($options)
29
    {
30
        global $xoopsConfig, $xoopsDB;
31
32
        $original_level = error_reporting(E_ALL ^ E_NOTICE);
33
34
        $moduleDirName = empty($options[0]) ? basename(dirname(__DIR__)) : $options[0];
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('', $xoopsConfig['language'], true);
48
49
        // ignoring cid from GET
50
        $cal->now_cid = 0;
51
52
        // setting properties of APCal
53
        $cal->conn = $GLOBALS['xoopsDB']->conn;
54
        include "$mod_path/include/read_configs.php";
55
        $cal->base_url    = $mod_url;
56
        $cal->base_path   = $mod_path;
57
        $cal->images_url  = "$mod_url/assets/images/$skin_folder";
58
        $cal->images_path = "$mod_path/assets/images/$skin_folder";
59
60
        $cal->get_monthly_html("$mod_url");
61
62
        if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
63
        } else {
64
            $moduleHelper = Xmf\Module\Helper::getHelper('system');
65
        }
66
67
        $block = array();
68
        if (is_array($cal->gmPoints) && !empty($cal->gmPoints)) {
69
            $tpl = new XoopsTpl();
70
            $tpl->assign('GMlatitude', $cal->gmlat);
71
            $tpl->assign('GMlongitude', $cal->gmlng);
72
            $tpl->assign('GMzoom', $cal->gmzoom);
73
            $tpl->assign('GMheight', $cal->gmheight . 'px');
74
            $tpl->assign('GMPoints', $cal->gmPoints);
75
            $tpl->assign('api_key', $moduleHelper->getConfig('apcal_mapsapi'));
76
            $block['map'] = $tpl->fetch(XOOPS_ROOT_PATH . '/modules/apcal/templates/apcal_googlemap.tpl');
77
        }
78
79
        error_reporting($original_level);
80
81
        return $block;
82
    }
83
84
    /**
85
     * @param $options
86
     * @return string
87
     */
88
    function apcal_map_edit($options)
89
    {
90
        return '';
91
    }
92
}
93