function __DSGetInitData() { $map = new \Bitrix\MobileApp\Designer\ConfigMap(); $params = $map->getParamsByGroups(); $groups = array_keys($params); $tmpLangs = array_change_key_case($map->getLangMessages(), CASE_LOWER); $langs = array(); foreach ($tmpLangs as $k => $v) { $langs[str_replace("_", "/", $k)] = $v; } $result = \Bitrix\Mobileapp\Designer\AppTable::getList(array("select" => array("CODE", "FOLDER", "DESCRIPTION", "SHORT_NAME", "NAME", "CONFIG.PLATFORM", "CONFIG.PARAMS"))); $fetchedApps = $result->fetchAll(); $apps = array(); $count = count($fetchedApps); for ($i = 0; $i < $count; $i++) { $apps[] = array("code" => $fetchedApps[$i]["CODE"], "name" => $fetchedApps[$i]["NAME"], "folder" => $fetchedApps[$i]["FOLDER"], "desc" => $fetchedApps[$i]["DESCRIPTION"], "params" => $fetchedApps[$i]["MOBILEAPP_DESIGNER_APP_CONFIG_PARAMS"], "platform" => $fetchedApps[$i]["MOBILEAPP_DESIGNER_APP_CONFIG_PLATFORM"]); } $dbres = \CSiteTemplate::GetList(); $templates = array(); while ($t = $dbres->Fetch()) { $templates[] = $t; } $data = array("map" => array("groups" => $groups, "groupedParams" => $params, "params" => $map->getDescriptionConfig(), "lang" => $tmpLangs), "apps" => $apps, "templates" => $templates); return $data; }
/** * Return configuration in JSON format * * @param $appCode - application code * @param bool $platform - platform code * * @see ConfigTable::getSupportedPlatforms for details on availible platforms * @return string * @throws \Bitrix\Main\ArgumentException */ public static function getConfigJSON($appCode, $platform = false) { $map = new \Bitrix\MobileApp\Designer\ConfigMap(); $res = ConfigTable::getList(array("filter" => array("APP_CODE" => $appCode))); $configs = $res->fetchAll(); $targetConfig = array(); for ($i = 0; $i < count($configs); $i++) { if ($configs[$i]["PLATFORM"] == $platform) { $targetConfig = $configs[$i]; break; } elseif ($configs[$i]["PLATFORM"] == "global") { $targetConfig = $configs[$i]; } } $params = array_key_exists("PARAMS", $targetConfig) ? $targetConfig["PARAMS"] : array(); $imageParamList = $map->getParamsByType(ParameterType::IMAGE); $imageSetParamList = $map->getParamsByType(ParameterType::IMAGE_SET); $structuredConfig = array(); foreach ($params as $key => $value) { if (!$map->has($key)) { continue; } if (array_key_exists($key, $imageParamList)) { $imagePath = \CFile::GetPath($value); if (strlen($imagePath) > 0) { $value = $imagePath; } else { continue; } } if (array_key_exists($key, $imageSetParamList)) { $tmpValue = array(); foreach ($value as $imageCode => $imageId) { $imagePath = \CFile::GetPath($imageId); if (strlen($imagePath) > 0) { $tmpValue[$imageCode] = $imagePath; } else { continue; } } $value = $tmpValue; } $structuredConfig = array_merge_recursive(self::nameSpaceToArray($key, $value), $structuredConfig); } $structuredConfig["info"] = array("designer_version" => ConfigMap::VERSION, "platform" => $platform); if (toUpper(SITE_CHARSET) != "UTF-8") { $structuredConfig = Encoding::convertEncodingArray($structuredConfig, SITE_CHARSET, "UTF-8"); } return json_encode($structuredConfig); }