Code Duplication    Length = 29-30 lines in 6 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:

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)