* @package taoMediaManager */ class FileImportForm extends \tao_helpers_form_FormContainer { private $instanceUri; public function __construct($instanceUri) { $this->instanceUri = $instanceUri; parent::__construct(); } protected function initForm() { $this->form = new \tao_helpers_form_xhtml_Form('export'); $submitElt = \tao_helpers_form_FormFactory::getElement('import', 'Free'); $submitElt->setValue(' ' . __('Import') . ''); $this->form->setActions([$submitElt], 'bottom'); $this->form->setActions([], 'top'); } /** * Used to create the form elements and bind them to the form instance * * @access protected * @return mixed */ protected function initElements() { //create file upload form box $fileElt = \tao_helpers_form_FormFactory::getElement('source', 'AsyncFile'); $fileElt->setDescription(__("Add a media file")); if (isset($_POST['import_sent_file'])) { $fileElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); } else { $fileElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty', ['message' => ''])); } $fileElt->addValidators([ \tao_helpers_form_FormFactory::getValidator('FileSize', ['max' => SystemHelper::getFileUploadLimit()]) ]); $this->form->addElement($fileElt); $langService = \tao_models_classes_LanguageService::singleton(); $dataUsage = new \core_kernel_classes_Resource(TaoOntology::PROPERTY_STANCE_LANGUAGE_USAGE_DATA); $dataLang = \common_session_SessionManager::getSession()->getDataLanguage(); $dataLang = 'http://www.tao.lu/Ontologies/TAO.rdf#Lang' . $dataLang; if (!is_null($this->instanceUri)) { $instance = new \core_kernel_classes_Resource($this->instanceUri); $lang = $instance->getOnePropertyValue(new \core_kernel_classes_Property(MediaService::PROPERTY_LANGUAGE)); if ($lang instanceof \core_kernel_classes_Resource) { $dataLang = $lang->getUri(); } } $langOptions = []; foreach ($langService->getAvailableLanguagesByUsage($dataUsage) as $lang) { $langOptions[\tao_helpers_Uri::encode($lang->getUri())] = $lang->getLabel(); } $langElt = \tao_helpers_form_FormFactory::getElement('lang', 'Combobox'); $langElt->setValue(\tao_helpers_Uri::encode($dataLang)); $langElt->setOptions($langOptions); $this->form->addElement($langElt); $this->form->createGroup('options', __('Media Options'), [ $langElt ]); $fileSentElt = \tao_helpers_form_FormFactory::getElement('import_sent_file', 'Hidden'); $fileSentElt->setValue(1); $this->form->addElement($fileSentElt); if (!is_null($this->instanceUri)) { $instanceElt = \tao_helpers_form_FormFactory::getElement('instanceUri', 'Hidden'); $instanceElt->setValue($this->instanceUri); $this->form->addElement($instanceElt); } } }