Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
configmap.php
1<?php
10
16
17Loc::loadMessages(__FILE__);
18
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();
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 {
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}
static loadLanguageFile($file, $language=null, $normalize=true)
Definition loc.php:224
static loadMessages($file)
Definition loc.php:64
static getDesc($type, $paramName=false)