33 public static function createApp($appCode =
"", $data = array(), $initConfig = array())
37 $fields[
"CODE"] = $appCode;
38 $dbResult = AppTable::add($fields);
39 if (!$dbResult->isSuccess())
41 $errors = $dbResult->getErrors();
42 if ($errors[0]->getCode() == FieldError::INVALID_VALUE)
46 elseif ($errors[0]->getCode() == FieldError::EMPTY_REQUIRED)
89 $result = AppTable::getById($appCode);
90 $appData = $result->fetchAll();
91 if (count($appData) > 0)
93 if(!is_array($appData[0][
"FILES"]))
94 $appData[0][
"FILES"] = [];
95 $appData[0][
"FILES"][] = $fileArray[
"fileID"];
96 AppTable::update($appCode, array(
"FILES" => $appData[0][
"FILES"]));
97 $arImage = \CFile::ResizeImageGet(
99 array(
"width" => self::PREVIEW_IMAGE_SIZE,
"height" => self::PREVIEW_IMAGE_SIZE),
100 BX_RESIZE_IMAGE_EXACT,
105 $fileArray[
"img_source_src"] = $arImage[
"src"];
118 $result = AppTable::getById($appCode);
119 $appData = $result->fetchAll();
120 if (count($appData) > 0)
123 $index = array_search($fileId, $appData[0][
"FILES"]);
124 if ($index !==
false)
126 unset($appData[0][
"FILES"][$index]);
127 AppTable::update($appCode, array(
"FILES" => $appData[0][
"FILES"]));
237 $map = new \Bitrix\MobileApp\Designer\ConfigMap();
238 $res = ConfigTable::getList(array(
240 "APP_CODE" => $appCode,
244 $configs = $res->fetchAll();
245 $targetConfig = array();
247 for ($i = 0; $i < count($configs); $i++)
249 if ($configs[$i][
"PLATFORM"] == $platform)
251 $targetConfig = $configs[$i];
254 elseif ($configs[$i][
"PLATFORM"] ==
"global")
256 $targetConfig = $configs[$i];
260 $params = array_key_exists(
"PARAMS", $targetConfig) ? $targetConfig[
"PARAMS"]: array() ;
263 $structuredConfig = array();
265 foreach ($params as $key => $value)
267 if (!$map->has($key))
272 if (array_key_exists($key, $imageParamList))
274 $imagePath = \CFile::GetPath($value);
281 if (array_key_exists($key, $imageSetParamList))
284 foreach ($value as $imageCode => $imageId)
286 $imagePath = \CFile::GetPath($imageId);
288 $tmpValue[$imageCode] = $imagePath;
294 $structuredConfig = array_merge_recursive(self::nameSpaceToArray($key, $value), $structuredConfig);
297 if(toUpper(SITE_CHARSET) !=
"UTF-8")
299 $structuredConfig = Encoding::convertEncodingArray($structuredConfig, SITE_CHARSET,
"UTF-8");
302 self::addVirtualParams($structuredConfig, $platform);
304 return json_encode($structuredConfig);
358 str_replace(Array(
"#folder#",
"#code#"), Array($folder, $appCode),$file->getContents())
375 $arFields = Array(
"TEMPLATE" => Array());
383 File::putFileContents(
385 str_replace(Array(
"#mobile_template_name#"), Array($templateId), File::getFileContents(
Application::getDocumentRoot() .
"/bitrix/templates/" . $templateId .
"/description.php"))
388 $arFields[
"TEMPLATE"][] = Array(
390 "CONDITION" =>
"CSite::InDir('/" . $folder .
"/')",
391 "TEMPLATE" => $templateId
395 $default_site_id = \CSite::GetDefSite();
396 if ($default_site_id)
398 $dbTemplates = \CSite::GetTemplateList($default_site_id);
399 $arFields[
"LID"] = $default_site_id;
400 $isTemplateFound =
false;
401 while ($template = $dbTemplates->Fetch())
403 $arFields[
"TEMPLATE"][] = array(
404 "TEMPLATE" => $template[
'TEMPLATE'],
405 "SORT" => $template[
'SORT'],
406 "CONDITION" => $template[
'CONDITION']
409 if ($template[
"TEMPLATE"] == $templateId && !$createNew && !$isTemplateFound)
411 $isTemplateFound =
true;
413 $arFields[
"TEMPLATE"][] = Array(
415 "CONDITION" =>
"CSite::InDir('/" . $folder .
"/')",
416 "TEMPLATE" => $templateId
421 $obSite = new \CSite;
422 $obSite->Update($default_site_id, $arFields);
433 $result = AppTable::getById($appCode);
434 $appData = $result->fetchAll();
436 if (count($appData) > 0 && is_array($appData[0][
'FILES']))
439 $result = \CFile::GetList([
'ID' =>
'desc'], [
'@ID' => implode(
',', $appData[0][
'FILES'])]);
440 while ($file = $result->Fetch())
442 $image = \CFile::ResizeImageGet(
444 [
'width' => self::PREVIEW_IMAGE_SIZE,
'height' => self::PREVIEW_IMAGE_SIZE],
445 BX_RESIZE_IMAGE_EXACT,
450 $files[
'file_' . $file[
'ID']] = [
452 'src' => \CFile::GetFileSRC($file),
453 'preview' => $image[
'src']