Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
configmap.php
1
<?php
9
namespace
Bitrix\MobileApp\Designer
;
10
11
use
Bitrix\Main\Application
;
12
use
Bitrix\Main\IO\File
;
13
use
Bitrix\Main\IO\Path
;
14
use
Bitrix\Main\Localization\Loc
;
15
use
Bitrix\Main\SystemException
;
16
17
Loc::loadMessages
(__FILE__);
18
19
class
ConfigMap
20
{
21
const
VERSION
= 1.1;
22
private
static
$configMap;
23
private
static
$configDescription;
24
29
function
__construct
()
30
{
31
$this->createMap();
32
}
33
34
private
function
createMap()
35
{
36
$mapFilePath =
Application::getDocumentRoot
() .
"/bitrix/modules/mobileapp/maps/config.php"
;
37
$file =
new
File
($mapFilePath);
38
if
(!$file->isExists())
39
{
40
throw
new
SystemException
(
"The map file '"
. $mapFilePath .
"' doesn't exists!"
, 100);
41
}
42
43
$map = include($mapFilePath);
44
45
if
(!is_array($map))
46
{
47
throw
new
SystemException
(
"The map file does exist but has some broken structure."
, 101);
48
}
49
50
self::$configMap = $map;
51
self::$configMap[
"groups"
] = array();
52
$groupTypes = array(
ParameterType::GROUP
,
ParameterType::GROUP_BACKGROUND
,
ParameterType::GROUP_BACKGROUND_LIGHT
);
53
54
foreach
($map[
"types"
] as $paramName => $intType)
55
{
56
if
(in_array($intType, $groupTypes))
57
{
58
self::$configMap[
"groups"
][] = $paramName;
59
}
60
61
}
62
}
63
64
public
function
getMap
()
65
{
66
67
if
(!self::$configMap)
68
{
69
self::createMap();
70
}
71
return
self::$configMap;
72
}
73
79
public
function
getDescriptionConfig
()
80
{
81
if
(self::$configDescription)
82
{
83
return
self::$configDescription;
84
}
85
86
$map = $this->
getMap
();
87
88
$mapTypes = $map[
"types"
];
89
self::$configDescription = array();
90
foreach
($mapTypes as $name => $type)
91
{
92
self::$configDescription[$name] = $this->
getParamDescription
($name, $type);
93
}
94
95
return
self::$configDescription;
96
}
97
98
public
function
getParamDescription
($name, $type)
99
{
100
if
(is_array($type))
101
{
102
$typeParam =
ParameterType::getDesc
($type[
"type"
]);
103
$desc = array_merge($type,$typeParam);
104
}
105
else
106
{
107
$desc =
ParameterType::getDesc
($type);
108
}
109
110
if
(!self::isGroup($name))
111
{
112
$desc[
"parent"
] = $this->
getGroupByParam
($name);
113
}
114
115
return
$desc;
116
}
117
118
public
function
getParamsByGroups
()
119
{
120
$map = $this->
getDescriptionConfig
();
121
$groups = array();
122
foreach
($map as $key => $desc)
123
{
124
$path = explode(
"/"
, $key);
125
$groups[$path[0]][$key] = $desc;
126
}
127
128
return
$groups;
129
}
130
136
public
function
getParamsByType
($paramType)
137
{
138
if
(!$paramType)
139
{
140
return
false
;
141
}
142
143
$stringType =
ParameterType::getStringType
($paramType);
144
$description = $this->
getDescriptionConfig
();
145
$paramsByType = array();
146
foreach
($description as $name => $desc)
147
{
148
if
($stringType == $desc[
"type"
])
149
{
150
$paramsByType[$name] = $desc;
151
}
152
}
153
154
return
$paramsByType;
155
}
156
161
public
function
getImageParams
()
162
{
163
return
$this->
getParamsByType
(
ParameterType::IMAGE
);
164
}
165
171
public
function
getGroupParams
()
172
{
173
$map = $this->
getMap
();
174
return
$map[
"groups"
];
175
}
176
183
public
function
isGroup
($paramName)
184
{
185
$map = $this->
getMap
();
186
$types = $map[
"types"
];
187
return
(array_key_exists($paramName, $types)
188
&&
ParameterType::getStringType
($types[$paramName]) ==
"group"
);
189
}
190
196
public
function
getGroupByParam
($paramName)
197
{
198
$groups = $this->
getGroupParams
();
199
200
if
(is_array($groups))
201
{
202
foreach
($groups as $group)
203
{
204
if
(mb_strpos($paramName, $group) === 0)
205
{
206
return
$group;
207
}
208
}
209
}
210
211
return
""
;
212
}
213
218
public
function
getLangMessages
()
219
{
220
return
Loc::loadLanguageFile
(Path::normalize(__FILE__));
221
}
222
228
public
function
has
($paramName)
229
{
230
return
array_key_exists($paramName, self::getDescriptionConfig());
231
}
232
239
private
function
getValueList($paramName)
240
{
241
$map = $this->
getMap
();
242
return
$map[
"listValues"
][$paramName];
243
}
244
245
private
function
getLimits($paramName)
246
{
247
$map = $this->
getMap
();
248
$limits = $map[
"limits"
][$paramName];
249
if
(!is_array($limits))
250
{
251
$limits = array();
252
}
253
return
$limits;
254
}
255
256
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getDocumentRoot
static getDocumentRoot()
Definition
application.php:717
Bitrix\Main\IO\File
Definition
file.php:7
Bitrix\Main\IO\Path
Definition
path.php:11
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadLanguageFile
static loadLanguageFile($file, $language=null, $normalize=true)
Definition
loc.php:224
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\MobileApp\Designer\ConfigMap
Definition
configmap.php:20
Bitrix\MobileApp\Designer\ConfigMap\__construct
__construct()
Definition
configmap.php:29
Bitrix\MobileApp\Designer\ConfigMap\getParamsByType
getParamsByType($paramType)
Definition
configmap.php:136
Bitrix\MobileApp\Designer\ConfigMap\has
has($paramName)
Definition
configmap.php:228
Bitrix\MobileApp\Designer\ConfigMap\getParamDescription
getParamDescription($name, $type)
Definition
configmap.php:98
Bitrix\MobileApp\Designer\ConfigMap\getParamsByGroups
getParamsByGroups()
Definition
configmap.php:118
Bitrix\MobileApp\Designer\ConfigMap\getMap
getMap()
Definition
configmap.php:64
Bitrix\MobileApp\Designer\ConfigMap\getImageParams
getImageParams()
Definition
configmap.php:161
Bitrix\MobileApp\Designer\ConfigMap\isGroup
isGroup($paramName)
Definition
configmap.php:183
Bitrix\MobileApp\Designer\ConfigMap\getGroupParams
getGroupParams()
Definition
configmap.php:171
Bitrix\MobileApp\Designer\ConfigMap\getGroupByParam
getGroupByParam($paramName)
Definition
configmap.php:196
Bitrix\MobileApp\Designer\ConfigMap\getLangMessages
getLangMessages()
Definition
configmap.php:218
Bitrix\MobileApp\Designer\ConfigMap\getDescriptionConfig
getDescriptionConfig()
Definition
configmap.php:79
Bitrix\MobileApp\Designer\ConfigMap\VERSION
const VERSION
Definition
configmap.php:21
Bitrix\MobileApp\Designer\ParameterType\getStringType
static getStringType($intType)
Definition
parametertype.php:68
Bitrix\MobileApp\Designer\ParameterType\GROUP_BACKGROUND
const GROUP_BACKGROUND
Definition
parametertype.php:10
Bitrix\MobileApp\Designer\ParameterType\GROUP_BACKGROUND_LIGHT
const GROUP_BACKGROUND_LIGHT
Definition
parametertype.php:11
Bitrix\MobileApp\Designer\ParameterType\GROUP
const GROUP
Definition
parametertype.php:12
Bitrix\MobileApp\Designer\ParameterType\getDesc
static getDesc($type, $paramName=false)
Definition
parametertype.php:27
Bitrix\MobileApp\Designer\ParameterType\IMAGE
const IMAGE
Definition
parametertype.php:19
Bitrix\MobileApp\Designer
Definition
app.php:2
modules
mobileapp
lib
designer
configmap.php
Создано системой
1.10.0