editCardealerService()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 27
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 20
nc 6
nop 1
dl 0
loc 27
rs 9.6
c 1
b 0
f 0
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
13
/**
14
 * Module: cardealer
15
 *
16
 * @category        Module
17
 * @package         cardealer
18
 * @author          XOOPS Development Team <[email protected]> - <https://xoops.org>
19
 * @copyright       {@link https://xoops.org/ XOOPS Project}
20
 * @license         GPL 2.0 or later
21
 * @link            https://xoops.org/
22
 * @since           1.0.0
23
 */
24
25
use XoopsModules\Cardealer;
26
27
/**
28
 * @param $options
29
 *
30
 * @return array
31
 */
32
function showCardealerService($options)
33
{
34
35
    $block        = [];
36
    $blockType    = $options[0];
37
    $serviceCount = $options[1];
38
    //$titleLenght = $options[2];
39
40
    /** @var \XoopsPersistableObjectHandler $serviceHandler */
41
    $serviceHandler = new Cardealer\ServiceHandler($GLOBALS['xoopsDB']);
42
    $criteria       = new \CriteriaCompo();
43
    array_shift($options);
44
    array_shift($options);
45
    array_shift($options);
46
    if ($blockType) {
47
        $criteria->add(new \Criteria('itemnum', 0, '!='));
48
        $criteria->setSort('itemnum');
49
        $criteria->setOrder('ASC');
50
    }
51
52
    $criteria->setLimit($serviceCount);
53
    $serviceArray = $serviceHandler->getAll($criteria);
54
    foreach (array_keys($serviceArray) as $i) {
55
    }
56
57
    return $block;
58
}
59
60
/**
61
 * @param $options
62
 *
63
 * @return string
64
 */
65
function editCardealerService($options)
66
{
67
    $form = MB_CARDEALER_DISPLAY;
0 ignored issues
show
Bug introduced by
The constant MB_CARDEALER_DISPLAY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
68
    $form .= "<input type='hidden' name='options[0]' value='" . $options[0] . "' />";
69
    $form .= "<input name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' type='text' />&nbsp;<br>";
70
    $form .= MB_CARDEALER_TITLELENGTH . " : <input name='options[2]' size='5' maxlength='255' value='" . $options[2] . "' type='text' /><br><br>";
0 ignored issues
show
Bug introduced by
The constant MB_CARDEALER_TITLELENGTH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
71
72
    /** @var \XoopsPersistableObjectHandler $serviceHandler */
73
    $serviceHandler = new Cardealer\ServiceHandler($GLOBALS['xoopsDB']);
74
75
    $criteria = new \CriteriaCompo();
76
    array_shift($options);
77
    array_shift($options);
78
    array_shift($options);
79
    $criteria->add(new Criteria('itemnum', 0, '!='));
80
    $criteria->setSort('itemnum');
81
    $criteria->setOrder('ASC');
82
    $serviceArray = $serviceHandler->getAll($criteria);
83
    $form         .= MB_CARDEALER_CATTODISPLAY . "<br><select name='options[]' multiple='multiple' size='5'>";
0 ignored issues
show
Bug introduced by
The constant MB_CARDEALER_CATTODISPLAY was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
84
    $form         .= "<option value='0' " . (false === in_array(0, $options) ? '' : "selected='selected'") . '>' . MB_CARDEALER_ALLCAT . '</option>';
0 ignored issues
show
Bug introduced by
The constant MB_CARDEALER_ALLCAT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
85
    foreach (array_keys($serviceArray) as $i) {
86
        $itemnum = $serviceArray[$i]->getVar('itemnum');
87
        $form    .= "<option value='" . $itemnum . "' " . (false === in_array($itemnum, $options) ? '' : "selected='selected'") . '>' . $serviceArray[$i]->getVar('title') . '</option>';
88
    }
89
    $form .= '</select>';
90
91
    return $form;
92
}
93