Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
template.php
1
<?php
2
namespace
Bitrix\Landing\PublicAction
;
3
4
use \Bitrix\Landing\Template as TemplateCore;
5
use \Bitrix\Landing\Site as
SiteCore
;
6
use \Bitrix\Landing\Landing as
LandingCore
;
7
use \Bitrix\Landing\TemplateRef;
8
use \Bitrix\Main\Localization\Loc;
9
use \Bitrix\Landing\PublicActionResult;
10
11
Loc::loadMessages
(__FILE__);
12
13
class
Template
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
59
if
($type ==
TemplateRef::ENTITY_TYPE_SITE
)
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
{
133
return
self::refProcess
($id,
TemplateRef::ENTITY_TYPE_SITE
,
'get'
);
134
}
135
141
public
static
function
getLandingRef
($id)
142
{
143
return
self::refProcess
($id,
TemplateRef::ENTITY_TYPE_LANDING
,
'get'
);
144
}
145
}
Bitrix\Landing\PublicAction\Template
Definition
template.php:14
Bitrix\Landing\PublicAction\Template\getLandingRef
static getLandingRef($id)
Definition
template.php:141
Bitrix\Landing\PublicAction\Template\getList
static getList(array $params=array())
Definition
template.php:20
Bitrix\Landing\PublicAction\Template\refProcess
static refProcess($id, $type, $method, array $data=array())
Definition
template.php:52
Bitrix\Landing\PublicAction\Template\setSiteRef
static setSiteRef($id, array $data=array())
Definition
template.php:110
Bitrix\Landing\PublicAction\Template\getSiteRef
static getSiteRef($id)
Definition
template.php:131
Bitrix\Landing\PublicAction\Template\setLandingRef
static setLandingRef($id, array $data=array())
Definition
template.php:121
Bitrix\Landing\PublicActionResult
Definition
publicactionresult.php:5
Bitrix\Landing\TemplateRef\ENTITY_TYPE_SITE
const ENTITY_TYPE_SITE
Definition
templateref.php:11
Bitrix\Landing\TemplateRef\ENTITY_TYPE_LANDING
const ENTITY_TYPE_LANDING
Definition
templateref.php:16
Bitrix\Main\DB\Connection\$host
$host
Definition
connection.php:29
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Landing\Landing
Definition
cache.php:2
Bitrix\Landing\PublicAction
Definition
block.php:2
Bitrix\Landing\Site
Definition
cookies.php:2
modules
landing
lib
publicaction
template.php
Создано системой
1.10.0