Code Duplication    Length = 44-44 lines in 2 locations

system/Inji/Model.php 2 locations

@@ 243-286 (lines=44) @@
240
                    return \App::$cur->{$colInfo['colParams']['value']['module']}->{$colInfo['colParams']['value']['method']}($item, $colName, $colInfo['colParams']);
241
                }
242
                break;
243
            case 'map':
244
                if ($item->$colName && json_decode($item->$colName, true)) {
245
                    $addres = json_decode($item->$colName, true);
246
                    $name = $addres['address'] ? $addres['address'] : 'lat:' . $addres['lat'] . ': lng:' . $addres['lng'];
247
                    \App::$cur->libs->loadLib('yandexMap');
248
                    ob_start();
249
                    $uid = Tools::randomString();
250
                    ?>
251
                    <div id='map<?= $uid; ?>_container' style="display:none;"><script>/*
252
                     <div id='map<?= $uid; ?>' style="width: 100%; height: 500px"></div>
253
                     <script>
254
                     var myMap<?= $uid; ?>;
255
                     var myMap<?= $uid; ?>CurPin;
256
                     inji.onLoad(function () {
257
                     ymaps.ready(init<?= $uid; ?>);
258
                     function init<?= $uid; ?>() {
259
                     var myPlacemark;
260
                     myMap<?= $uid; ?> = new ymaps.Map("map<?= $uid; ?>", {
261
                     center: ["<?= $addres['lat'] ?>", "<?= $addres['lng']; ?>"],
262
                     zoom: 13
263
                     });
264
                     myCoords = ["<?= $addres['lat'] ?>", "<?= $addres['lng']; ?>"];
265
                     myMap<?= $uid; ?>CurPin = new ymaps.Placemark(myCoords,
266
                     {iconContent: "<?= $addres['address']; ?>"},
267
                     {preset: 'islands#greenStretchyIcon'}
268
                     );
269
                     myMap<?= $uid; ?>.geoObjects.add(myMap<?= $uid; ?>CurPin, 0);
270
                     }
271
                     window['init<?= $uid; ?>'] = init<?= $uid; ?>;
272
                     });
273
                     */</script>
274
                    </div>
275
                    <?php
276
                    $content = ob_get_contents();
277
                    ob_end_clean();
278
                    $onclick = 'inji.Ui.modals.show("' . addcslashes($addres['address'], '"') . '", $("#map' . $uid . '_container script").html().replace(/^\/\*/g, "").replace(/\*\/$/g, "")+"</script>","mapmodal' . $uid . '","modal-lg");';
279
                    $onclick .= 'return false;';
280
                    $value = "<a href ='#' onclick='{$onclick}' >{$name}</a>";
281
                    $value .= $content;
282
                } else {
283
                    $value = 'Местоположение не заданно';
284
                }
285
286
                break;
287
            case 'dynamicType':
288
                switch ($colInfo['colParams']['typeSource']) {
289
                    case'selfMethod':
@@ 314-357 (lines=44) @@
311
                            }
312
                        } else {
313
                            switch ($type) {
314
                                case 'map':
315
                                    if ($item->$colName && json_decode($item->$colName, true)) {
316
                                        $addres = json_decode($item->$colName, true);
317
                                        $name = $addres['address'] ? $addres['address'] : 'lat:' . $addres['lat'] . ': lng:' . $addres['lng'];
318
                                        \App::$cur->libs->loadLib('yandexMap');
319
                                        ob_start();
320
                                        $uid = Tools::randomString();
321
                                        ?>
322
                                        <div id='map<?= $uid; ?>_container' style="display:none;"><script>/*
323
                                                                                 <div id='map<?= $uid; ?>' style="width: 100%; height: 500px"></div>
324
                                                                                 <script>
325
                                                                                 var myMap<?= $uid; ?>;
326
                                                                                 var myMap<?= $uid; ?>CurPin;
327
                                                                                 inji.onLoad(function () {
328
                                                                                 ymaps.ready(init<?= $uid; ?>);
329
                                                                                 function init<?= $uid; ?>() {
330
                                                                                 var myPlacemark;
331
                                                                                 myMap<?= $uid; ?> = new ymaps.Map("map<?= $uid; ?>", {
332
                                                                                 center: ["<?= $addres['lat'] ?>", "<?= $addres['lng']; ?>"],
333
                                                                                 zoom: 13
334
                                                                                 });
335
                                                                                 myCoords = ["<?= $addres['lat'] ?>", "<?= $addres['lng']; ?>"];
336
                                                                                 myMap<?= $uid; ?>CurPin = new ymaps.Placemark(myCoords,
337
                                                                                 {iconContent: "<?= $addres['address']; ?>"},
338
                                                                                 {preset: 'islands#greenStretchyIcon'}
339
                                                                                 );
340
                                                                                 myMap<?= $uid; ?>.geoObjects.add(myMap<?= $uid; ?>CurPin, 0);
341
                                                                                 }
342
                                                                                 window['init<?= $uid; ?>'] = init<?= $uid; ?>;
343
                                                                                 });
344
                                                                                 */</script>
345
                                        </div>
346
                                        <?php
347
                                        $content = ob_get_contents();
348
                                        ob_end_clean();
349
                                        $onclick = 'inji.Ui.modals.show("' . addcslashes($addres['address'], '"') . '", $("#map' . $uid . '_container script").html().replace(/^\/\*/g, "").replace(/\*\/$/g, "")+"</script>","mapmodal' . $uid . '","modal-lg");';
350
                                        $onclick .= 'return false;';
351
                                        $value = "<a href ='#' onclick='{$onclick}' >{$name}</a>";
352
                                        $value .= $content;
353
                                    } else {
354
                                        $value = 'Местоположение не заданно';
355
                                    }
356
357
                                    break;
358
                                default:
359
                                    $value = $item->$colName;
360
                            }