1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
savesource.php
См. документацию.
1<?php
2namespace Bitrix\Translate\Controller\Editor;
3
4use Bitrix\Main;
5use Bitrix\Translate;
6use Bitrix\Main\Localization\Loc;
7
12 extends Operation
13{
21 public function run($file = '')
22 {
23 Loc::loadLanguageFile(__DIR__. '/operation.php');
24 Loc::loadLanguageFile(__FILE__);
25
26 $result = [];
27 if (empty($file))
28 {
29 $this->addError(new Main\Error(Loc::getMessage('TR_EDIT_FILE_PATH_ERROR')));
30 return $result;
31 }
32 $normalized = Main\IO\Path::normalize($file);
33 if ($normalized != $file)
34 {
35 $this->addError(new Main\Error(Loc::getMessage('TR_EDIT_FILE_WRONG_NAME')));
36 return $result;
37 }
38 $file = $normalized;
39 if (!Translate\IO\Path::isLangDir($file, true) || !Translate\IO\Path::isPhpFile($file))
40 {
41 $this->addError(new Main\Error(Loc::getMessage('TR_EDIT_ERROR_FILE_NOT_LANG', ['#FILE#' => $file])));
42 return $result;
43 }
45 {
46 $this->addError(new Main\Error(Loc::getMessage('TR_EDIT_FILE_WRONG_NAME')));
47 return $result;
48 }
49
50 $request = $this->controller->getRequest();
51
52 $languagesToUpdate = [];
53
55
56 // languages to update
57 $languagesToUpdateTmp = $request->getPost('LANGS');
58 if ($languagesToUpdateTmp !== null && \is_array($languagesToUpdateTmp) && \count($languagesToUpdateTmp) > 0)
59 {
60 $languagesToUpdate = \array_intersect($languagesToUpdateTmp, $enabledLanguagesList);
61 }
62 unset($languagesToUpdateTmp);
63
65 $documentRoot = \rtrim(Translate\IO\Path::tidy(Main\Application::getDocumentRoot()), '/');
66
67 foreach ($enabledLanguagesList as $langId)
68 {
69 if (!\in_array($langId, $languagesToUpdate))
70 {
71 continue;
72 }
73
74 $langRelPath = Translate\IO\Path::replaceLangId($file, $langId);
75 $fullPath = Translate\IO\Path::tidy($documentRoot.'/'.$langRelPath);
76 $fullPath = Main\Localization\Translation::convertLangPath($fullPath, $langId);
77
78 $langFile = new Translate\File($fullPath);
80 ->setLangId($langId)
81 ->setOperatingEncoding($currentEncoding);
82
83 // backup
84 if ($langFile->isExists() && Translate\Config::needToBackUpFiles())
85 {
86 if (!$langFile->backup())
87 {
88 $this->addError(new Main\Error(
89 Loc::getMessage('TR_CREATE_BACKUP_ERROR', ['#FILE#' => $langFile->getPath()])
90 ));
91 }
92 }
93
94 $fileSrcForSave = $request->getPost('SRC_'. $langId);
95
96 if (empty($fileSrcForSave) || !\is_string($fileSrcForSave))
97 {
98 $this->addError(new Main\Error(Loc::getMessage('TR_EDIT_PARAM_ERROR')));
99 continue;
100 }
101
102 if (!$langFile->lint($fileSrcForSave))
103 {
104 $this->addErrors($langFile->getErrors());
105 continue;
106 }
107
108 try
109 {
110 if (!$langFile->putContents($fileSrcForSave))
111 {
112 if ($langFile->hasErrors())
113 {
114 $this->addErrors($langFile->getErrors());
115 }
116 }
117 else
118 {
119 // check
120 if (!$langFile->load() && $langFile->hasErrors())
121 {
122 $this->addErrors($langFile->getErrors());
123 }
124 elseif ($langFile->count() > 0)
125 {
126 $langFile->updatePhraseIndex();
127 }
128 }
129 }
130 catch (Main\IO\IoException $exception)
131 {
132 if (!$langFile->isExists())
133 {
134 $this->addError(new Main\Error(
135 Loc::getMessage('TR_ERROR_WRITE_CREATE', ['#FILE#' => $langFile->getPath()])
136 ));
137 }
138 else
139 {
140 $this->addError(new Main\Error(
141 Loc::getMessage('TR_ERROR_WRITE_UPDATE', ['#FILE#' => $langFile->getPath()])
142 ));
143 }
144 }
145 }
146
147 if (!$this->hasErrors())
148 {
149 $result['SUMMARY'] = Loc::getMessage('TR_EDIT_SAVING_COMPLETED');
150 }
151
152 return $result;
153 }
154}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static normalize($path)
Определения path.php:22
static getCurrentEncoding()
Определения translation.php:104
static convertLangPath($langFile, $language)
Определения translation.php:267
static getEnabledLanguages()
Определения config.php:211
static replaceLangId(string $path, string $langId)
Определения path.php:98
static tidy(string $path)
Определения path.php:16
static isAllowPath(string $path)
Определения permission.php:23
$langFile
Определения .description.php:2
$result
Определения get_property_values.php:14
Определения Image.php:9
Определения directory.php:3
hasErrors()
Определения errorableimplementation.php:17
Определения autoload.php:3
addErrors(array $errors)
Определения error.php:41
addError(Main\Error $error)
Определения error.php:22
trait Error
Определения error.php:11
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</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."%"
Определения waybill.php:936