1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
fileinput.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\UI;
4
5use Bitrix\Main\Loader;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Main\UI\Uploader\Uploader;
8use Bitrix\Main\Web\Json;
9
10Loc::loadMessages(__FILE__);
11
13{
14 public const UPLOAD_IMAGES = 'I';
15 public const UPLOAD_EXTENTION_LIST = 'F';
16 public const UPLOAD_ANY_FILES = 'A';
17
18 protected $elementSetts = array(
19 "name" => "FILE[n#IND#]",
20 "description" => true,
21 "delete" => true,
22 "edit" => true,
23 "thumbSize" => 640
24 );
25 protected $uploadSetts = array(
26 "upload" => false,
27 "uploadType" => "path",
28 "medialib" => false,
29 "fileDialog" => false,
30 "cloud" => false,
31 "maxCount" => 0,
32 "maxSize" => 0
33 );
34 protected $id = "bx_iblockfileprop";
35 protected $files = array();
36 protected static $instance = null;
37 protected $templates = array();
38
39 public static $templatePatterns = array(
40 'description' => <<<HTML
41 <input type="text" id="#id#Description" name="#description_name#" value="#description#" class="adm-fileinput-item-description" />
42HTML
43 ,
44 'regularInput' => '<input class="bx-bxu-fileinput-value" type="hidden" id="#id#Value" name="#input_name#" value="#input_value#" />',
45 'arrayInput' => <<<HTML
46 <input type="hidden" id="#id#Value" name="#input_name#[tmp_name]" value="#input_value#" />
47 <input type="hidden" name="#input_name#[type]" value="#type#" />
48 <input type="hidden" name="#input_name#[name]" value="#name#" />
49 <input type="hidden" name="#input_name#[size]" value="#size#" />
50 <input type="hidden" name="#input_name#[error]" value="0" />
51HTML
52 ,
53 'new' => <<<HTML
54 <div class="adm-fileinput-item">
55 <div class="adm-fileinput-item-preview">
56 <span class="adm-fileinput-item-loading">
57 <span class="container-loading-title">#MESS_LOADING#</span>
58 <span class="container-loading-bg"><span class="container-loading-bg-progress" style="width: 5%;" id="#id#Progress"></span></span>
59 </span>
60 <div class="adm-fileinput-item-preview-icon">
61 <div class="bx-file-icon-container-medium icon-#ext#">
62 <div class="bx-file-icon-cover">
63 <div class="bx-file-icon-corner">
64 <div class="bx-file-icon-corner-fix"></div>
65 </div>
66 <div class="bx-file-icon-images"></div>
67 </div>
68 <div class="bx-file-icon-label"></div>
69 </div>
70 <span class="container-doc-title" id="#id#Name">#name#</span>
71 </div>
72 <div class="adm-fileinput-item-preview-img">#preview#</div>
73 <input class="bx-bxu-fileinput-value" type="hidden" id="#id#Value" name="#input_name#" value="#input_value#" />
74 </div>
75 #description#
76 <div class="adm-fileinput-item-panel">
77 <span class="adm-fileinput-item-panel-btn adm-btn-setting" id="#id#Edit">&nbsp;</span>
78 <span class="adm-fileinput-item-panel-btn adm-btn-del" id="#id#Del">&nbsp;</span>
79 </div>
80 <div id="#id#Properties" class="adm-fileinput-item-properties">#properties#</div>
81 </div>
82HTML
83 ,
84 'unsaved' => <<<HTML
85<div class="adm-fileinput-item-wrapper" id="#id#Block">
86 <div class="adm-fileinput-item">
87 <div class="adm-fileinput-item-preview">
88 <span class="adm-fileinput-item-loading">
89 <span class="container-loading-title">#MESS_LOADING#</span>
90 <span class="container-loading-bg"><span class="container-loading-bg-progress" style="width: 60%;" id="#id#Progress"></span></span>
91 </span>
92 <div class="adm-fileinput-item-preview-icon">
93 <div class="bx-file-icon-container-medium icon-#ext#">
94 <div class="bx-file-icon-cover">
95 <div class="bx-file-icon-corner">
96 <div class="bx-file-icon-corner-fix"></div>
97 </div>
98 <div class="bx-file-icon-images"></div>
99 </div>
100 <div class="bx-file-icon-label"></div>
101 </div>
102 <span class="container-doc-title" id="#id#Name">#name#</span>
103 </div>
104 <div class="adm-fileinput-item-preview-img" id="#id#Canvas"></div>
105 #input#
106 </div>
107 #description#
108 <div class="adm-fileinput-item-panel">
109 <span class="adm-fileinput-item-panel-btn adm-btn-setting" id="#id#Edit">&nbsp;</span>
110 <span class="adm-fileinput-item-panel-btn adm-btn-del" id="#id#Del">&nbsp;</span>
111 </div>
112 <div id="#id#Properties" class="adm-fileinput-item-properties">#properties#</div>
113 </div>
114</div>
115HTML
116 ,
123 'uploaded' => <<<HTML
124<div class="adm-fileinput-item-wrapper" id="#id#Block">
125 <div class="adm-fileinput-item adm-fileinput-item-saved">
126 <div class="adm-fileinput-item-preview">
127 <span class="adm-fileinput-item-loading">
128 <span class="container-loading-title">#MESS_LOADING#</span>
129 <span class="container-loading-bg"><span class="container-loading-bg-progress" style="width: 60%;"></span></span>
130 </span>
131 <div class="adm-fileinput-item-preview-icon">
132 <div class="bx-file-icon-container-medium icon-#ext#">
133 <div class="bx-file-icon-cover">
134 <div class="bx-file-icon-corner">
135 <div class="bx-file-icon-corner-fix"></div>
136 </div>
137 <div class="bx-file-icon-images"></div>
138 </div>
139 <div class="bx-file-icon-label"></div>
140 </div>
141 <span class="container-doc-title" id="#id#Name">#name#</span>
142 </div>
143 <div class="adm-fileinput-item-preview-img" id="#id#Canvas"></div>
144 <input style="display: none;" type="hidden" id="#id#Value" readonly="readonly" name="#input_name#" value="#input_value#" />
145 </div>
146 #description#
147 <div class="adm-fileinput-item-panel">
148 <span class="adm-fileinput-item-panel-btn adm-btn-setting" id="#id#Edit">&nbsp;</span>
149 <span class="adm-fileinput-item-panel-btn adm-btn-del" id="#id#Del">&nbsp;</span>
150 </div>
151 <div id="#id#Properties" class="adm-fileinput-item-properties">#properties#</div>
152 </div>
153</div>
154HTML
155 ,
156 'unexisted' => <<<HTML
157<div class="adm-fileinput-item-wrapper" id="#id#Block">
158 <div class="adm-fileinput-item adm-fileinput-item-saved">
159 <div class="adm-fileinput-item-preview">
160 <span class="adm-fileinput-item-loading">
161 <span class="container-loading-title">#MESS_LOADING#</span>
162 <span class="container-loading-bg"><span class="container-loading-bg-progress" style="width: 60%;"></span></span>
163 </span>
164 <div class="adm-fileinput-item-preview-icon">
165 <div class="bx-file-icon-container-medium icon-#ext#">
166 <div class="bx-file-icon-cover">
167 <div class="bx-file-icon-corner">
168 <div class="bx-file-icon-corner-fix"></div>
169 </div>
170 <div class="bx-file-icon-images"></div>
171 </div>
172 <div class="bx-file-icon-label"></div>
173 </div>
174 <span class="container-doc-title" id="#id#Name">#name#</span>
175 </div>
176 <div class="adm-fileinput-item-preview-img" id="#id#Canvas"></div>
177 <input style="display: none;" data-fileinput="Y" type="file" id="#id#Value" readonly="readonly" name="#input_name#" value="" />
178 </div>
179 #description#
180 <div class="adm-fileinput-item-panel">
181 <span class="adm-fileinput-item-panel-btn adm-btn-del" id="#id#Del">&nbsp;</span>
182 </div>
183 <div id="#id#Properties" class="adm-fileinput-item-properties">#properties#</div>
184 </div>
185</div>
186HTML
187);
191 public function __construct($params = array())
192 {
193 global $USER;
194 $inputs = array_merge($this->elementSetts, $params);
195 $this->elementSetts = array(
196 "name" => $inputs["name"],
197 "description" => !empty($inputs["description"]),
198 "delete" => $inputs['delete'] !== false,
199 "edit" => $inputs['edit'] !== false,
200 "thumbSize" => 640,
201 //"properties" => (is_array($inputs) ? $inputs : array()) //TODO It is needed to deal with additional properties
202 );
203 if (isset($params['id']))
204 $this->elementSetts['id'] = $params['id'];
205 $replace = array(
206 "/\\#MESS_LOADING\\#/" => Loc::getMessage("BXU_LoadingProcess"),
207 "/\\#description\\#/" => ($this->elementSetts["edit"] && $this->elementSetts["description"] ? self::$templatePatterns["description"] : ""),
208 "/\\#properties\\#/" => "",
209 "/[\n\t]+/" => ""
210 );
211 $this->templates["uploaded"] = preg_replace(array_keys($replace), array_values($replace), self::$templatePatterns["uploaded"]);
212 $this->templates["unexisted"] = preg_replace(array_keys($replace), array_values($replace), self::$templatePatterns["unexisted"]);
213 $this->templates["new"] = preg_replace(array_keys($replace), array_values($replace), self::$templatePatterns["new"]);
214 $this->templates["unsaved"] = preg_replace(array_keys($replace), array_values($replace), self::$templatePatterns["unsaved"]);
215 $replace = array(
216 "#input_name#" => $inputs["name"],
217 "#input_value#" => "",
218 "#description_name#" => self::getInputName($inputs["name"], "_descr")
219 );
220 $this->templates["new"] = str_replace(array_keys($replace), array_values($replace), $this->templates["new"]);
221
222 $this->templates["unsavedArray"] = str_replace("#input#", self::$templatePatterns["arrayInput"], $this->templates["unsaved"]);
223 $this->templates["unsaved"] = str_replace("#input#", self::$templatePatterns["regularInput"], $this->templates["unsaved"]);
224
225 $inputs = array_merge($this->uploadSetts, $params);
226
227 $this->uploadSetts = array(
228 "upload" => '',
229 "uploadType" => "path",
230 "medialib" =>
231 isset($inputs['medialib'])
232 && $inputs['medialib'] === true
233 && \COption::GetOptionString('fileman', "use_medialib", "Y") != "N"
234 ,
235 "fileDialog" =>
236 (isset($inputs['file_dialog']) && $inputs['file_dialog'] === true)
237 || (isset($inputs['fileDialog']) && $inputs['fileDialog'] === true)
238 ,
239 "cloud" =>
240 isset($inputs['cloud'])
241 && $inputs['cloud'] === true
242 && $USER?->CanDoOperation("clouds_browse")
243 && \CModule::IncludeModule("clouds")
245 ,
246 "maxCount" => isset($params["maxCount"]) && $params["maxCount"] > 0 ? $params["maxCount"] : 0,
247 "maxSize" => isset($params["maxSize"]) && $params["maxSize"] > 0 ? $params["maxSize"] : 0,
248 "allowUpload" => $params["allowUpload"] ?? self::UPLOAD_ANY_FILES,
249 "allowUploadExt" => trim($params["allowUploadExt"] ?? ''),
250 "allowSort" => isset($params["allowSort"]) && $params["allowSort"] === "N" ? "N" : "Y",
251 );
252 if (!in_array(
253 $this->uploadSetts["allowUpload"],
254 [
255 self::UPLOAD_ANY_FILES,
256 self::UPLOAD_IMAGES,
257 self::UPLOAD_EXTENTION_LIST,
258 ]
259 ))
260 {
261 $this->uploadSetts["allowUpload"] = self::UPLOAD_ANY_FILES;
262 }
263 if ($this->uploadSetts["medialib"] === true)
264 $this->uploadSetts["medialib"] = (Loader::includeModule("fileman") && \CMedialib::CanDoOperation('medialib_view_collection'));
265 if($this->uploadSetts["fileDialog"] === true && !$USER?->CanDoOperation('fileman_view_file_structure'))
266 $this->uploadSetts["fileDialog"] = false;
267
268 if (empty($this->uploadSetts["allowUploadExt"]) && $this->uploadSetts["allowUpload"] === self::UPLOAD_EXTENTION_LIST)
269 $this->uploadSetts["allowUpload"] = self::UPLOAD_ANY_FILES;
270 if (isset($this->elementSetts["id"]))
271 $this->id = 'bx_file_'.mb_strtolower(preg_replace("/[^a-z0-9]/i", "_", $this->elementSetts["id"]));
272 else
273 $this->id = 'bx_file_'.mb_strtolower(preg_replace("/[^a-z0-9]/i", "_", $this->elementSetts["name"]));
274
275 if ($inputs['upload'] === true)
276 {
277 $this->uploadSetts['upload'] = FileInputReceiver::sign(array(
278 "id" => ($inputs['uploadType'] === "hash" ? "hash" : "path"),
279 "allowUpload" => $this->uploadSetts["allowUpload"],
280 "allowUploadExt" => $this->uploadSetts["allowUploadExt"]
281 ));
282 $this->uploadSetts['uploadType'] = (in_array($inputs["uploadType"], array(/*"file",*/ "hash", "path")) ? $inputs["uploadType"] : "path");
283 }
284 self::$instance = $this;
285 }
286
292 public static function createInstance($params = array(), $hashIsID = true)
293 {
294 $c = __CLASS__;
295 return new $c($params, $hashIsID);
296 }
297
302 public function show($values = array(), $getDataFromRequest = false)
303 {
304 \CJSCore::Init(array('fileinput'));
305
306 $files = '';
307 if (!is_array($values) || array_key_exists("tmp_name", $values))
308 {
309 $values = array($this->elementSetts["name"] => $values);
310 }
311 $maxIndex = 0;
312 $pattMaxIndex = mb_strpos($this->elementSetts["name"], "#IND#") > 0 ? str_replace("#IND#", "(\\d+)", preg_quote($this->elementSetts["name"])) : null;
313 foreach($values as $inputName => $fileId)
314 {
315 if ($pattMaxIndex && preg_match("/".$pattMaxIndex."/", $inputName, $matches))
316 {
317 $maxIndex = max($maxIndex, intval($matches[1]));
318 }
319 if ($res = $this->getFile($fileId, $inputName, $getDataFromRequest))
320 {
321 $t = (isset($res["fileId"]) && $res["fileId"] > 0 ? $this->templates["uploaded"] : (is_array($fileId) ? $this->templates["unsavedArray"] : $this->templates["unsaved"]));
322 if (!is_array($res))
323 {
324 $res = $this->formFile($fileId, $inputName);
325 $t = $this->templates["unexisted"];
326 }
327 $patt = array();
328 foreach ($res as $pat => $rep)
329 {
330 $patt["#".$pat."#"] = htmlspecialcharsbx($rep);
331 }
332 if (array_key_exists("#description#", $patt) && str_contains($patt["#description#"], "&amp;quot;"))
333 {
334 $patt["#description#"] = str_replace("&amp;quot;", "&quot;", $patt["#description#"]);
335 }
336 $files .= str_ireplace(array_keys($patt), array_values($patt), $t);
337 $this->files[] = $res;
338 }
339 }
340
341 $canDelete = true ? '' : 'adm-fileinput-non-delete'; // In case we can not delete files
342 $canEdit = ($this->elementSetts["edit"] ? '' : 'adm-fileinput-non-edit');
343
344 $settings = \CUserOptions::GetOption('main', 'fileinput');
345 $settings = (is_array($settings) ? $settings : array(
346 "frameFiles" => "N",
347 "pinDescription" => "N",
348 "mode" => "mode-pict",
349 "presets" => array(
350 array("width" => 200, "height" => 200, "title" => "200x200")
351 ),
352 "presetActive" => 0
353 ));
354
355 if ($this->uploadSetts["maxCount"] == 1)
356 {
357 if ($this->uploadSetts["allowUpload"] === self::UPLOAD_IMAGES)
358 $hintMessage = Loc::getMessage("BXU_DNDMessage01");
359 else if ($this->uploadSetts["allowUpload"] === self::UPLOAD_EXTENTION_LIST)
360 $hintMessage = Loc::getMessage("BXU_DNDMessage02", array("#ext#" => htmlspecialcharsbx($this->uploadSetts["allowUploadExt"])));
361 else
362 $hintMessage = Loc::getMessage("BXU_DNDMessage03");
363
364 if ($this->uploadSetts["maxSize"] > 0)
365 $hintMessage .= Loc::getMessage("BXU_DNDMessage04", array("#size#" => \CFile::FormatSize($this->uploadSetts["maxSize"])));
366 }
367 else
368 {
369 $maxCount = ($this->uploadSetts["maxCount"] > 0 ? GetMessage("BXU_DNDMessage5", array("#maxCount#" => htmlspecialcharsbx($this->uploadSetts["maxCount"]))) : "");
370 if ($this->uploadSetts["allowUpload"] === self::UPLOAD_IMAGES)
371 $hintMessage = Loc::getMessage("BXU_DNDMessage1", array("#maxCount#" => $maxCount));
372 else if ($this->uploadSetts["allowUpload"] == self::UPLOAD_EXTENTION_LIST)
373 $hintMessage = Loc::getMessage("BXU_DNDMessage2", array("#ext#" => htmlspecialcharsbx($this->uploadSetts["allowUploadExt"]), "#maxCount#" => $maxCount));
374 else
375 $hintMessage = Loc::getMessage("BXU_DNDMessage3", array("#maxCount#" => $maxCount));
376 if ($this->uploadSetts["maxSize"] > 0)
377 $hintMessage .= Loc::getMessage("BXU_DNDMessage4", array("#size#" => \CFile::FormatSize($this->uploadSetts["maxSize"])));
378 }
379
380 $this->getExtDialogs();
381
382 $uploadSetts = $this->uploadSetts + $settings;
383 if (array_key_exists("presets", $settings))
384 {
385 $uploadSetts["presets"] = $settings["presets"];
386 $uploadSetts["presetActive"] = $settings["presetActive"];
387 }
388 $uploadSetts["maxIndex"] = $maxIndex;
389 $template = \CUtil::JSEscape($this->templates["new"]);
390 $classSingle = (array_key_exists("maxCount", $uploadSetts) && intval($uploadSetts["maxCount"]) == 1 ? "adm-fileinput-wrapper-single" : "");
391 $uploadSetts = Json::encode($uploadSetts);
392 $elementSetts = Json::encode($this->elementSetts);
393 $values = Json::encode($this->files);
394 $mes = array(
395 "preview" => GetMessage("BXU_Preview"),
396 "nonPreview" => GetMessage("BXU_NonPreview")
397 );
398
399 $settings["modePin"] = (isset($settings["pinDescription"]) && $settings["pinDescription"] == "Y" && $this->elementSetts["description"] ? "mode-with-description" : "");
400 $t = <<<HTML
401<div class="adm-fileinput-wrapper {$classSingle}">
402<div class="adm-fileinput-btn-panel">
403 <span class="adm-btn add-file-popup-btn" id="{$this->id}_add"></span>
404 <div class="adm-fileinput-mode {$settings["mode"]}" id="{$this->id}_mode">
405 <a href="#" class="mode-pict" id="{$this->id}ThumbModePreview" title="{$mes["preview"]}"></a>
406 <a href="#" class="mode-file" id="{$this->id}ThumbModeNonPreview" title="{$mes["nonPreview"]}"></a>
407 </div>
408</div>
409<div id="{$this->id}_block" class="adm-fileinput-area {$canDelete} {$canEdit} {$settings['mode']} {$settings["modePin"]}">
410 <div class="adm-fileinput-area-container" id="{$this->id}_container">{$files}</div>
411 <span class="adm-fileinput-drag-area-hint" id="{$this->id}Notice">{$hintMessage}</span>
412<script>
413(function(BX)
414{
415 if (BX)
416 {
417 BX.ready(BX.defer(function(){
418 new BX.UI.FileInput('{$this->id}', {$uploadSetts}, {$elementSetts}, {$values}, '{$template}');
419 }));
420 }
421})(window["BX"] || top["BX"]);
422</script>
423</div>
424</div>
425HTML;
426 return $t;
427 }
428 private function getExtDialogs()
429 {
430 if ($this->uploadSetts["medialib"] && Loader::includeModule("fileman"))
431 {
432 $this->uploadSetts["medialib"] = array(
433 "click" => "OpenMedialibDialog".$this->id,
434 "handler" => "SetValueFromMedialib".$this->id
435 );
436 \CMedialib::ShowDialogScript(array(
437 "event" => $this->uploadSetts["medialib"]["click"],
438 "arResultDest" => array(
439 "FUNCTION_NAME" => $this->uploadSetts["medialib"]["handler"]
440 )
441 ));
442 }
443 if ($this->uploadSetts["fileDialog"])
444 {
445 $this->uploadSetts["fileDialog"] = array(
446 "click" => "OpenFileDialog".$this->id,
447 "handler" => "SetValueFromFileDialog".$this->id
448 );
450 (
451 Array(
452 "event" => $this->uploadSetts["fileDialog"]["click"],
453 "arResultDest" => array("FUNCTION_NAME" => $this->uploadSetts["fileDialog"]["handler"]),
454 "arPath" => array("SITE" => SITE_ID, "PATH" =>"/upload"),
455 "select" => 'F',// F - file only, D - folder only
456 "operation" => 'O',
457 "showUploadTab" => true,
458 "allowAllFiles" => true,
459 "SaveConfig" => true,
460 )
461 );
462 }
463 }
464 private function formFile($fileId = "", $inputName = "file")
465 {
466 $result = array(
467 'id' => $fileId,
468 'name' => 'Unknown',
469 'description_name' => self::getInputName($inputName, "_descr"),
470 'description' => '',
471 'size' => 0,
472 'type' => 'unknown',
473 'input_name' => $inputName,
474 'input_value' => $fileId,
475 'entity' => "file",
476 'ext' => ''
477 );
478 if (!empty($this->elementSetts["properties"]))
479 {
480 foreach ($this->elementSetts["properties"] as $key)
481 {
482 $result[$key."_name"] = self::getInputName($inputName, "_".$key);
483 $result[$key] = "";
484 }
485 }
486 return $result;
487 }
488 private function getFile($fileId = "", $inputName = "file", $getDataFromRequest = false)
489 {
490 $result = null;
491 $properties = array();
492 if (is_array($fileId) && array_key_exists("ID", $fileId))
493 {
494 $properties = $fileId;
495 unset($properties["ID"]);
496 $fileId = $fileId["ID"];
497 }
498
499 if ($fileId > 0 && ($ar = \CFile::GetFileArray($fileId)) && is_array($ar))
500 {
501 $name = ($ar['ORIGINAL_NAME'] <> ''?$ar['ORIGINAL_NAME']:$ar['FILE_NAME']);
502 $result = array(
503 'fileId' => $fileId,
504 'id' => $this->id.'_'.$fileId,
505 'name' => $name,
506 'description_name' => self::getInputName($inputName, "_descr"),
507 'description' => str_replace('"', "&quot;", $ar['DESCRIPTION']),
508 'size' => $ar['FILE_SIZE'],
509 'type' => $ar['CONTENT_TYPE'],
510 'input_name' => $inputName,
511 'input_value' => $fileId,
512 'entity' => (($ar["WIDTH"] > 0 && $ar["HEIGHT"] > 0) ? "image" : "file"),
513 'ext' => GetFileExtension($name),
514 'real_url' => $ar['SRC']
515 );
516 if ($result['entity'] == "image")
517 {
519 $result['preview_url'] = FileInputUnclouder::getSrcWithResize($ar, array('width' => 200, 'height' => 200));
520 $result['width'] = $ar["WIDTH"];
521 $result['height'] = $ar["HEIGHT"];
522 }
523 }
524 else
525 {
526 $file = null;
527 if (is_array($fileId) && array_key_exists("tmp_name", $fileId))
528 $file = array(
529 "tmp_name" => $fileId["tmp_name"],
530 "type" => (array_key_exists("type", $fileId) ? $fileId["type"] : null),
531 "name" => (array_key_exists("name", $fileId) ? $fileId["name"] : null),
532 "description" => (array_key_exists("description", $fileId) ? $fileId["description"] : null)
533 );
534 else if (is_string($fileId))
535 $file = array(
536 "tmp_name" => $fileId,
537 "type" => null,
538 "name" => null,
539 "description" => null
540 );
541 if (is_array($file) && ($paths = Uploader::getPaths($file["tmp_name"])) &&
542 ($flTmp = \CBXVirtualIo::GetInstance()->GetFile($paths["tmp_name"])) && $flTmp->IsExists())
543 {
544 $name = is_string($file["name"]) && $file["name"] <> '' ? $file["name"] : $flTmp->getName();
545 $result = array(
546 'id' => md5($file["tmp_name"]),
547 'name' => $name,
548 'description_name' => self::getInputName($inputName, "_descr"),
549 'description' => is_string($file["description"]) && $file["description"] <> '' ? $file["description"] : "",
550 'size' => $flTmp->GetFileSize(),
551 'type' => is_string($file["type"]) && $file["type"] <> '' ? $file["type"] : $flTmp->getType(),
552 'input_name' => $inputName,
553 'input_value' => $file["tmp_name"],
554 'entity' => "file",
555 'ext' => GetFileExtension($name),
556 'real_url' => $paths["tmp_url"]
557 );
558
559 $info = (new \Bitrix\Main\File\Image($paths["tmp_name"]))->getInfo();
560 if ($info)
561 {
562 $result['entity'] = "image";
563 $result['tmp_url'] = $paths["tmp_url"];
564 if (($mime = $info->getMime()) <> '')
565 $result['type'] = $mime;
566 $result['width'] = $info->getWidth();
567 $result['height'] = $info->getHeight();
568 }
569 }
570 }
571 if (is_array($result) && !empty($this->elementSetts["properties"]))
572 {
573 $request = null;
574 if ($getDataFromRequest === true)
575 {
576 $request = \Bitrix\Main\Context::getCurrent()->getRequest();
577 $result["description"] = $request->isPost() ? $request->getPost($result["description_name"]) : $request->getQuery($result["description_name"]);
578 }
579 foreach ($this->elementSetts["properties"] as $key)
580 {
581 $result[$key."_name"] = self::getInputName($inputName, "_".$key);
582 $result[$key] = (is_null($request) ? $properties[$key] : ($request->isPost() ? $request->getPost($result[$key."_name"]) : $request->getQuery($result[$key."_name"])));
583 }
584 }
585 return $result;
586 }
587
588 private static function getInputName($inputName, $type = "")
589 {
590 if ($type == "")
591 return $inputName;
592 $p = mb_strpos($inputName, "[");
593 return ($p > 0) ? mb_substr($inputName, 0, $p).$type.mb_substr($inputName, $p) : $inputName.$type;
594 }
595
601 public static function prepareFile($file)
602 {
603 if (!empty($file["tmp_name"]))
604 {
605
606 }
607 return $file;
608 }
609}
$type
Определения event.php:7
static includeModule($moduleName)
Определения loader.php:67
$name
Определения entity.php:33
static str_replace($search, $replace, $str)
Определения stringhelper.php:74
static prepareFile($file)
Определения fileinput.php:601
const UPLOAD_IMAGES
Определения fileinput.php:14
show($values=array(), $getDataFromRequest=false)
Определения fileinput.php:302
static $templatePatterns
Определения fileinput.php:39
__construct($params=array())
Определения fileinput.php:191
static createInstance($params=array(), $hashIsID=true)
Определения fileinput.php:292
$elementSetts
Определения fileinput.php:18
const UPLOAD_ANY_FILES
Определения fileinput.php:16
static $instance
Определения fileinput.php:36
const UPLOAD_EXTENTION_LIST
Определения fileinput.php:15
static sign($params=array())
Определения fileinputreceiver.php:41
static getSrcWithResize($file=array(), $size=array())
Определения fileinputunclouder.php:39
static getSrc($file=array())
Определения fileinputunclouder.php:13
static ShowScript($arConfig)
Определения file_dialog.php:9
static GetInstance()
Определения virtual_io.php:60
static HasActiveBuckets()
Определения storage.php:1801
static Init($arExt=array(), $bReturn=false)
Определения jscore.php:66
& nbsp
Определения epilog_main_admin.php:38
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
Определения file_new.php:657
$maxCount
Определения options.php:1622
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$p
Определения group_list_element_edit.php:23
global $USER
Определения csv_new_run.php:40
$inputName
Определения options.php:197
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения backup.php:924
GetFileExtension($path)
Определения tools.php:2972
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$settings
Определения product_settings.php:43
<? endif;?> window document title
Определения prolog_main_admin.php:76
$ar
Определения options.php:199
font style
Определения invoice.php:442
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$paths
Определения options.php:2080
$matches
Определения index.php:22
const SITE_ID
Определения sonet_set_content_view.php:12