* @package taoItems */ class taoQtiTest_models_forms_ImportForm extends tao_helpers_form_FormContainer { // --- ASSOCIATIONS --- // --- ATTRIBUTES --- // --- OPERATIONS --- public function __construct(core_kernel_classes_Resource $test) { parent::__construct(['uri' => $test->getUri()]); } /** * (non-PHPdoc) * @see tao_helpers_form_FormContainer::initForm() */ public function initForm() { $this->form = new tao_helpers_form_xhtml_Form('export'); $this->form->setDecorators([ 'element' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div']), 'group' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-group']), 'error' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-error ui-state-error ui-corner-all']), 'actions-bottom' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-toolbar']), 'actions-top' => new tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-toolbar']) ]); $submitElt = tao_helpers_form_FormFactory::getElement('import', 'Free'); $submitElt->setValue(' ' . __('Import') . ''); $this->form->setActions([$submitElt], 'bottom'); $this->form->setActions([], 'top'); } /** * (non-PHPdoc) * @see tao_helpers_form_FormContainer::initElements() */ public function initElements() { /* $descElt = tao_helpers_form_FormFactory::getElement('qtitest_desc', 'Label'); $descElt->setValue(__('A qti testpackage')); $this->form->addElement($descElt); */ //create file upload form box $fileElt = tao_helpers_form_FormFactory::getElement('source', 'AsyncFile'); $fileElt->setDescription(__("Add the source file")); if (isset($_POST['import_sent_xhtml'])) { $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('FileMimeType', ['mimetype' => ['application/zip', 'application/x-zip', 'application/x-zip-compressed', 'application/octet-stream'], 'extension' => ['zip']]), tao_helpers_form_FormFactory::getValidator('FileSize', ['max' => SystemHelper::getFileUploadLimit()]) ]); $this->form->addElement($fileElt); $this->form->createGroup('file', __('Upload a QTI 2.1 Test Package File'), ['source']); $element = tao_helpers_form_FormFactory::getElement('uri', 'Hidden'); //$element->setValue(); $this->getForm()->addElement($element); $xhtmlSentElt = tao_helpers_form_FormFactory::getElement('import_sent_qtitest', 'Hidden'); $xhtmlSentElt->setValue(1); $this->form->addElement($xhtmlSentElt); } }