/** * (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', array('message' => ''))); } $fileElt->addValidators(array(tao_helpers_form_FormFactory::getValidator('FileMimeType', array('mimetype' => array('application/zip', 'application/x-zip', 'application/x-zip-compressed', 'application/octet-stream'), 'extension' => array('zip'))), tao_helpers_form_FormFactory::getValidator('FileSize', array('max' => tao_helpers_Environment::getFileUploadLimit())))); $this->form->addElement($fileElt); $this->form->createGroup('file', __('Upload a QTI 2.1 Test Package File'), array('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); }
/** * Short description of method initElements * * @access protected * @author Joel Bout, <*****@*****.**> * @return mixed */ protected function initElements() { $langService = tao_models_classes_LanguageService::singleton(); // Retrieve languages available for a GUI usage. $guiUsage = new core_kernel_classes_Resource(INSTANCE_LANGUAGE_USAGE_GUI); $guiOptions = array(); foreach ($langService->getAvailableLanguagesByUsage($guiUsage) as $lang) { $guiOptions[tao_helpers_Uri::encode($lang->getUri())] = $lang->getLabel(); } // Retrieve languages available for a Data usage. $dataUsage = new core_kernel_classes_Resource(INSTANCE_LANGUAGE_USAGE_DATA); $dataOptions = array(); foreach ($langService->getAvailableLanguagesByUsage($dataUsage) as $lang) { $dataOptions[tao_helpers_Uri::encode($lang->getUri())] = $lang->getLabel(); } $uiLangElement = tao_helpers_form_FormFactory::getElement('ui_lang', 'Combobox'); $uiLangElement->setDescription(__('Interface language')); $uiLangElement->setOptions($guiOptions); $this->form->addElement($uiLangElement); $dataLangElement = tao_helpers_form_FormFactory::getElement('data_lang', 'Combobox'); $dataLangElement->setDescription(__('Data language')); $dataLangElement->setOptions($dataOptions); $this->form->addElement($dataLangElement); $tzElement = tao_helpers_form_FormFactory::getElement('timezone', 'Combobox'); $tzElement->setDescription(__('Time zone')); $options = array(); foreach (DateTimeZone::listIdentifiers() as $id) { $options[$id] = $id; } $tzElement->setOptions($options); $this->form->addElement($tzElement); }
public function initElements() { $class = $this->data['class']; if (!$class instanceof \core_kernel_classes_Class) { throw new \common_Exception('missing class in simple delivery creation form'); } $classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue($class->getUri()); $this->form->addElement($classUriElt); //create the element to select the import format $formatElt = \tao_helpers_form_FormFactory::getElement('test', 'Combobox'); $formatElt->setDescription(__('Select the test you want to publish to the test-takers')); $testClass = new \core_kernel_classes_Class(TAO_TEST_CLASS); $options = array(); $testService = \taoTests_models_classes_TestsService::singleton(); foreach ($testClass->getInstances(true) as $test) { try { $testItems = $testService->getTestItems($test); //Filter tests which has no items if (!empty($testItems)) { $options[$test->getUri()] = $test->getLabel(); } } catch (\Exception $e) { \common_Logger::w('Unable to load items for test ' . $test->getUri()); } } if (empty($options)) { throw new NoTestsException(); } $formatElt->setOptions($options); $formatElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($formatElt); }
/** * (non-PHPdoc) * @see tao_helpers_form_FormContainer::initElements() */ public function initElements() { $fileName = ''; $instances = array(); if (isset($this->data['instance'])) { $instance = $this->data['instance']; if ($instance instanceof core_kernel_classes_Resource) { $instances[$instance->getUri()] = $instance->getLabel(); } } elseif (isset($this->data['class'])) { $class = $this->data['class']; if ($class instanceof core_kernel_classes_Class) { foreach ($class->getInstances() as $instance) { $instances[$instance->getUri()] = $instance->getLabel(); } } } else { throw new common_Exception('No class nor instance specified for export'); } $instances = tao_helpers_Uri::encodeArray($instances, tao_helpers_Uri::ENCODE_ARRAY_KEYS); $descElt = tao_helpers_form_FormFactory::getElement('desc', 'Label'); $descElt->setValue(__('Enables you to export a published delivery')); $this->form->addElement($descElt); $instanceElt = tao_helpers_form_FormFactory::getElement('exportInstance', 'Radiobox'); $instanceElt->setDescription(__('Items')); $instanceElt->setAttribute('checkAll', true); $instanceElt->setOptions($instances); $instanceElt->setValue(current(array_keys($instances))); $this->form->addElement($instanceElt); $this->form->createGroup('options', __('Export Options'), array('desc', 'filename', 'exportInstance')); }
protected function initForm() { parent::initForm(); $saveELt = tao_helpers_form_FormFactory::getElement('Save', 'Free'); $saveELt->setValue('<button class="form-submitter small li-inner waves-effect waves-light btn btn_small" type="button"><span class="icon-save"></span>' . __('Save') . '</button>'); $this->form->setActions(array(), 'top'); $this->form->setActions(array($saveELt), 'bottom'); }
/** * Initialiaze recovery form elements * * @access public * @author Aleh Hutnikau <*****@*****.**> */ public function initElements() { $mailElement = tao_helpers_form_FormFactory::getElement('userMail', 'Textbox'); $mailElement->setDescription(__('Your mail') . '*'); $mailElement->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $mailElement->addValidator(tao_helpers_form_FormFactory::getValidator('Email')); $mailElement->setAttributes(array('autofocus' => 'autofocus')); $this->form->addElement($mailElement); }
/** * Initialize create delivery form elements * * @access public * @author Aleh Hutnikau <*****@*****.**> */ public function initElements() { $labelElt = \tao_helpers_form_FormFactory::getElement('label', 'Textbox'); $labelElt->setDescription(__('Label')); $this->form->addElement($labelElt); $startElt = \tao_helpers_form_FormFactory::getElement('start', 'Hidden'); $this->form->addElement($startElt); $endElt = \tao_helpers_form_FormFactory::getElement('end', 'Hidden'); $this->form->addElement($endElt); parent::initElements(); }
/** * Init filename field * * @throws \common_Exception */ public function initElements() { $date = new \DateTime(); $filename = 'metadata-' . $date->format('ymd'); $nameElt = \tao_helpers_form_FormFactory::getElement('filename', 'Textbox'); $nameElt->setDescription(__('File name')); $nameElt->setValue($filename); $nameElt->setUnit(".csv"); $nameElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($nameElt); $this->form->createGroup('options', __('Export metadata item'), array('xml_desc', 'filename', 'exportInstance')); }
/** * Short description of method initElements * * @access public * @author Bertrand Chevrier, <*****@*****.**> * @return mixed */ public function initElements() { $labelElt = tao_helpers_form_FormFactory::getElement('label', 'Textbox'); $labelElt->setDescription(__('Name')); $labelElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($labelElt); $sizeElt = tao_helpers_form_FormFactory::getElement('size', 'Textbox'); $sizeElt->setDescription(__('Number of elements')); $sizeElt->setAttribute('size', '4'); $sizeElt->setValue(1); $sizeElt->addValidators(array(tao_helpers_form_FormFactory::getValidator('NotEmpty'), tao_helpers_form_FormFactory::getValidator('Integer', array('min' => 1)))); $this->form->addElement($sizeElt); }
/** * Initialize the form elements * * @access protected * @author Bertrand Chevrier, <*****@*****.**> * @return mixed */ protected function initElements() { parent::initElements(); $elements = $this->form->getElements(); $this->form->setElements(array()); $currentLangElt = tao_helpers_form_FormFactory::getElement('current_lang', 'Textbox'); $currentLangElt->setDescription(__('Current language')); $currentLangElt->setAttributes(array('readonly' => 'true')); $currentLangElt->setValue(\common_session_SessionManager::getSession()->getDataLanguage()); //API lang /data lang $this->form->addElement($currentLangElt); $dataLangElement = tao_helpers_form_FormFactory::getElement('translate_lang', 'Combobox'); $dataLangElement->setDescription(__('Translate to')); $dataLangElement->setOptions(tao_helpers_I18n::getAvailableLangsByUsage(new core_kernel_classes_Resource(INSTANCE_LANGUAGE_USAGE_DATA))); $dataLangElement->setEmptyOption(__('Select a language')); $dataLangElement->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($dataLangElement); $this->form->createGroup('translation_info', __('Translation parameters'), array('current_lang', 'translate_lang')); $dataGroup = array(); foreach ($elements as $element) { if ($element instanceof tao_helpers_form_elements_Hidden || $element->getName() == 'uri' || $element->getName() == 'classUri') { $this->form->addElement($element); } else { $propertyUri = tao_helpers_Uri::decode($element->getName()); $property = new core_kernel_classes_Property($propertyUri); //translate only language dependent properties or Labels //supported widget are: Textbox, TextArea, HtmlArea //@todo support other widgets if ($property->isLgDependent() && ($element instanceof tao_helpers_form_elements_Textbox || $element instanceof tao_helpers_form_elements_TextArea || $element instanceof tao_helpers_form_elements_HtmlArea) || $propertyUri == RDFS_LABEL) { $translatedElt = clone $element; $viewElt = tao_helpers_form_FormFactory::getElement('view_' . $element->getName(), 'Label'); $viewElt->setDescription($element->getDescription()); $viewElt->setValue($element->getValue()); $viewElt->setAttribute('no-format', true); if ($element instanceof tao_helpers_form_elements_HtmlArea) { $viewElt->setAttribute('htmlentities', false); } $this->form->addElement($viewElt); $dataGroup[] = $viewElt->getName(); $translatedElt->setDescription(' '); $translatedElt->setValue(''); if ($propertyUri == RDFS_LABEL) { $translatedElt->setForcedValid(); } $this->form->addElement($translatedElt); $dataGroup[] = $translatedElt->getName(); } } } $this->form->createGroup('translation_form', __('Translate'), $dataGroup); }
/** * Initialiaze password reset form elements * * @access public * @author Aleh Hutnikau <*****@*****.**> * @return mixed */ public function initElements() { $tokenElement = tao_helpers_form_FormFactory::getElement('token', 'Hidden'); $this->form->addElement($tokenElement); $pass1Element = tao_helpers_form_FormFactory::getElement('newpassword', 'Hiddenbox'); $pass1Element->setDescription(__('New password')); $pass1Element->addValidators(PasswordConstraintsService::singleton()->getValidators()); $pass1Element->setBreakOnFirstError(false); $this->form->addElement($pass1Element); $pass2Element = tao_helpers_form_FormFactory::getElement('newpassword2', 'Hiddenbox'); $pass2Element->setDescription(__('Repeat new password')); $pass2Element->addValidators(array(tao_helpers_form_FormFactory::getValidator('Password', array('password2_ref' => $pass1Element)))); $this->form->addElement($pass2Element); }
/** * Short description of method initElements * * @access public * @author Joel Bout, <*****@*****.**> * @return mixed */ public function initElements() { $pass1Element = tao_helpers_form_FormFactory::getElement('oldpassword', 'Hiddenbox'); $pass1Element->setDescription(__('Old Password')); $pass1Element->addValidator(tao_helpers_form_FormFactory::getValidator('Callback', array('message' => __('Passwords are not matching'), 'object' => tao_models_classes_UserService::singleton(), 'method' => 'isPasswordValid', 'param' => tao_models_classes_UserService::singleton()->getCurrentUser()))); $this->form->addElement($pass1Element); $pass2Element = tao_helpers_form_FormFactory::getElement('newpassword', 'Hiddenbox'); $pass2Element->setDescription(__('New password')); $pass2Element->addValidators(array(tao_helpers_form_FormFactory::getValidator('Length', array('min' => 3)))); $this->form->addElement($pass2Element); $pass3Element = tao_helpers_form_FormFactory::getElement('newpassword2', 'Hiddenbox'); $pass3Element->setDescription(__('Repeat new password')); $pass3Element->addValidators(array(tao_helpers_form_FormFactory::getValidator('Password', array('password2_ref' => $pass2Element)))); $this->form->addElement($pass3Element); }
/** * Short description of method initElements * * @access public * @author Joel Bout, <*****@*****.**> * @return mixed */ public function initElements() { $loginElt = tao_helpers_form_FormFactory::getElement('login', 'Textbox'); $loginElt->setDescription(__('Login')); $loginElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($loginElt); $passElt = tao_helpers_form_FormFactory::getElement('password', 'Hiddenbox'); $passElt->setDescription(__('Password')); $passElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($passElt); //add 2 hidden inputs to post requested process and activity executions: $processElt = tao_helpers_form_FormFactory::getElement('processUri', 'Hidden'); $this->form->addElement($processElt); $activityElt = tao_helpers_form_FormFactory::getElement('activityUri', 'Hidden'); $this->form->addElement($activityElt); }
/** * Short description of method initElements * * @access protected * @author Joel Bout, <*****@*****.**> * @return mixed */ protected function initElements() { $userElement = \tao_helpers_form_FormFactory::getElement('user', 'Hidden'); $userElement->setValue(\common_session_SessionManager::getSession()->getUserUri()); $this->form->addElement($userElement); $roleOptions = array(); foreach (\common_session_SessionManager::getSession()->getUserRoles() as $role) { $roleResource = new \core_kernel_classes_Resource($role); $roleOptions[$role] = $roleResource->getLabel(); } $roleElement = \tao_helpers_form_FormFactory::getElement('rolefilter', 'Checkbox'); $roleElement->setDescription(__('Keep roles')); $roleElement->setOptions($roleOptions); $roleElement->setValues(array_keys($roleOptions)); $this->form->addElement($roleElement); }
/** * Used to create the form elements and bind them to the form instance * * @access protected * @return mixed */ protected function initElements() { //create date picker elements $fromDateElt = \tao_helpers_form_FormFactory::getElement('from', 'calendar'); $fromDateElt->setDescription(__('Start date of the export')); $toDateElt = \tao_helpers_form_FormFactory::getElement('to', 'calendar'); $toDateElt->setDescription(__('End date of the export')); $toDateElt->setValue(time()); $this->form->addElement($fromDateElt); $this->form->addElement($toDateElt); if (!is_null($this->instanceUri)) { $instanceElt = \tao_helpers_form_FormFactory::getElement('uri', 'Hidden'); $instanceElt->setValue($this->instanceUri); $this->form->addElement($instanceElt); } }
protected function initForm() { parent::initForm(); $bottom = $this->form->getActions('bottom'); $top = $this->form->getActions('top'); $edit = \tao_helpers_form_FormFactory::getElement('edit', 'Free'); $value = ''; if ($edit) { $value .= '<button type="button" id="edit-media" data-classuri="' . $this->getClazz()->getUri() . '" data-uri="' . $this->getInstance()->getUri() . '" class="edit-instance btn-success small"><span class="icon-upload"></span> ' . __('Upload new media') . '</button>'; } $edit->setValue($value); $top[] = $edit; $bottom[] = $edit; $this->form->setActions($bottom, 'bottom'); $this->form->setActions($top, 'top'); }
/** * Short description of method initElements * * @access public * @author Bertrand Chevrier, <*****@*****.**> * @return mixed */ public function initElements() { if (isset($this->data['redirect']) && !empty($this->data['redirect'])) { $hiddenElt = tao_helpers_form_FormFactory::getElement('redirect', 'Hidden'); $hiddenElt->setValue($this->data['redirect']); $this->form->addElement($hiddenElt); } $loginElt = tao_helpers_form_FormFactory::getElement('login', 'Textbox'); $loginElt->setDescription(Layout::getLoginLabel()); $loginElt->setAttributes(array('autofocus' => 'autofocus')); $loginElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($loginElt); $passElt = tao_helpers_form_FormFactory::getElement('password', 'Hiddenbox'); $passElt->setDescription(Layout::getPasswordLabel()); $passElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($passElt); }
protected function initElements() { parent::initElements(); /** @var \tao_helpers_form_elements_xhtml_Combobox $originalTestElement */ $originalTestElement = $this->getForm()->getElement(tao_helpers_Uri::encode(BookletClassService::PROPERTY_TEST)); $options = $originalTestElement->getOptions(); $formatElt = tao_helpers_form_FormFactory::getElement('test', 'Readonly'); $formatElt->setDescription(__('Selected test')); $formatElt->setValue(isset($options[$originalTestElement->getRawValue()]) ? $options[$originalTestElement->getRawValue()] : __('Test has been removed')); $downloadBtn = \tao_helpers_form_FormFactory::getElement('Download', 'Button'); $downloadBtn->setValue(__('Download') . ' PDF'); $downloadBtn->setIcon('icon-download'); $downloadBtn->addClass('btn-download btn-success small'); $this->getForm()->removeElement(tao_helpers_Uri::encode(BookletClassService::PROPERTY_TEST)); $this->getForm()->setActions(array_merge($this->form->getActions(), array($downloadBtn)), 'bottom'); $this->getForm()->addElement($formatElt); }
/** * overriden * * @access public * @author Joel Bout, <*****@*****.**> * @return mixed */ public function initElements() { //create file upload form box $fileElt = tao_helpers_form_FormFactory::getElement('source', 'AsyncFile'); $fileElt->setDescription(__("Add an RDF/XML file")); if (isset($_POST['import_sent_rdf'])) { $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); } else { $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty', array('message' => ''))); } $fileElt->addValidators(array(tao_helpers_form_FormFactory::getValidator('FileMimeType', array('mimetype' => array('text/xml', 'application/rdf+xml', 'application/xml'), 'extension' => array('rdf', 'rdfs'))), tao_helpers_form_FormFactory::getValidator('FileSize', array('max' => tao_helpers_Environment::getFileUploadLimit())))); $this->form->addElement($fileElt); $this->form->createGroup('file', __('Import Metadata from RDF file'), array('rdf_desc', 'source')); $rdfSentElt = tao_helpers_form_FormFactory::getElement('import_sent_rdf', 'Hidden'); $rdfSentElt->setValue(1); $this->form->addElement($rdfSentElt); }
/** * Initialize the form elements * * @access protected * @author Bertrand Chevrier, <*****@*****.**> * @return mixed */ protected function initElements() { $themingConfig = isset($this->options['themingConfig']) ? $this->options['themingConfig'] : new PlatformThemingConfig(); //Logo file input $fileElt = \tao_helpers_form_FormFactory::getElement('logo', 'AsyncFile'); $fileElt->setDescription(__('Logo')); $this->form->addElement($fileElt); //Link input $textElt = \tao_helpers_form_FormFactory::getElement("link", 'Textbox'); $textElt->setDescription(__('Link on logo click')); $textElt->setValue($themingConfig->offsetGet('link')); $this->form->addElement($textElt); //Message input $textElt = \tao_helpers_form_FormFactory::getElement("message", 'Textbox'); $textElt->setDescription(__('Alternative text of the logo')); $textElt->setValue($themingConfig->offsetGet('message')); $this->form->addElement($textElt); }
public function initElements() { if (isset($this->data['resource'])) { $resource = $this->data['resource']; } else { throw new \common_Exception('No class nor instance specified for export'); } $fileName = strtolower(\tao_helpers_Display::textCleaner($resource->getLabel(), '*')); $hiddenElt = \tao_helpers_form_FormFactory::getElement('resource', 'Hidden'); $hiddenElt->setValue($resource->getUri()); $this->form->addElement($hiddenElt); $nameElt = \tao_helpers_form_FormFactory::getElement('filename', 'Textbox'); $nameElt->setDescription(__('File name')); $nameElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); $nameElt->setValue($fileName); $nameElt->setUnit(".zip"); $this->form->addElement($nameElt); $this->form->createGroup('options', __('Export Media as Zip file'), array('filename', 'ziptpl')); }
public function initElements() { parent::initElements(); $formatElt = tao_helpers_form_FormFactory::getElement('anonymousClass', 'Hidden'); $formatElt->setValue(tao_helpers_Uri::encode(BookletClassService::PROPERTY_ANONYMOUS)); $this->getForm()->addElement($formatElt); $testElement = $this->getForm()->getElement(tao_helpers_Uri::encode(BookletClassService::PROPERTY_TEST)); if (!count($testElement->getOptions())) { throw new \taoSimpleDelivery_actions_form_NoTestsException(); } $anonymousElm = $this->getForm()->getElement(tao_helpers_Uri::encode(BookletClassService::PROPERTY_ANONYMOUS)); $anonymousElm->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $testElement->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $createElt = \tao_helpers_form_FormFactory::getElement('create', 'Button'); $createElt->setValue(__('Generate')); $createElt->setIcon("icon-play"); $createElt->addClass("form-submitter btn-success small"); $this->form->setActions(array($createElt), 'bottom'); }
/** * Short description of method initElements * * @access public * @author Bertrand Chevrier, <*****@*****.**> * @return mixed */ public function initElements() { $property = $this->getPropertyInstance(); isset($this->options['index']) ? $index = $this->options['index'] : ($index = 1); $propertyProperties = array_merge(tao_helpers_form_GenerisFormFactory::getDefaultProperties(), array(new core_kernel_classes_Property(PROPERTY_IS_LG_DEPENDENT), new core_kernel_classes_Property(PROPERTY_WIDGET), new core_kernel_classes_Property(RDFS_RANGE))); $elementNames = array(); foreach ($propertyProperties as $propertyProperty) { //map properties widgets to form elements $element = tao_helpers_form_GenerisFormFactory::elementMap($propertyProperty); if (!is_null($element)) { //take property values to populate the form $values = $property->getPropertyValuesCollection($propertyProperty); foreach ($values->getIterator() as $value) { if (!is_null($value)) { if ($value instanceof core_kernel_classes_Resource) { $element->setValue($value->getUri()); } if ($value instanceof core_kernel_classes_Literal) { $element->setValue((string) $value); } } } $element->setName("property_{$index}_{$element->getName()}"); $element->addClass('property'); if ($propertyProperty->getUri() == RDFS_LABEL) { $element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); } $this->form->addElement($element); $elementNames[] = $element->getName(); } } $encodedUri = tao_helpers_Uri::encode($property->getUri()); $modeElt = tao_helpers_form_FormFactory::getElement("{$index}_uri", 'Hidden'); $modeElt->setValue($encodedUri); $modeElt->addClass('property'); $this->form->addElement($modeElt); $elementNames[] = $modeElt->getName(); if (count($elementNames) > 0) { $groupTitle = $this->getGroupTitle($property); $this->form->createGroup("property_{$encodedUri}", $groupTitle, $elementNames); } }
/** * overriden * * @access public * @author Joel Bout, <*****@*****.**> * @return mixed */ public function initElements() { $descElt = tao_helpers_form_FormFactory::getElement('rdf_desc', 'Label'); $descElt->setValue(__('Please upload a published delivery assembly .')); $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_rdf'])) { $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); } else { $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty', array('message' => ''))); } $fileElt->addValidators(array(tao_helpers_form_FormFactory::getValidator('FileMimeType', array('mimetype' => array('application/zip', 'application/x-zip', 'application/x-zip-compressed', 'application/octet-stream'), 'extension' => array('zip'))), tao_helpers_form_FormFactory::getValidator('FileSize', array('max' => tao_helpers_Environment::getFileUploadLimit())))); $this->form->addElement($fileElt); $this->form->createGroup('file', __('Upload an assembly'), array('rdf_desc', 'source')); $rdfSentElt = tao_helpers_form_FormFactory::getElement('import_sent_rdf', 'Hidden'); $rdfSentElt->setValue(1); $this->form->addElement($rdfSentElt); }
/** * (non-PHPdoc) * @see tao_helpers_form_FormContainer::initElements() */ public function initElements() { //create file upload form box $fileElt = tao_helpers_form_FormFactory::getElement('source', 'AsyncFile'); $fileElt->setDescription(__("Add a zip file containing QTI/APIP tests and items")); if (isset($_POST['import_sent_qti'])) { $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); } else { $fileElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty', array('message' => ''))); } $fileElt->addValidators(array(tao_helpers_form_FormFactory::getValidator('FileMimeType', array('mimetype' => array('application/zip', 'application/x-zip', 'application/x-zip-compressed', 'application/octet-stream'), 'extension' => array('zip'))), tao_helpers_form_FormFactory::getValidator('FileSize', array('max' => tao_helpers_Environment::getFileUploadLimit())))); $this->form->addElement($fileElt); /* $disableValidationElt = tao_helpers_form_FormFactory::getElement("disable_validation", 'Checkbox'); $disableValidationElt->setDescription(__("Disable validation")); $disableValidationElt->setOptions(array("on" => "")); $this->form->addElement($disableValidationElt); */ $this->form->createGroup('file', __('Import a QTI/APIP Content Package'), array('source')); $qtiSentElt = tao_helpers_form_FormFactory::getElement('import_sent_qti', 'Hidden'); $qtiSentElt->setValue(1); $this->form->addElement($qtiSentElt); }
/** * (non-PHPdoc) * @see tao_actions_form_Instance::initElements() */ protected function initElements() { parent::initElements(); $elementId = tao_helpers_Uri::encode(TAO_ITEM_MODEL_PROPERTY); $ele = $this->form->getElement($elementId); $ele->feed(); $modelUri = $ele->getEvaluatedValue(); if (empty($modelUri)) { // remove deprecated models $statusProperty = new core_kernel_classes_Property(TAO_ITEM_MODEL_STATUS_PROPERTY); $options = array(); foreach ($ele->getOptions() as $optUri => $optLabel) { $model = new core_kernel_classes_Resource(tao_helpers_Uri::decode($optUri)); $status = $model->getOnePropertyValue($statusProperty); if (!is_null($status) && $status->getUri() != TAO_ITEM_MODEL_STATUS_DEPRECATED) { $options[$optUri] = $optLabel; } } $ele->setOptions($options); if (count($options) === 1) { reset($options); $ele->setValue(key($options)); } } else { // replace radio with hidden element $this->form->removeElement($elementId); $itemModelElt = tao_helpers_form_FormFactory::getElement($elementId, 'Hidden'); $itemModelElt->setValue($modelUri); $this->form->addElement($itemModelElt); // display model label $model = new core_kernel_classes_Resource($modelUri); $itemModelLabelElt = tao_helpers_form_FormFactory::getElement('itemModelLabel', 'Label'); $itemModelLabelElt->setDescription(__('Item Model')); $itemModelLabelElt->setValue($model->getLabel()); $this->form->addElement($itemModelLabelElt); } }
/** * overriden * * @access public * @author Joel Bout, <*****@*****.**> * @return mixed */ public function initElements() { $fileName = ''; $instances = array(); if (isset($this->data['instance'])) { $resource = $this->data['instance']; } elseif (isset($this->data['class'])) { $resource = $this->data['class']; } else { throw new common_Exception('No class nor instance specified for export'); } $fileName = strtolower(tao_helpers_Display::textCleaner($resource->getLabel(), '*')); $hiddenElt = tao_helpers_form_FormFactory::getElement('resource', 'Hidden'); $hiddenElt->setValue($resource->getUri()); $this->form->addElement($hiddenElt); $nameElt = tao_helpers_form_FormFactory::getElement('filename', 'Textbox'); $nameElt->setDescription(__('File name')); $nameElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $nameElt->setValue($fileName); $nameElt->setUnit(".rdf"); $this->form->addElement($nameElt); $instances = tao_helpers_Uri::encodeArray($instances, tao_helpers_Uri::ENCODE_ARRAY_KEYS); $this->form->createGroup('options', __('Export Metadata as RDF/XML file'), array('rdf_desc', 'filename', 'rdftpl')); }
public function initElements() { $class = $this->data['class']; if (!$class instanceof core_kernel_classes_Class) { throw new common_Exception('missing class in simple delivery creation form'); } $classUriElt = tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue($class->getUri()); $this->form->addElement($classUriElt); //create the element to select the import format $formatElt = tao_helpers_form_FormFactory::getElement('test', 'Combobox'); $formatElt->setDescription(__('Select the test you want to publish to the test-takers')); $testClass = new core_kernel_classes_Class(TAO_TEST_CLASS); $options = array(); foreach ($testClass->getInstances(true) as $test) { $options[$test->getUri()] = $test->getLabel(); } if (empty($options)) { throw new taoSimpleDelivery_actions_form_NoTestsException(); } $formatElt->setOptions($options); $formatElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($formatElt); }
/** * Short description of method initElements * * @access public * @author Joel Bout, <*****@*****.**> * @return mixed */ public function initElements() { if (count($this->exportHandlers) > 1) { //create the element to select the import format $formatElt = tao_helpers_form_FormFactory::getElement('exportHandler', 'Radiobox'); $formatElt->setDescription(__('Choose export format')); //mandatory field $formatElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $formatElt->setOptions($this->getFormats()); if (isset($_POST['exportHandler'])) { if (array_key_exists($_POST['exportHandler'], $this->getFormats())) { $formatElt->setValue($_POST['exportHandler']); } } $this->form->addElement($formatElt); $this->form->createGroup('formats', __('Supported export formats'), array('exportHandler')); } if (isset($this->data['instance'])) { $item = $this->data['instance']; if ($item instanceof core_kernel_classes_Resource) { //add an hidden elt for the instance Uri $uriElt = tao_helpers_form_FormFactory::getElement('uri', 'Hidden'); $uriElt->setValue($item->getUri()); $this->form->addElement($uriElt); } } if (isset($this->data['class'])) { $class = $this->data['class']; if ($class instanceof core_kernel_classes_Class) { //add an hidden elt for the class uri $classUriElt = tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue($class->getUri()); $this->form->addElement($classUriElt); } } $idElt = tao_helpers_form_FormFactory::getElement('id', 'Hidden'); $this->form->addElement($idElt); foreach ($this->subForm->getElements() as $element) { $this->form->addElement($element); } foreach ($this->subForm->getGroups() as $group) { $this->form->createGroup($group['title'], $group['title'], $group['elements'], $group['options']); } }
/** * Initialize the form elements * * @access protected * @author Bertrand Chevrier, <*****@*****.**> * @return mixed */ protected function initElements() { $clazz = $this->getClazz(); $instance = $this->getInstance(); $guiOrderProperty = new core_kernel_classes_Property(TAO_GUIORDER_PROP); //get the list of properties to set in the form $propertyCandidates = tao_helpers_form_GenerisFormFactory::getDefaultProperties(); $classProperties = tao_helpers_form_GenerisFormFactory::getClassProperties($clazz, $this->getTopClazz()); $propertyCandidates = array_merge($propertyCandidates, $classProperties); $additionalProperties = isset($this->options['additionalProperties']) && is_array($this->options['additionalProperties']) ? $this->options['additionalProperties'] : array(); if (!empty($additionalProperties)) { $propertyCandidates = array_merge($propertyCandidates, $additionalProperties); } $excludedProperties = isset($this->options['excludedProperties']) && is_array($this->options['excludedProperties']) ? $this->options['excludedProperties'] : array(); $editedProperties = array(); foreach ($propertyCandidates as $property) { if (!isset($editedProperties[$property->getUri()]) && !in_array($property->getUri(), $excludedProperties)) { $editedProperties[$property->getUri()] = $property; } } $finalElements = array(); foreach ($editedProperties as $property) { $property->feed(); $widget = $property->getWidget(); if ($widget == null || $widget instanceof core_kernel_classes_Literal) { continue; } //map properties widgets to form elments $element = tao_helpers_form_GenerisFormFactory::elementMap($property); if (!is_null($element)) { //take instance values to populate the form if (!is_null($instance)) { $values = $instance->getPropertyValuesCollection($property); foreach ($values->getIterator() as $value) { if (!is_null($value)) { if ($value instanceof core_kernel_classes_Resource) { if ($element instanceof tao_helpers_form_elements_Readonly) { $element->setValue($value->getLabel()); } else { $element->setValue($value->getUri()); } } if ($value instanceof core_kernel_classes_Literal) { $element->setValue((string) $value); } } } } // don't show empty labels if ($element instanceof tao_helpers_form_elements_Label && strlen($element->getRawValue()) == 0) { continue; } //set file element validator: if ($element instanceof tao_helpers_form_elements_AsyncFile) { } if ($property->getUri() == RDFS_LABEL) { // Label will not be a TAO Property. However, it should // be always first. array_splice($finalElements, 0, 0, array(array($element, 1))); } else { if (count($guiOrderPropertyValues = $property->getPropertyValues($guiOrderProperty))) { // get position of this property if it has one. $position = intval($guiOrderPropertyValues[0]); // insert the element at the right place. $i = 0; while ($i < count($finalElements) && ($position >= $finalElements[$i][1] && $finalElements[$i][1] !== null)) { $i++; } array_splice($finalElements, $i, 0, array(array($element, $position))); } else { // Unordered properties will go at the end of the form. $finalElements[] = array($element, null); } } } } // Add elements related to class properties to the form. foreach ($finalElements as $element) { $this->form->addElement($element[0]); } //add an hidden elt for the class uri $classUriElt = tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue(tao_helpers_Uri::encode($clazz->getUri())); $this->form->addElement($classUriElt); if (!is_null($instance)) { //add an hidden elt for the instance Uri $instanceUriElt = tao_helpers_form_FormFactory::getElement('uri', 'Hidden'); $instanceUriElt->setValue(tao_helpers_Uri::encode($instance->getUri())); $this->form->addElement($instanceUriElt); $hiddenId = tao_helpers_form_FormFactory::getElement('id', 'Hidden'); $hiddenId->setValue($instance->getUri()); $this->form->addElement($hiddenId); } }