/** * Generate Select Box Element * * @param array $aInput * @return string */ function genInputFiles(&$aInput, $sInfo = '', $sError = '') { bx_import('BxDolUploader'); $sUniqId = genRndPwd(8, false); $sUploaders = ''; $oUploader = null; foreach ($aInput['uploaders'] as $sUploaderObject) { $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $aInput['storage_object'], $sUniqId); if (!$oUploader) { continue; } $sGhostTemplate = false; if (isset($aInput['ghost_template']) && is_object($aInput['ghost_template'])) { // form is not submitted and ghost template is BxDolFormNested object $oFormNested = $aInput['ghost_template']; if ($oFormNested instanceof BxDolFormNested) { $sGhostTemplate = $oFormNested->getCode(); } } elseif (isset($aInput['ghost_template']) && is_array($aInput['ghost_template']) && isset($aInput['ghost_template']['inputs'])) { // form is not submitted and ghost template is form array bx_import('BxDolFormNested'); $oFormNested = new BxDolFormNested($aInput['name'], $aInput['ghost_template'], $this->aParams['db']['submit_name'], $this->oTemplate); $sGhostTemplate = $oFormNested->getCode(); } elseif (isset($aInput['ghost_template']) && is_array($aInput['ghost_template']) && $aInput['ghost_template']) { // form is submitted and ghost template is array of BxDolFormNested objects bx_import('BxDolFormNested'); $sGhostTemplate = array(); foreach ($aInput['ghost_template'] as $iFileId => $oFormNested) { if (is_object($oFormNested) && $oFormNested instanceof BxDolFormNested) { $sGhostTemplate[$iFileId] = $oFormNested->getCode(); } } } elseif (isset($aInput['ghost_template']) && is_string($aInput['ghost_template'])) { // ghost template is just string template, without nested form $sGhostTemplate = $aInput['ghost_template']; } $aParams = array('button_title' => bx_js_string($oUploader->getUploaderButtonTitle(isset($aInput['upload_buttons_titles']) ? $aInput['upload_buttons_titles'] : false)), 'content_id' => isset($aInput['content_id']) ? $aInput['content_id'] : ''); if (isset($aInput['images_transcoder']) && $aInput['images_transcoder']) { $aParams['images_transcoder'] = bx_js_string($aInput['images_transcoder']); } $sUploaders .= $oUploader->getUploaderButton($sGhostTemplate, isset($aInput['multiple']) ? $aInput['multiple'] : true, $aParams); } return $this->oTemplate->parseHtmlByName('form_field_uploader.html', array('uploaders_buttons' => $sUploaders, 'info' => $sInfo, 'error' => $sError, 'id_container_errors' => $oUploader ? $oUploader->getIdContainerErrors() : '', 'id_container_result' => $oUploader ? $oUploader->getIdContainerResult() : '', 'uploader_instance_name' => $oUploader ? $oUploader->getNameJsInstanceUploader() : '', 'is_init_ghosts' => isset($aInput['init_ghosts']) && !$aInput['init_ghosts'] ? 0 : 1)); }