Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
cloud.php
1<?php
3
4use \Bitrix\Landing\Site;
5use \Bitrix\Landing\Demos as DemoCore;
6use \Bitrix\Landing\PublicActionResult;
7
8class Cloud
9{
14 public static function getRepository()
15 {
16 return Block::getRepository(null, true);
17 }
18
26 protected static function getDemoItemList(string $type, bool $isPage, array $filter = []): PublicActionResult
27 {
28 if ($isPage)
29 {
30 $result = Demos::getPageList($type)->getResult();
31 }
32 else
33 {
34 $result = Demos::getSiteList($type)->getResult();
35 }
36
37 // we need only used in public templates
38 if (
39 $result &&
40 isset($filter['used_in_public']) &&
41 $filter['used_in_public'] == 'Y'
42 )
43 {
44 $resultNotPublic = $result;
45 $res = Site::getList([
46 'select' => [
47 'ID', 'TITLE', 'TPL_CODE'
48 ],
49 'filter' => [
50 '=ACTIVE' => 'Y',
51 '=TPL_CODE' => array_keys($resultNotPublic)
52 ]
53 ]);
54 while ($row = $res->fetch())
55 {
56 unset($resultNotPublic[$row['TPL_CODE']]);
57 }
58 foreach ($resultNotPublic as $key => $foo)
59 {
60 unset($result[$key]);
61 }
62 }
63
64 // we need't local templates, only from rest
65 if (
66 $result &&
67 isset($filter['only_rest']) &&
68 $filter['only_rest'] == 'Y'
69 )
70 {
71 foreach ($result as $key => $item)
72 {
73 if (!$item['REST'])
74 {
75 unset($result[$key]);
76 }
77 }
78 }
79
80 $actionResult = new PublicActionResult;
81 $actionResult->setResult($result);
82
83 return $actionResult;
84 }
85
92 public static function getDemoSiteList(string $type, array $filter = []): PublicActionResult
93 {
94 return self::getDemoItemList($type, false, $filter);
95 }
96
103 public static function getDemoPageList(string $type, array $filter = []): PublicActionResult
104 {
105 return self::getDemoItemList($type, true, $filter);
106 }
107
114 public static function getUrlPreview($code, $type)
115 {
116 return Demos::getUrlPreview($code, $type);
117 }
118
124 public static function getAppItems(string $appCode): PublicActionResult
125 {
126 return Demos::getList([
127 'filter' => [
128 '=APP_CODE' => $appCode
129 ]
130 ]);
131 }
132
138 public static function getAppItemManifest(int $id): PublicActionResult
139 {
140 $result = new PublicActionResult;
141
142 $template = DemoCore::getList([
143 'filter' => ['ID' => $id]
144 ])->fetch();
145
146 if ($template)
147 {
148 $template['MANIFEST'] = unserialize($template['MANIFEST'], ['allowed_classes' => false]);
149 $result->setResult($template);
150 }
151
152 return $result;
153 }
154}
static getAppItems(string $appCode)
Definition cloud.php:124
static getUrlPreview($code, $type)
Definition cloud.php:114
static getAppItemManifest(int $id)
Definition cloud.php:138
static getDemoItemList(string $type, bool $isPage, array $filter=[])
Definition cloud.php:26
static getDemoPageList(string $type, array $filter=[])
Definition cloud.php:103
static getDemoSiteList(string $type, array $filter=[])
Definition cloud.php:92
static getList(array $params=array())
Definition demos.php:452
static getUrlPreview($code, $type)
Definition demos.php:136
static getSiteList($type, array $filter=[])
Definition demos.php:112
static getPageList($type, array $filter=[])
Definition demos.php:124
static getList(array $params=[], $initiator=null)
Definition site.php:99