Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
tools.php
1<?php
3
4
8
9class Tools
10{
11 private static $jsMobileCorePath = "/bitrix/cache/js/mobileapp_designer/mobile_core.js";
12
13 public static function getMobileJSCorePath()
14 {
15 self::generateMobileJSFile();
16 return self::$jsMobileCorePath;
17 }
18
19 private static function generateMobileJSFile()
20 {
21 $lastModificationHash = Option::get("mobileapp","mobile_core_modification","");
22 $coreMobileFileList = array(
23 "/bitrix/js/main/core/core.js",
24 "/bitrix/js/main/core/core_promise.js",
25 "/bitrix/js/main/core/core_ajax.js",
26 "/bitrix/js/main/core/core_db.js",
27 "/bitrix/js/mobileapp/bitrix_mobile.js",
28 "/bitrix/js/mobileapp/mobile_lib.js"
29 );
30
31 $modificationHash = self::getArrayFilesHash($coreMobileFileList);
32
33 $coreFile = new File(Application::getDocumentRoot().self::$jsMobileCorePath);
34
35 if($modificationHash == $lastModificationHash && $coreFile->isExists())
36 return;
37
38 CheckDirPath(Application::getDocumentRoot()."/bitrix/cache/js/mobileapp_designer/");
39
40 $content = "";
41 foreach ($coreMobileFileList as $filePath)
42 {
43 $file = new \Bitrix\Main\IO\File(Application::getDocumentRoot().$filePath);
44 if($file->isExists())
45 {
46 $fileContent = $file->getContents();
47 $content.="\n\n".$fileContent;
48
49 }
50 }
51
52
53 $coreFile->open("w+");
54 $coreFile->putContents($content);
55 $coreFile->close();
56
57 Option::set("mobileapp","mobile_core_modification", $modificationHash);
58
59 }
60
61 public static function getArrayFilesHash($fileList = array())
62 {
63 $fileModificationString = "";
64 foreach ($fileList as $item)
65 {
66 $file = new File(Application::getDocumentRoot().$item);
67 $fileModificationString .= $item."|";
68 if($file->isExists())
69 {
70 $file->getModificationTime();
71 $fileModificationString .= "|".$file->getModificationTime();
72 }
73 }
74
75 return md5($fileModificationString);
76 }
77
78
79}
static getArrayFilesHash($fileList=array())
Definition tools.php:61