Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
configuration.php
1<?php
2
4
14
15Loc::loadLanguageFile(__FILE__);
16
18{
23 public function downloadAction()
24 {
25 if (Helper::getInstance()->enabledZipMod())
26 {
27 $postfix = $this->getRequest()->getQuery('postfix');
28 if (!empty($postfix))
29 {
30 $context = Helper::getInstance()->getContextUser($postfix);
31 $setting = new Setting($context);
32 $access = Manifest::checkAccess(Manifest::ACCESS_TYPE_EXPORT, $setting->get(Setting::MANIFEST_CODE));
33 if ($access['result'] === true)
34 {
35 $structure = new Structure($context);
36
37 $name = $structure->getArchiveName();
38 if(empty($name))
39 {
40 $name = Helper::DEFAULT_ARCHIVE_NAME;
41 }
42 $name .= '.' . Helper::DEFAULT_ARCHIVE_FILE_EXTENSIONS;
43
44 $archive = new Archive($name);
45
46 $files = [];
47 $fileList = $structure->getFileList();
48 $archiveEntryBuilder = new Zip\EntryBuilder();
49 if (is_array($fileList))
50 {
51 $folderName = Helper::STRUCTURE_FILES_NAME;
52 foreach ($fileList as $file)
53 {
54 $id = (int)$file['ID'];
55 $fileArray = \CFile::getFileArray($id);
56 if ($fileArray)
57 {
58 $entry = $archiveEntryBuilder->createFromFileArray($fileArray, $folderName . '/' . $id);
59 $files[$id] = array_merge(
60 [
61 'NAME' => $fileArray['ORIGINAL_NAME'],
62 ],
63 $file
64 );
65 $archive->addEntry($entry);
66 }
67 }
68 }
69
70 if ($files)
71 {
72 $structure->saveContent(false, Helper::STRUCTURE_FILES_NAME, $files);
73 }
74
75 $smallFilesList = $structure->listSmallFile();
76 if ($smallFilesList)
77 {
78 $structure->saveContent(false, Helper::STRUCTURE_SMALL_FILES_NAME, $smallFilesList);
79 }
80
81 $folderFiles = $structure->getConfigurationFileList();
82 foreach ($folderFiles as $file)
83 {
84 $entry = $archiveEntryBuilder->createFromFileId((int)$file['ID'], $file['NAME']);
85 if ($entry)
86 {
87 $archive->addEntry($entry);
88 }
89 }
90
91 return $archive;
92 }
93 }
94 }
95
96 return null;
97 }
98
99 public function getDefaultPreFilters()
100 {
101 return [
102 new ActionFilter\Authentication(),
103 new ActionFilter\Scope(ActionFilter\Scope::NOT_REST),
104 ];
105 }
106}
static loadLanguageFile($file, $language=null, $normalize=true)
Definition loc.php:224
static checkAccess(string $type, $manifestCode='')
Definition manifest.php:111