Code Duplication    Length = 30-30 lines in 3 locations

install/src/functions.php 3 locations

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