/** * @param $strInputName * @param string $strFileId * @param bool|array $showInfo * @param array $inputs * @return string */ public static function Show($strInputName, $strFileId = "", $showInfo = false, $inputs = array()) { global $USER; CJSCore::Init('file_input'); ob_start(); $uploadInput = $inputs['upload'] === true ? array() : $inputs['upload']; $medialibInput = $inputs['medialib'] === true ? array() : $inputs['medialib']; $fileDialogInput = $inputs['file_dialog'] === true ? array() : $inputs['file_dialog']; $cloudInput = $inputs['cloud'] === true ? array() : $inputs['cloud']; self::Init($showInfo, $strInputName); //1. Upload from PC if (is_array($uploadInput)) { self::$bUseUpload = true; if (!array_key_exists("NAME", $uploadInput)) { $uploadInput["NAME"] = $strInputName; } } //2. Select file from medialib if (COption::GetOptionString('fileman', "use_medialib", "Y") != "N" && is_array($medialibInput)) { self::$bUseMedialib = true; if (!array_key_exists("NAME", $medialibInput)) { $medialibInput["NAME"] = $strInputName; } } //3. Select file from file dialog if (is_array($fileDialogInput)) { self::$bUseFileDialog = true; if (!array_key_exists("NAME", $fileDialogInput)) { $fileDialogInput["NAME"] = $strInputName; } } //4. Select file from cloud if (is_array($cloudInput) && $USER->CanDoOperation("clouds_browse") && CModule::IncludeModule("clouds") && CCloudStorage::HasActiveBuckets()) { self::$bUseCloud = true; if (!array_key_exists("NAME", $cloudInput)) { $cloudInput["NAME"] = $strInputName; } } if ($inputs['description'] !== false) { self::$bShowDescInput = true; self::$descInputName = isset($inputs['description']["NAME"]) ? $inputs['description']["NAME"] : self::GetInputName($strInputName, "_descr"); } if ($inputs['del'] !== false) { self::$bShowDelInput = true; self::$delInputName = isset($inputs['del']["NAME"]) ? $inputs['del']["NAME"] : self::GetInputName($strInputName, "_del"); } // $arFile - Array with current file or false if it's empty self::$curFileIds = is_array($strFileId) && !array_key_exists("tmp_name", $strFileId) ? $strFileId : array($strFileId); self::$curFiles = array(); self::$bFileExists = false; foreach (self::$curFileIds as $fileId) { if (is_array($fileId)) { continue; } if (strlen($fileId) <= 1 && intVal($fileId) === 0) { continue; } self::$bFileExists = true; if ($arFile = self::GetFile($fileId)) { $arFile['FILE_NOT_FOUND'] = false; if (self::$bShowDescInput && isset($inputs['description']['VALUE'])) { $arFile['DESCRIPTION'] = $inputs['description']['VALUE']; } } else { $arFile = array('FILE_NOT_FOUND' => true, 'DEL_NAME' => self::$delInputName); } self::$curFiles[] = $arFile; } self::$bViewMode = self::IsViewMode(); if (self::$bViewMode) { self::$bShowDelInput = false; } if (!self::$bViewMode || self::$bFileExists) { $inputs = array('upload' => self::$bUseUpload, 'medialib' => self::$bUseMedialib, 'file_dialog' => self::$bUseFileDialog, 'cloud' => self::$bUseCloud, 'del' => self::$bShowDelInput, 'description' => self::$bShowDescInput); self::$arInputs = array('upload' => $uploadInput, 'medialib' => $medialibInput, 'file_dialog' => $fileDialogInput, 'cloud' => $cloudInput); self::DisplayControl($inputs); } $result = ob_get_contents(); ob_end_clean(); return $result; }