adslight_maps_show()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 24
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php declare(strict_types=1);
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    XOOPS Project (https://xoops.org)
14
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
15
 * @author       XOOPS Development Team
16
 * @author       Pascal Le Boustouller: original author ([email protected])
17
 * @author       Luc Bizet (www.frxoops.org)
18
 * @author       jlm69 (www.jlmzone.com)
19
 * @author       mamba (www.xoops.org)
20
 */
21
22
use XoopsModules\Adslight\Helper;
23
24
/** @var Helper $helper */
25
26
// <{$xoops_url}>/modules/adslight/maps/<{$block.mapsname}>/assets/images/map.png
27
28
/**
29
 * @param array $options
30
 *
31
 * @return array|false
32
 */
33
function adslight_maps_show($options)
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
function adslight_maps_show(/** @scrutinizer ignore-unused */ $options)

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

Loading history...
34
{
35
    if (!class_exists(Helper::class)) {
36
        return [];
37
    }
38
39
    $helper = Helper::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $helper is dead and can be removed.
Loading history...
40
41
    global $xoopsConfig, $block_lang;
42
    $maps_name = $xoopsConfig['language'];
0 ignored issues
show
Unused Code introduced by
The assignment to $maps_name is dead and can be removed.
Loading history...
43
    $block     = [];
44
    $myts      = \MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
45
46
    $moduleDirName = \basename(\dirname(__DIR__));
47
    $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
48
49
    $block['title'] = constant("{$block_lang}_TITLE");
50
    //@todo - move language string to language file
51
    $block['imgmapsurl'] = '<a title="Recherche dans votre region" href="' . XOOPS_URL . '/modules/adslight/maps.php"><img src="' . XOOPS_URL . '/modules/adslight/maps/' . $xoopsConfig['language'] . '/assets/images/map.png" alt="Recherche dans votre region" border="0"></a><br>';
52
53
    $block['link'] = '<a href="' . XOOPS_URL . "/modules/{$moduleDirName}/\"><b>" . constant("{$block_lang}_ALL_LISTINGS") . '</b></a><br>';
54
    $block['add']  = '<a href="' . XOOPS_URL . "/modules/{$moduleDirName}/\"><b>" . constant("{$block_lang}_ADDNOW") . '</b></a><br>';
55
56
    return $block;
57
}
58
59
/**
60
 * @param array $options
61
 *
62
 * @return string html form to display
63
 */
64
function adslight_maps_edit($options): string
65
{
66
    $moduleDirName = \basename(\dirname(__DIR__));
67
    $block_lang    = '_MB_' . mb_strtoupper($moduleDirName);
68
69
    $form = constant("{$block_lang}_ORDER") . "&nbsp;<select name='options[]'>";
70
    $form .= "<option value='date_created'";
71
    if ('date_created' === $options[0]) {
72
        $form .= ' selected';
73
    }
74
    $form .= '>' . constant($block_lang . '_DATE') . "</option>\n";
75
76
    $form .= "<option value='hits'";
77
    if ('hits' === $options[0]) {
78
        $form .= ' selected';
79
    }
80
    $form .= '>' . constant("{$block_lang}_HITS") . '</option>';
81
    $form .= "</select>\n";
82
83
    $form .= '&nbsp;' . constant("{$block_lang}_DISP") . "&nbsp;<input type='text' name='options[]' value='{$options[1]}'>&nbsp;" . constant("{$block_lang}_LISTINGS");
84
    $form .= '&nbsp;<br><br>' . constant("{$block_lang}_CHARS") . "&nbsp;<input type='text' name='options[]' value='{$options[2]}'>&nbsp;" . constant("{$block_lang}_LENGTH") . '<br><br>';
85
86
    return $form;
87
}
88