Code Duplication    Length = 35-35 lines in 2 locations

system/modules/Materials/Materials.php 1 location

@@ 82-116 (lines=35) @@
79
        return $return;
80
    }
81
82
    function sitemap() {
83
        $map = [];
84
        $zeroMaterials = \Materials\Material::getList(['where' => ['category_id', 0]]);
85
        foreach ($zeroMaterials as $mat) {
86
            $map[] = [
87
                'name' => $mat->name,
88
                'url' => [
89
                    'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($mat->getHref())
90
                ],
91
            ];
92
        }
93
94
        $categorys = \Materials\Category::getList(['where' => ['parent_id', 0]]);
95
        $scan = function($category, $scan) {
96
            $map = [];
97
98
            foreach ($category->items as $mat) {
99
                $map[] = [
100
                    'name' => $mat->name,
101
                    'url' => [
102
                        'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($mat->getHref())
103
                    ],
104
                ];
105
            }
106
            foreach ($category->childs as $child) {
107
                $map = array_merge($map, $scan($child, $scan));
108
            }
109
            return $map;
110
        };
111
        foreach ($categorys as $category) {
112
            $map = array_merge($map, $scan($category, $scan));
113
        }
114
        return $map;
115
    }
116
117
}
118

system/modules/Ecommerce/Ecommerce.php 1 location

@@ 325-359 (lines=35) @@
322
        return $cart;
323
    }
324
325
    function sitemap() {
326
        $map = [];
327
        $zeroItems = \Ecommerce\Item::getList(['where' => ['category_id', 0]]);
328
        foreach ($zeroItems as $item) {
329
            $map[] = [
330
                'name' => $item->name,
331
                'url' => [
332
                    'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
333
                ],
334
            ];
335
        }
336
337
        $categorys = \Ecommerce\Category::getList(['where' => ['parent_id', 0]]);
338
        $scan = function($category, $scan) {
339
            $map = [];
340
341
            foreach ($category->items as $item) {
342
                $map[] = [
343
                    'name' => $item->name,
344
                    'url' => [
345
                        'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
346
                    ],
347
                ];
348
            }
349
            foreach ($category->catalogs as $child) {
350
                $map = array_merge($map, $scan($child, $scan));
351
            }
352
            return $map;
353
        };
354
        foreach ($categorys as $category) {
355
            $map = array_merge($map, $scan($category, $scan));
356
        }
357
        return $map;
358
    }
359
360
}
361