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
    public 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

@@ 346-380 (lines=35) @@
343
        return $cart;
344
    }
345
346
    public function sitemap() {
347
        $map = [];
348
        $zeroItems = \Ecommerce\Item::getList(['where' => ['category_id', 0]]);
349
        foreach ($zeroItems as $item) {
350
            $map[] = [
351
                'name' => $item->name,
352
                'url' => [
353
                    'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
354
                ],
355
            ];
356
        }
357
358
        $categorys = \Ecommerce\Category::getList(['where' => ['parent_id', 0]]);
359
        $scan = function($category, $scan) {
360
            $map = [];
361
362
            foreach ($category->items as $item) {
363
                $map[] = [
364
                    'name' => $item->name,
365
                    'url' => [
366
                        'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
367
                    ],
368
                ];
369
            }
370
            foreach ($category->catalogs as $child) {
371
                $map = array_merge($map, $scan($child, $scan));
372
            }
373
            return $map;
374
        };
375
        foreach ($categorys as $category) {
376
            $map = array_merge($map, $scan($category, $scan));
377
        }
378
        return $map;
379
    }
380
}