Code Duplication    Length = 29-29 lines in 3 locations

install/actions/action_options.php 3 locations

@@ 61-89 (lines=29) @@
58
    }
59
}
60
61
if( ! function_exists('getChunks')) {
62
    /**
63
     * display chunks
64
     *
65
     * @param array $presets
66
     * @return string
67
     */
68
    function getChunks($presets = array())
69
    {
70
        if (empty($presets)) {
71
            return '';
72
        }
73
        $selected = isset ($_POST['chunk']) ? $_POST['chunk'] : array();
74
        $tpl = '<label><input type="checkbox" name="chunk[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
75
        $_ = array();
76
        $i = 0;
77
        $ph = array();
78
        foreach ($presets as $preset) {
79
            $ph['i'] = $i;
80
            $ph['name'] = $preset[0];
81
            $ph['desc'] = $preset[1];
82
            $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo';
83
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
84
            $_[] = parse($tpl, $ph);
85
            $i++;
86
        }
87
        return (0 < count($_)) ? '<h3>[%chunks%]</h3>' . implode("\n", $_) : '';
88
    }
89
}
90
91
if( ! function_exists('getModules')) {
92
    /**
@@ 91-119 (lines=29) @@
88
    }
89
}
90
91
if( ! function_exists('getModules')) {
92
    /**
93
     * display modules
94
     *
95
     * @param array $presets
96
     * @return string
97
     */
98
    function getModules($presets = array())
99
    {
100
        if (empty($presets)) {
101
            return '';
102
        }
103
        $selected = isset ($_POST['module']) ? $_POST['module'] : array();
104
        $tpl = '<label><input type="checkbox" name="module[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
105
        $_ = array();
106
        $i = 0;
107
        $ph = array();
108
        foreach ($presets as $preset) {
109
            $ph['i'] = $i;
110
            $ph['name'] = $preset[0];
111
            $ph['desc'] = $preset[1];
112
            $ph['class'] = !in_array('sample', $preset[7]) ? 'toggle' : 'toggle demo';
113
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
114
            $_[] = parse($tpl, $ph);
115
            $i++;
116
        }
117
        return (0 < count($_)) ? '<h3>[%modules%]</h3>' . implode("\n", $_) : '';
118
    }
119
}
120
121
if( ! function_exists('getPlugins')) {
122
    /**
@@ 155-183 (lines=29) @@
152
    }
153
}
154
155
if( ! function_exists('getSnippets')) {
156
    /**
157
     * display snippets
158
     *
159
     * @param array $presets
160
     * @return string
161
     */
162
    function getSnippets($presets = array())
163
    {
164
        if (!count($presets)) {
165
            return '';
166
        }
167
        $selected = isset ($_POST['snippet']) ? $_POST['snippet'] : array();
168
        $tpl = '<label><input type="checkbox" name="snippet[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
169
        $_ = array();
170
        $i = 0;
171
        $ph = array();
172
        foreach ($presets as $preset) {
173
            $ph['i'] = $i;
174
            $ph['name'] = $preset[0];
175
            $ph['desc'] = $preset[1];
176
            $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo';
177
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
178
            $_[] = parse($tpl, $ph);
179
            $i++;
180
        }
181
        return (0 < count($_)) ? '<h3>[%snippets%]</h3>' . implode("\n", $_) : '';
182
    }
183
}
184
185
switch($installMode){
186
    case 0: