Code Duplication    Length = 30-30 lines in 3 locations

install/src/functions.php 3 locations

@@ 289-318 (lines=30) @@
286
    }
287
}
288
289
if (!function_exists('getChunks')) {
290
    /**
291
     * display chunks
292
     *
293
     * @param array $presets
294
     * @return string
295
     */
296
    function getChunks($presets = array())
297
    {
298
        if (empty($presets)) {
299
            return '';
300
        }
301
        $selected = isset ($_POST['chunk']) ? $_POST['chunk'] : array();
302
        $tpl = '<label><input type="checkbox" name="chunk[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
303
        $_ = array();
304
        $i = 0;
305
        $ph = array();
306
        foreach ($presets as $preset) {
307
            $ph['i'] = $i;
308
            $ph['name'] = $preset[0];
309
            $ph['desc'] = $preset[1];
310
            $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo';
311
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
312
            $_[] = parse($tpl, $ph);
313
            $i++;
314
        }
315
316
        return (0 < count($_)) ? '<h3>[%chunks%]</h3>' . implode("\n", $_) : '';
317
    }
318
}
319
320
if (!function_exists('getModules')) {
321
    /**
@@ 320-349 (lines=30) @@
317
    }
318
}
319
320
if (!function_exists('getModules')) {
321
    /**
322
     * display modules
323
     *
324
     * @param array $presets
325
     * @return string
326
     */
327
    function getModules($presets = array())
328
    {
329
        if (empty($presets)) {
330
            return '';
331
        }
332
        $selected = isset ($_POST['module']) ? $_POST['module'] : array();
333
        $tpl = '<label><input type="checkbox" name="module[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
334
        $_ = array();
335
        $i = 0;
336
        $ph = array();
337
        foreach ($presets as $preset) {
338
            $ph['i'] = $i;
339
            $ph['name'] = $preset[0];
340
            $ph['desc'] = $preset[1];
341
            $ph['class'] = !in_array('sample', $preset[7]) ? 'toggle' : 'toggle demo';
342
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
343
            $_[] = parse($tpl, $ph);
344
            $i++;
345
        }
346
347
        return (0 < count($_)) ? '<h3>[%modules%]</h3>' . implode("\n", $_) : '';
348
    }
349
}
350
351
if (!function_exists('getPlugins')) {
352
    /**
@@ 386-415 (lines=30) @@
383
    }
384
}
385
386
if (!function_exists('getSnippets')) {
387
    /**
388
     * display snippets
389
     *
390
     * @param array $presets
391
     * @return string
392
     */
393
    function getSnippets($presets = array())
394
    {
395
        if (!count($presets)) {
396
            return '';
397
        }
398
        $selected = isset ($_POST['snippet']) ? $_POST['snippet'] : array();
399
        $tpl = '<label><input type="checkbox" name="snippet[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
400
        $_ = array();
401
        $i = 0;
402
        $ph = array();
403
        foreach ($presets as $preset) {
404
            $ph['i'] = $i;
405
            $ph['name'] = $preset[0];
406
            $ph['desc'] = $preset[1];
407
            $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo';
408
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
409
            $_[] = parse($tpl, $ph);
410
            $i++;
411
        }
412
413
        return (0 < count($_)) ? '<h3>[%snippets%]</h3>' . implode("\n", $_) : '';
414
    }
415
}
416
417
if (!function_exists('clean_up')) {
418
    function clean_up($sqlParser)