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

@@ 358-392 (lines=35) @@
355
        return $cart;
356
    }
357
358
    public function sitemap() {
359
        $map = [];
360
        $zeroItems = \Ecommerce\Item::getList(['where' => ['category_id', 0]]);
361
        foreach ($zeroItems as $item) {
362
            $map[] = [
363
                'name' => $item->name,
364
                'url' => [
365
                    'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
366
                ],
367
            ];
368
        }
369
370
        $categorys = \Ecommerce\Category::getList(['where' => ['parent_id', 0]]);
371
        $scan = function($category, $scan) {
372
            $map = [];
373
374
            foreach ($category->items as $item) {
375
                $map[] = [
376
                    'name' => $item->name,
377
                    'url' => [
378
                        'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
379
                    ],
380
                ];
381
            }
382
            foreach ($category->catalogs as $child) {
383
                $map = array_merge($map, $scan($child, $scan));
384
            }
385
            return $map;
386
        };
387
        foreach ($categorys as $category) {
388
            $map = array_merge($map, $scan($category, $scan));
389
        }
390
        return $map;
391
    }
392
393
    public function getFavoriteCount() {
394
        if (Users\User::$cur->id) {
395
            return \Ecommerce\Favorite::getCount(['user_id', Users\User::$cur->id]);