4use \Bitrix\Landing\Manager;
5use \Bitrix\Landing\File;
6use \Bitrix\Landing\Rights;
7use \Bitrix\Landing\Landing;
9use \Bitrix\Landing\PublicActionResult;
10use \Bitrix\Main\Localization\Loc;
23 $disallow = [
'ACTIVE',
'SPECIAL',
'TPL_CODE'];
25 if (is_array($fields))
27 foreach ($fields as $k => $v)
29 if (in_array($k, $disallow))
49 if (($fields = SiteCore::getAdditionalFields($id)))
51 foreach ($fields as $key => $field)
53 $fields[$key] = $field->getValue();
74 static $mixedParams = [
'id'];
77 $result->setResult(SiteCore::getPublicUrl($id));
89 $result->setResult(SiteCore::getPreview($id));
99 public static function getList(array $params = [], $initiator =
null)
102 $params = $result->sanitizeKeys($params);
103 $getPublicUrl =
false;
104 $getPreviewPicture =
false;
106 $mobileHit = $initiator ===
'mobile';
110 \Bitrix\Landing\Connector\Mobile::forceMobile();
115 !isset($params[
'select']) ||
116 !is_array($params[
'select'])
119 $params[
'select'] = [
'*'];
122 !isset($params[
'filter']) ||
123 !is_array($params[
'filter'])
126 $params[
'filter'] = [];
131 isset($params[
'filter'][
'=TYPE']) &&
132 $params[
'filter'][
'=TYPE'] ==
'STORE'
135 $params[
'filter'][
'=TYPE'] = [
136 $params[
'filter'][
'=TYPE'],
141 isset($params[
'filter'][
'TYPE']) &&
142 $params[
'filter'][
'TYPE'] ==
'STORE'
145 $params[
'filter'][
'TYPE'] = [
146 $params[
'filter'][
'TYPE'],
151 if (isset($params[
'filter'][
'CHECK_PERMISSIONS']))
153 unset($params[
'filter'][
'CHECK_PERMISSIONS']);
157 if (is_array($params[
'select']))
159 if (in_array(
'DOMAIN_NAME', $params[
'select']))
161 $params[
'select'][
'DOMAIN_NAME'] =
'DOMAIN.DOMAIN';
163 if (in_array(
'PUBLIC_URL', $params[
'select']))
165 $getPublicUrl =
true;
167 if (in_array(
'PREVIEW_PICTURE', $params[
'select']))
169 $getPreviewPicture =
true;
171 if (in_array(
'PHONE', $params[
'select']))
174 $params[
'select'][] =
'ID';
177 $deleted = [
'DOMAIN_NAME',
'PUBLIC_URL',
'PREVIEW_PICTURE',
'PHONE'];
178 foreach ($params[
'select'] as $k => $code)
180 if (in_array($code, $deleted))
182 unset($params[
'select'][$k]);
189 $getPreviewPicture &&
190 !in_array(
'LANDING_ID_INDEX', $params[
'select'])
193 $params[
'select'][] =
'LANDING_ID_INDEX';
195 if (!in_array(
'ID', $params[
'select']))
197 $params[
'select'][] =
'ID';
199 if (!in_array(
'TYPE', $params[
'select']))
201 $params[
'select'][] =
'TYPE';
206 $landingIndexes = [];
207 $res = SiteCore::getList($params);
208 while ($row = $res->fetch())
210 if (isset($row[
'DATE_CREATE']))
212 $row[
'DATE_CREATE'] = (string) $row[
'DATE_CREATE'];
214 if (isset($row[
'DATE_MODIFY']))
216 $row[
'DATE_MODIFY'] = (string) $row[
'DATE_MODIFY'];
218 if ($row[
'LANDING_ID_INDEX'] && $getPreviewPicture)
220 $landingIndexes[$row[
'ID']] = $row[
'LANDING_ID_INDEX'];
224 $row[
'PUBLIC_URL'] =
'';
226 if ($getPreviewPicture)
228 $row[
'PREVIEW_PICTURE'] =
'';
232 $row[
'PHONE'] = \Bitrix\Landing\Connector\Crm::getContacts(
236 $data[$row[
'ID']] = $row;
240 if ($getPublicUrl || $getPreviewPicture)
242 $urls = SiteCore::getPublicUrl(array_keys($data),
true, !$mobileHit);
243 foreach ($urls as $siteId => $url)
245 $data[$siteId][
'PUBLIC_URL'] = $url;
252 $landing = Landing::createInstance(0);
253 foreach ($landingIndexes as $siteId => $landingId)
255 $data[$siteId][
'PREVIEW_PICTURE'] = $landing->getPreview(
258 $data[$siteId][
'PUBLIC_URL']
276 public static function add(array $fields)
279 $error = new \Bitrix\Landing\Error;
281 $fields = self::clearDisallowFields($fields);
282 $fields[
'ACTIVE'] =
'N';
284 $res = SiteCore::add($fields);
286 if ($res->isSuccess())
288 $result->setResult($res->getId());
292 $error->addFromResult($res);
293 $result->setError($error);
305 public static function update($id, array $fields)
308 $error = new \Bitrix\Landing\Error;
310 $fields = self::clearDisallowFields($fields);
312 $res = SiteCore::update($id, $fields);
314 if ($res->isSuccess())
316 $result->setResult(
true);
320 $error->addFromResult($res);
321 $result->setError($error);
332 public static function delete($id)
335 $error = new \Bitrix\Landing\Error;
337 $res = SiteCore::delete($id);
339 if ($res->isSuccess())
341 $result->setResult(
true);
345 $error->addFromResult($res);
346 $result->setError($error);
361 $error = new \Bitrix\Landing\Error;
366 $res = SiteCore::markDelete($id);
370 $res = SiteCore::markUnDelete($id);
372 if ($res->isSuccess())
374 $result->setResult($res->getId());
378 $error->addFromResult($res);
379 $result->setError($error);
392 return self::markDelete($id,
false);
404 $error = new \Bitrix\Landing\Error;
405 if (!($fields[
'PARENT_ID'] ??
null))
407 $fields[
'PARENT_ID'] =
null;
409 $addResult = SiteCore::addFolder($siteId, $fields);
411 if ($addResult->isSuccess())
413 $result->setResult($addResult->getId());
417 $error->addFromResult($addResult);
418 $result->setError($error);
434 $error = new \Bitrix\Landing\Error;
436 if (!($fields[
'PARENT_ID'] ??
null))
438 $fields[
'PARENT_ID'] =
null;
440 $addResult = SiteCore::updateFolder($siteId, $folderId, $fields);
442 if ($addResult->isSuccess())
444 $result->setResult(
true);
448 $error->addFromResult($addResult);
449 $result->setError($error);
465 $error = new \Bitrix\Landing\Error;
466 $moveResult = SiteCore::moveFolder($folderId, $toFolderId ?:
null, $toSiteId ?:
null);
468 if ($moveResult->isSuccess())
470 $result->setResult($moveResult->getId());
474 $error->addFromResult($moveResult);
475 $result->setError($error);
490 $error = new \Bitrix\Landing\Error;
492 $publicationResult = SiteCore::publicationFolder($folderId, $mark);
494 if ($publicationResult->isSuccess())
496 $result->setResult($publicationResult->isSuccess());
500 $error->addFromResult($publicationResult);
501 $result->setError($error);
514 return self::publicationFolder($folderId,
false);
526 if (array_key_exists(
'PARENT_ID', $filter) && !($filter[
'PARENT_ID'] ??
null))
528 $filter[
'PARENT_ID'] =
null;
531 $rows = array_values(SiteCore::getFolders($siteId, $filter));
532 foreach ($rows as &$row)
534 if (isset($row[
'DATE_CREATE']))
536 $row[
'DATE_CREATE'] = (string) $row[
'DATE_CREATE'];
538 if (isset($row[
'DATE_MODIFY']))
540 $row[
'DATE_MODIFY'] = (string) $row[
'DATE_MODIFY'];
545 $result->setResult($rows);
559 $error = new \Bitrix\Landing\Error;
563 $res = SiteCore::markFolderDelete($id);
567 $res = SiteCore::markFolderUnDelete($id);
569 if ($res->isSuccess())
571 $result->setResult(
true);
575 $error->addFromResult($res);
576 $result->setError($error);
589 return self::markFolderDelete($id,
false);
601 $error = new \Bitrix\Landing\Error;
605 $res = SiteCore::publication($id);
609 $res = SiteCore::unpublic($id);
612 if ($res->isSuccess())
614 $result->setResult($res->getId());
618 $error->addFromResult($res);
619 $result->setError($error);
632 return self::publication($id,
false);
641 public static function fullExport($id, array $params = array())
646 SiteCore::fullExport($id, $params)
660 static $mixedParams = [
'rights'];
663 $error = new \Bitrix\Landing\Error;
664 $result->setResult(
false);
667 if (!is_array($rights))
679 $result->setError($error);
686 'limit_sites_access_permissions'
689 $result->setError($error);
713 $error = new \Bitrix\Landing\Error;
714 $result->setResult([]);
723 'limit_sites_access_permissions'
726 $result->setError($error);
752 static $internal =
true;
753 static $mixedParams = [
'picture'];
756 $result->setResult(
false);
757 $error = new \Bitrix\Landing\Error;
760 $res = SiteCore::getList(array(
772 $result->setResult(array(
774 'src' => $file[
'SRC']
783 $result->setError($error);
798 \Bitrix\Landing\Site\Type::setScope($type);
818 $result->setResult($binding->bindSite($id));
822 $result->setResult($binding->unbindSite($id));
827 $result->setResult(
false);
841 \Bitrix\Landing\Site\Type::setScope(
'KNOWLEDGE');
842 $binding = new \Bitrix\Landing\Binding\Menu($menuCode);
843 return self::binding($id, $binding,
true);
854 \Bitrix\Landing\Site\Type::setScope(
'KNOWLEDGE');
855 $binding = new \Bitrix\Landing\Binding\Menu($menuCode);
856 return self::binding($id, $binding,
false);
867 \Bitrix\Landing\Site\Type::setScope(
'KNOWLEDGE');
871 !\
Bitrix\landing\Binding\Group::getList($groupId)
874 $binding = new \Bitrix\Landing\Binding\Group($groupId);
875 $result = self::binding($id, $binding,
true);
876 if ($result->getResult())
879 \Bitrix\Landing\Site::update($id, [
888 $result->setResult(
false);
900 \Bitrix\Landing\Site\Type::setScope(
'GROUP');
904 $binding = new \Bitrix\Landing\Binding\Group($groupId);
905 $result = self::binding($id, $binding,
false);
906 if ($result->getResult())
909 \Bitrix\Landing\Site::update($id, [
910 'TYPE' =>
'KNOWLEDGE'
918 $result->setResult(
false);
930 foreach ($bindings as $i => $binding)
932 if (!$binding[
'PUBLIC_URL'])
934 unset($bindings[$i]);
938 return array_values($bindings);
949 \Bitrix\Landing\Site\Type::setScope(
'KNOWLEDGE');
950 $bindings = \Bitrix\Landing\Binding\Menu::getList($menuCode);
951 $result->setResult(self::removeEmptyBindings($bindings));
963 \Bitrix\Landing\Site\Type::setScope(
'GROUP');
964 $bindings = \Bitrix\Landing\Binding\Group::getList($groupId);
965 $result->setResult(self::removeEmptyBindings($bindings));
static canCreateNewBinding(int $groupId)
static addToSite(int $id, int $fileId, bool $temp=false)
const FEATURE_PERMISSIONS_AVAILABLE
static savePicture($file, $ext=false, $params=array())
static checkFeature(string $feature, array $params=array())
static getGroupBindings(?int $groupId=null)
static unPublicFolder(int $folderId)
static addFolder(int $siteId, array $fields)
static binding(int $id, \Bitrix\Landing\Binding\Entity $binding, bool $bind)
static fullExport($id, array $params=array())
static getFolders(int $siteId, array $filter=[])
static updateFolder(int $siteId, int $folderId, array $fields)
static getMenuBindings(?string $menuCode=null)
static setRights($id, $rights=[])
static getAdditionalFields($id)
static getPreview(int $id)
static bindingToMenu(int $id, string $menuCode)
static moveFolder(int $folderId, ?int $toFolderId, ?int $toSiteId=null)
static removeEmptyBindings(array $bindings)
static unbindingFromMenu(int $id, string $menuCode)
static markFolderDelete(int $id, bool $mark=true)
static getList(array $params=[], $initiator=null)
static clearDisallowFields(array $fields)
static publication(int $id, bool $mark=true)
static bindingToGroup(int $id, int $groupId)
static unbindingFromGroup(int $id, int $groupId)
static markDelete($id, $mark=true)
static add(array $fields)
static uploadFile($id, $picture, $ext=false, array $params=[], $temp=false)
static update($id, array $fields)
static markFolderUnDelete(int $id)
static publicationFolder(int $folderId, bool $mark=true)
static setOperationsForSite($siteId, array $rights=[])
static getOperationsForSite($siteId)
static hasAccessForSite($siteId, $accessType, $deleted=false)
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)