Completed
Push — master ( 583920...a73650 )
by Michael
02:19
created

slides.php ➔ b_presenter_slides_edit()   B

Complexity

Conditions 4
Paths 6

Size

Total Lines 27
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 22
nc 6
nop 1
dl 0
loc 27
rs 8.5806
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 26 and the first side effect is on line 21.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
 * presenter module for xoops
13
 *
14
 * @copyright       XOOPS Project (http://xoops.org)
15
 * @license         GPL 2.0 or later
16
 * @package         presenter
17
 * @since           2.5.5
18
 * @author          XOOPS Development Team <[email protected]> - <http://xoops.org>
19
 * @version         $Id: 1.0 slides.php 11532 Wed 2013/08/28 4:00:27Z XOOPS Development Team $
20
 */
21
include_once XOOPS_ROOT_PATH . '/modules/presenter/include/functions.php';
22
/**
23
 * @param $options
24
 * @return array
25
 */
26
function b_presenter_slides_show($options)
27
{
28
    include_once XOOPS_ROOT_PATH . '/modules/presenter/class/slides.php';
29
    $myts =& MyTextSanitizer::getInstance();
30
31
    $slides       = array();
32
    $type_block   = $options[0];
33
    $nb_slides    = $options[1];
34
    $lenght_title = $options[2];
0 ignored issues
show
Unused Code introduced by
$lenght_title is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
35
36
    $slidesHandler =& xoops_getModuleHandler('slides', 'presenter');
37
    $criteria      = new CriteriaCompo();
38
    array_shift($options);
39
    array_shift($options);
40
    array_shift($options);
41
42
    if ($type_block) {
43
        $criteria->add(new Criteria('slides_id', 0, '!='));
44
        $criteria->setSort('slides_id');
45
        $criteria->setOrder('ASC');
46
    }
47
48
    $criteria->setLimit($nb_slides);
49
    $slides_arr = $slidesHandler->getAll($criteria);
50
    foreach (array_keys($slides_arr) as $i) {
51
        $slides[$i]['slides_id']      = $slides_arr[$i]->getVar('slides_id');
52
        $slides[$i]['slides_cid']     = $slides_arr[$i]->getVar('slides_cid');
53
        $slides[$i]['slides_uid']     = $slides_arr[$i]->getVar('slides_uid');
54
        $slides[$i]['slides_title']   = $slides_arr[$i]->getVar('slides_title');
55
        $slides[$i]['slides_content'] = $slides_arr[$i]->getVar('slides_content');
56
57
        $slides[$i]['css_id']    = $slides_arr[$i]->getVar('css_id');
58
        $slides[$i]['css_class'] = $slides_arr[$i]->getVar('css_class');
59
60
        $slides[$i]['slides_transition_x'] = $slides_arr[$i]->getVar('slides_transition_x');
61
        $slides[$i]['slides_transition_y'] = $slides_arr[$i]->getVar('slides_transition_y');
62
        $slides[$i]['slides_transition_z'] = $slides_arr[$i]->getVar('slides_transition_z');
63
        $slides[$i]['slides_rotation_x']   = $slides_arr[$i]->getVar('slides_rotation_x');
64
        $slides[$i]['slides_rotation_y']   = $slides_arr[$i]->getVar('slides_rotation_y');
65
        $slides[$i]['slides_rotation_z']   = $slides_arr[$i]->getVar('slides_rotation_z');
66
        $slides[$i]['slides_scale_x']      = $slides_arr[$i]->getVar('slides_scale_x');
67
        $slides[$i]['slides_scale_y']      = $slides_arr[$i]->getVar('slides_scale_y');
68
        $slides[$i]['slides_scale_z']      = $slides_arr[$i]->getVar('slides_scale_z');
69
        $slides[$i]['slides_created']      = $slides_arr[$i]->getVar('slides_created');
70
        $slides[$i]['slides_published']    = $slides_arr[$i]->getVar('slides_published');
71
        $slides[$i]['slides_position']     = $slides_arr[$i]->getVar('slides_position');
72
        $slides[$i]['slides_online']       = $slides_arr[$i]->getVar('slides_online');
73
        $slides[$i]['slides_type']         = $slides_arr[$i]->getVar('slides_type');
74
        $slides[$i]['slides_notes']        = $slides_arr[$i]->getVar('slides_notes');
75
        $slides[$i]['slides_mp3']          = $slides_arr[$i]->getVar('slides_mp3');
76
        $slides[$i]['slides_time']         = $slides_arr[$i]->getVar('slides_time');
77
        $slides[$i]['slides_status']       = $slides_arr[$i]->getVar('slides_status');
78
        $slides[$i]['slides_waiting']      = $slides_arr[$i]->getVar('slides_waiting');
79
        $slides[$i]['slides_online']       = $slides_arr[$i]->getVar('slides_online');
80
    }
81
82
    return $slides;
83
}
84
85
/**
86
 * @param $options
87
 * @return string
88
 */
89
function b_presenter_slides_edit($options)
90
{
91
    include_once XOOPS_ROOT_PATH . '/modules/presenter/class/presenter_slides.php';
92
93
    $form = _MB_PRESENTER_DISPLAY . "\n";
94
    $form .= "<input type='hidden' name='options[0]' value='" . $options[0] . "' />";
95
    $form .= "<input name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' type='text' />&nbsp;<br />";
96
    $form .= _MB_PRESENTER_TITLELENGTH . " : <input name='options[2]' size='5' maxlength='255' value='" . $options[2] . "' type='text' /><br /><br />";
97
    $slidesHandler =& xoops_getModuleHandler('slides', 'presenter');
98
    $criteria      = new CriteriaCompo();
99
    array_shift($options);
100
    array_shift($options);
101
    array_shift($options);
102
    $criteria->add(new Criteria('slides_id', 0, '!='));
103
    $criteria->setSort('slides_id');
104
    $criteria->setOrder('ASC');
105
    $slides_arr = $slidesHandler->getAll($criteria);
106
    $form .= _MB_PRESENTER_CATTODISPLAY . "<br /><select name='options[]' multiple='multiple' size='5'>";
107
    $form .= "<option value='0' " . (array_search(0, $options) === false ? "" : "selected='selected'") . ">" . _MB_PRESENTER_ALLCAT . "</option>";
108
    foreach (array_keys($slides_arr) as $i) {
109
        $slides_id = $slides_arr[$i]->getVar('slides_id');
110
        $form .= "<option value='" . $slides_id . "' " . (array_search($slides_id, $options) === false ? "" : "selected='selected'") . ">" . $slides_arr[$i]->getVar('slides_title') . "</option>";
111
    }
112
    $form .= "</select>";
113
114
    return $form;
115
}
116