Code Duplication    Length = 30-30 lines in 3 locations

install/actions/action_options.php 3 locations

@@ 146-175 (lines=30) @@
143
    }
144
}
145
146
if( ! function_exists('getChunks')) {
147
    /**
148
     * display chunks
149
     *
150
     * @param array $presets
151
     * @return string
152
     */
153
    function getChunks($presets = array())
154
    {
155
        if (!count($presets)) {
156
            return '';
157
        }
158
        $selected = isset ($_POST['chunk']) ? $_POST['chunk'] : array();
159
        $tpl = '<label><input type="checkbox" name="chunk[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
160
        $_ = array();
161
        $i = 0;
162
        foreach ($presets as $preset) {
163
            $ph['i'] = $i;
164
            $ph['name'] = $preset[0];
165
            $ph['desc'] = $preset[1];
166
            $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo';
167
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
168
            $_[] = parse($tpl, $ph);
169
            $i++;
170
        }
171
        if (0 < count($_)) {
172
            return '<h3>[%chunks%]</h3>' . join("\n", $_);
173
        }
174
    }
175
}
176
177
if( ! function_exists('getModules')) {
178
    /**
@@ 177-206 (lines=30) @@
174
    }
175
}
176
177
if( ! function_exists('getModules')) {
178
    /**
179
     * display modules
180
     *
181
     * @param array $presets
182
     * @return string
183
     */
184
    function getModules($presets = array())
185
    {
186
        if (!count($presets)) {
187
            return '';
188
        }
189
        $selected = isset ($_POST['module']) ? $_POST['module'] : array();
190
        $tpl = '<label><input type="checkbox" name="module[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
191
        $_ = array();
192
        $i = 0;
193
        foreach ($presets as $preset) {
194
            $ph['i'] = $i;
195
            $ph['name'] = $preset[0];
196
            $ph['desc'] = $preset[1];
197
            $ph['class'] = !in_array('sample', $preset[7]) ? 'toggle' : 'toggle demo';
198
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
199
            $_[] = parse($tpl, $ph);
200
            $i++;
201
        }
202
        if (0 < count($_)) {
203
            return '<h3>[%modules%]</h3>' . join("\n", $_);
204
        }
205
    }
206
}
207
208
if( ! function_exists('getPlugins')) {
209
    /**
@@ 243-272 (lines=30) @@
240
    }
241
}
242
243
if( ! function_exists('getSnippets')) {
244
    /**
245
     * display snippets
246
     *
247
     * @param array $presets
248
     * @return string
249
     */
250
    function getSnippets($presets = array())
251
    {
252
        if (!count($presets)) {
253
            return '';
254
        }
255
        $selected = isset ($_POST['snippet']) ? $_POST['snippet'] : array();
256
        $tpl = '<label><input type="checkbox" name="snippet[]" value="[+i+]" class="[+class+]" [+checked+] />[%install_update%] <span class="comname">[+name+]</span> - [+desc+]</label><hr />';
257
        $_ = array();
258
        $i = 0;
259
        foreach ($presets as $preset) {
260
            $ph['i'] = $i;
261
            $ph['name'] = $preset[0];
262
            $ph['desc'] = $preset[1];
263
            $ph['class'] = !in_array('sample', $preset[5]) ? 'toggle' : 'toggle demo';
264
            $ph['checked'] = in_array($i, $selected) || (!isset($_POST['options_selected'])) ? 'checked' : '';
265
            $_[] = parse($tpl, $ph);
266
            $i++;
267
        }
268
        if (0 < count($_)) {
269
            return '<h3>[%snippets%]</h3>' . join("\n", $_);
270
        }
271
    }
272
}
273