Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
template.php
1<?php
3
4use \Bitrix\Landing\Template as TemplateCore;
5use \Bitrix\Landing\Site as SiteCore;
6use \Bitrix\Landing\Landing as LandingCore;
7use \Bitrix\Landing\TemplateRef;
8use \Bitrix\Main\Localization\Loc;
9use \Bitrix\Landing\PublicActionResult;
10
11Loc::loadMessages(__FILE__);
12
14{
20 public static function getList(array $params = array())
21 {
22 $result = new PublicActionResult();
23 $params = $result->sanitizeKeys($params);
24
25 $data = array();
26 $res = TemplateCore::getList($params);
27 while ($row = $res->fetch())
28 {
29 if (isset($row['DATE_CREATE']))
30 {
31 $row['DATE_CREATE'] = (string) $row['DATE_CREATE'];
32 }
33 if (isset($row['DATE_MODIFY']))
34 {
35 $row['DATE_MODIFY'] = (string) $row['DATE_MODIFY'];
36 }
37 $data[] = $row;
38 }
39 $result->setResult($data);
40
41 return $result;
42 }
43
52 protected static function refProcess($id, $type, $method, array $data = array())
53 {
54 $result = new PublicActionResult();
55 $error = new \Bitrix\Landing\Error;
56 $data = (array) $data;
57 $id = (int)$id;
58
60 {
61 $entityClass = SiteCore::class;
62 $method = $method . 'ForSite';
63 }
64 else if ($type == TemplateRef::ENTITY_TYPE_LANDING)
65 {
66 $entityClass = LandingCore::class;
67 $method = $method . 'ForLanding';
68 }
69
70 if (isset($entityClass))
71 {
72 $entity = $entityClass::getList(array(
73 'select' => array(
74 'ID'
75 ),
76 'filter' => array(
77 'ID' => $id
78 )
79 ))->fetch();
80 if ($entity)
81 {
82 $res = TemplateRef::$method(
83 $id,
84 $data
85 );
86 $result->setResult(
87 $res == null ? true : $res
88 );
89 }
90 else
91 {
92 $error->addError(
93 'ENTITY_NOT_FOUND',
94 Loc::getMessage('LANDING_ENTITY_NOT_FOUND')
95 );
96 }
97 }
98
99 $result->setError($error);
100
101 return $result;
102 }
103
110 public static function setSiteRef($id, array $data = array())
111 {
112 return self::refProcess($id, TemplateRef::ENTITY_TYPE_SITE, 'set', $data);
113 }
114
121 public static function setLandingRef($id, array $data = array())
122 {
123 return self::refProcess($id, TemplateRef::ENTITY_TYPE_LANDING, 'set', $data);
124 }
125
131 public static function getSiteRef($id)
132 {
134 }
135
141 public static function getLandingRef($id)
142 {
144 }
145}
static getList(array $params=array())
Definition template.php:20
static refProcess($id, $type, $method, array $data=array())
Definition template.php:52
static setSiteRef($id, array $data=array())
Definition template.php:110
static setLandingRef($id, array $data=array())
Definition template.php:121
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29