Code Duplication    Length = 38-38 lines in 2 locations

manager/media/style/default/ajax.php 2 locations

@@ 253-290 (lines=38) @@
250
            if ($role && $name && $type) {
251
                switch ($type) {
252
                    case 'Snippet':
253
                    case 'SnippetNoCache': {
254
255
                        $sql = $modx->db->query('SELECT *
256
						FROM ' . $modx->getFullTableName('site_snippets') . '
257
						WHERE name="' . $name . '"
258
						LIMIT 1');
259
260
                        if ($modx->db->getRecordCount($sql)) {
261
                            $row = $modx->db->getRow($sql);
262
                            $contextmenu = array(
263
                                'header' => array(
264
                                    'innerHTML' => '<i class="fa fa-code"></i> ' . $row['name']
265
                                ),
266
                                'item' => array(
267
                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
268
                                    'url' => "index.php?a=22&id=" . $row['id']
269
                                )
270
                            );
271
                            if (!empty($row['description'])) {
272
                                $contextmenu['seperator'] = '';
273
                                $contextmenu['description'] = array(
274
                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
275
                                );
276
                            }
277
                        } else {
278
                            $contextmenu = array(
279
                                'header' => array(
280
                                    'innerHTML' => '<i class="fa fa-code"></i> ' . $name
281
                                ),
282
                                'item' => array(
283
                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_snippet'],
284
                                    'url' => "index.php?a=23&itemname=" . $name
285
                                )
286
                            );
287
                        }
288
289
                        break;
290
                    }
291
                    case 'Chunk' : {
292
293
                        $sql = $modx->db->query('SELECT *
@@ 291-328 (lines=38) @@
288
289
                        break;
290
                    }
291
                    case 'Chunk' : {
292
293
                        $sql = $modx->db->query('SELECT *
294
						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '
295
						WHERE name="' . $name . '"
296
						LIMIT 1');
297
298
                        if ($modx->db->getRecordCount($sql)) {
299
                            $row = $modx->db->getRow($sql);
300
                            $contextmenu = array(
301
                                'header' => array(
302
                                    'innerHTML' => '<i class="fa fa-th-large"></i> ' . $row['name']
303
                                ),
304
                                'item' => array(
305
                                    'innerHTML' => '<i class="fa fa-pencil-square-o"></i> ' . $_lang['edit'],
306
                                    'url' => "index.php?a=78&id=" . $row['id']
307
                                )
308
                            );
309
                            if (!empty($row['description'])) {
310
                                $contextmenu['seperator'] = '';
311
                                $contextmenu['description'] = array(
312
                                    'innerHTML' => '<i class="fa fa-info"></i> ' . $row['description']
313
                                );
314
                            }
315
                        } else {
316
                            $contextmenu = array(
317
                                'header' => array(
318
                                    'innerHTML' => '<i class="fa fa-th-large"></i> ' . $name
319
                                ),
320
                                'item' => array(
321
                                    'innerHTML' => '<i class="fa fa-plus"></i> ' . $_lang['new_htmlsnippet'],
322
                                    'url' => "index.php?a=77&itemname=" . $name
323
                                )
324
                            );
325
                        }
326
327
                        break;
328
                    }
329
                    case 'AttributeValue': {
330
                        $sql = $modx->db->query('SELECT *
331
						FROM ' . $modx->getFullTableName('site_htmlsnippets') . '