2namespace Bitrix\MobileApp\Designer;
5use Bitrix\Main\Application;
6use Bitrix\Main\Entity\FieldError;
7use Bitrix\Main\IO\Directory;
8use Bitrix\Main\IO\File;
9use Bitrix\Main\Text\Encoding;
42 if (
$errors[0]->getCode() == FieldError::INVALID_VALUE)
44 $result = self::IS_ALREADY_EXISTS;
60 private static function getTemplateList()
77 $result = AppTable::delete($appCode);
89 $result = AppTable::getById($appCode);
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),
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"]));
155 "APP_CODE" => $appCode,
178 "APP_CODE" => $appCode,
207 foreach (
$config as $paramName => $value)
209 if (!
$map->has($paramName))
237 $map = new \Bitrix\MobileApp\Designer\ConfigMap();
240 "APP_CODE" => $appCode,
244 $configs =
$res->fetchAll();
245 $targetConfig =
array();
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();
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 self::addVirtualParams($structuredConfig,
$platform);
299 return json_encode($structuredConfig);
314 public static function copyFromTemplate($folder, $appCode, $useOffline =
false, $templateCode =
"simple")
316 if(!in_array($templateCode, self::getTemplateList()))
318 $templateCode =
"simple";
321 $appFolderPath = Application::getDocumentRoot() .
"/" . $folder .
"/";
322 $offlineTemplate = Application::getDocumentRoot() .
"/bitrix/modules/mobileapp/templates_app/offline/";
323 $templatePath = Application::getDocumentRoot() .
"/bitrix/modules/mobileapp/templates_app/".$templateCode.
"/";
325 $directory =
new Directory($templatePath);
326 if($directory->isExists())
328 if (!Directory::isDirectoryExists($appFolderPath))
332 CopyDirFiles($offlineTemplate, $appFolderPath.
"/offline");
335 $items = $directory->getChildren();
336 foreach (
$items as $entry)
341 $filePath = $entry->getPath();
342 $appFilePath = $appFolderPath . $entry->getName();
344 if($entry instanceof Directory)
346 CopyDirFiles($filePath, $appFolderPath.
"/".$entry->getName(),
true,
true);
350 $file =
new File($entry->getPath());
351 File::putFileContents(
353 str_replace(Array(
"#folder#",
"#code#"), Array($folder, $appCode),$file->getContents())
370 $arFields = Array(
"TEMPLATE" => Array());
374 Application::getDocumentRoot() .
"/bitrix/modules/mobileapp/templates/default_app/",
375 Application::getDocumentRoot() .
"/bitrix/templates/" .
$templateId, True, True
378 File::putFileContents(
379 Application::getDocumentRoot() .
"/bitrix/templates/" .
$templateId .
"/description.php",
380 str_replace(Array(
"#mobile_template_name#"), Array(
$templateId), File::getFileContents(Application::getDocumentRoot() .
"/bitrix/templates/" .
$templateId .
"/description.php"))
385 "CONDITION" =>
"CSite::InDir('/" . $folder .
"/')",
390 $default_site_id = \CSite::GetDefSite();
391 if ($default_site_id)
393 $dbTemplates = \CSite::GetTemplateList($default_site_id);
395 $isTemplateFound =
false;
396 while (
$template = $dbTemplates->Fetch())
406 $isTemplateFound =
true;
410 "CONDITION" =>
"CSite::InDir('/" . $folder .
"/')",
416 $obSite = new \CSite;
417 $obSite->Update($default_site_id,
$arFields);
428 $result = AppTable::getById($appCode);
429 $appData =
$result->fetchAll();
431 if (
count($appData) > 0 && is_array($appData[0][
'FILES']))
434 $result = \CFile::GetList([
'ID' =>
'desc'], [
'@ID' => implode(
',', $appData[0][
'FILES'])]);
435 while ($file =
$result->Fetch())
437 $image = \CFile::ResizeImageGet(
439 [
'width' => self::PREVIEW_IMAGE_SIZE,
'height' => self::PREVIEW_IMAGE_SIZE],
445 $files[
'file_' . $file[
'ID']] = [
447 'src' => \CFile::GetFileSRC($file),
448 'preview' => $image[
'src']
484 private static function nameSpaceToArray($namespace, $value)
486 $keys = explode(
"/", $namespace);
491 $temp = & $temp[$keys[
$i]];
500 private static function addVirtualParams(&$structuredConfig,
$platform)
502 if($structuredConfig[
"offline"] && !empty($structuredConfig[
"offline"][
"file_list"]))
504 $offlineParams = &$structuredConfig[
"offline"];
507 $offlineParams[
"change_mark"] = $changeMark;
510 if($structuredConfig[
"buttons"][
"badge"])
512 $structuredConfig[
"buttons_badge"] = $structuredConfig[
"buttons"][
"badge"];
513 unset($structuredConfig[
"buttons"][
"badge"]);
516 $structuredConfig[
"info"] =
array(
static isExists($appCode, $platform)
const SIMPLE_APP_TEMPLATE
static createApp($appCode="", $data=array(), $initConfig=array())
static removeApp($appCode)
static getConfigJSON($appCode, $platform=false)
static registerFileInApp(&$fileArray, $appCode)
static bindTemplate($templateId, $folder, $createNew)
static getAppFiles($appCode)
static removeConfig($appCode="", $platform=array())
static unregisterFileInApp($fileId, $appCode)
static updateConfig($appCode="", $platform="", $config=array())
static addConfig($appCode="", $platform, $config=array())
const APP_TEMPLATE_IS_NOT_EXISTS
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
const BX_RESIZE_IMAGE_EXACT
CopyDirFiles($path_from, $path_to, $ReWrite=true, $Recursive=false, $bDeleteAfterCopy=false, $strExclude="")
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']