Code Duplication    Length = 44-44 lines in 2 locations

system/Inji/Model.php 2 locations

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