Code Duplication    Length = 27-28 lines in 2 locations

install/actions/action_options.php 1 location

@@ 4-30 (lines=27) @@
1
<?php
2
$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0;
3
4
if( ! function_exists('getTemplates')) {
5
    /**
6
     * @param array $presets
7
     * @return string
8
     */
9
    function getTemplates($presets = array())
10
    {
11
        if (empty($presets)) {
12
            return '';
13
        }
14
        $selectedTemplates = isset ($_POST['template']) ? $_POST['template'] : array();
15
        $tpl = '<label><input type="checkbox" name="template[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
16
        $_ = array();
17
        $i = 0;
18
        $ph = array();
19
        foreach ($presets as $preset) {
20
            $ph['i'] = $i;
21
            $ph['name'] = isset($preset[0]) ? $preset[0] : '';
22
            $ph['desc'] = isset($preset[1]) ? $preset[1] : '';
23
            $ph['class'] = !in_array('sample', $preset[6]) ? 'toggle' : 'toggle demo';
24
            $ph['checked'] = in_array($i, $selectedTemplates) || (!isset($_POST['options_selected'])) ? 'checked' : '';
25
            $_[] = parse($tpl, $ph);
26
            $i++;
27
        }
28
        return (0 < count($_)) ? '<h3>[%templates%]</h3>' . implode("\n", $_) : '';
29
    }
30
}
31
32
if( ! function_exists('getTVs')) {
33
    /**

install/src/functions.php 1 location

@@ 228-255 (lines=28) @@
225
    }
226
}
227
228
if (!function_exists('getTemplates')) {
229
    /**
230
     * @param array $presets
231
     * @return string
232
     */
233
    function getTemplates($presets = array())
234
    {
235
        if (empty($presets)) {
236
            return '';
237
        }
238
        $selectedTemplates = isset ($_POST['template']) ? $_POST['template'] : array();
239
        $tpl = '<label><input type="checkbox" name="template[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
240
        $_ = array();
241
        $i = 0;
242
        $ph = array();
243
        foreach ($presets as $preset) {
244
            $ph['i'] = $i;
245
            $ph['name'] = isset($preset[0]) ? $preset[0] : '';
246
            $ph['desc'] = isset($preset[1]) ? $preset[1] : '';
247
            $ph['class'] = !in_array('sample', $preset[6]) ? 'toggle' : 'toggle demo';
248
            $ph['checked'] = in_array($i, $selectedTemplates) || (!isset($_POST['options_selected'])) ? 'checked' : '';
249
            $_[] = parse($tpl, $ph);
250
            $i++;
251
        }
252
253
        return (0 < count($_)) ? '<h3>[%templates%]</h3>' . implode("\n", $_) : '';
254
    }
255
}
256
257
if (!function_exists('getTVs')) {
258
    /**