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

apcal_map.php ➔ apcal_map_edit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
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
 */
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)
0 ignored issues
show
Coding Style introduced by
apcal_map_show uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
29
    {
30
        global $xoopsConfig, $xoopsDB;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
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";
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...
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
Unused Code introduced by
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)
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
89
    {
90
        return '';
91
    }
92
}
93