Short description of method initElements

@access public
@author Joel Bout, <joel@taotesting.com>
@return mixed
17657
public function initElements()
    {
        
        parent::initElements();
        
        $encodedIncludesRolePropertyUri = tao_helpers_Uri::encode(GenerisRdf::PROPERTY_ROLE_INCLUDESROLE);
        $encodedInstanceUri = tao_helpers_Uri::encode($this->getInstance()->getUri());
        $rolesElement = $this->form->getElement($encodedIncludesRolePropertyUri);
        if (!is_null($rolesElement)) {
	        $rolesOptions = $rolesElement->getOptions();
	        
	        // remove the role itself in the list of includable roles
	        // to avoid cyclic inclusions (even if the system supports it).
	        if (array_key_exists($encodedInstanceUri, $rolesOptions)){
	        	unset($rolesOptions[$encodedInstanceUri]);
	        }
	        
	        $rolesElement->setOptions($rolesOptions);
        }
        
    }
387328
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(__('Delivery'));
		$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', 'exportInstance'));
    }
255907
protected function initElements()
    {
		$idElt = \tao_helpers_form_FormFactory::getElement('name', 'Textbox');
		$idElt->setDescription(__('Identifier'));
		$idElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty'));
		$idElt->addValidator(\tao_helpers_form_FormFactory::getValidator('AlphaNum'));
		$this->form->addElement($idElt);

		$verElt = \tao_helpers_form_FormFactory::getElement('version', 'Textbox');
		$verElt->setDescription(__('Version'));
		$verElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty'));
		$this->form->addElement($verElt);
		
		$authorElt = \tao_helpers_form_FormFactory::getElement('author', 'Textbox');
		$authorElt->setDescription(__('Author'));
		$authValid = \tao_helpers_form_FormFactory::getValidator('NotEmpty');
		$authorElt->addValidator($authValid);
		$authorElt->setValue('Open Assessment Technologies SA');
		$this->form->addElement($authorElt);
		
		$nsElt = \tao_helpers_form_FormFactory::getElement('authorNs', 'Textbox');
		$nsElt->setDescription('Author namespace');
		$nsElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty'));
		$nsElt->addValidator(\tao_helpers_form_FormFactory::getValidator('AlphaNum'));
		$nsElt->setValue('oat');
		$this->form->addElement($nsElt);
		
		$licenseElt = \tao_helpers_form_FormFactory::getElement('license', 'Textbox');
		$licenseElt->setDescription(__('License'));
		$licenseElt->setValue('GPL-2.0');
		$this->form->addElement($licenseElt);
		
		$idElt = \tao_helpers_form_FormFactory::getElement('label', 'Textbox');
		$idElt->setDescription(__('Label'));
		$idElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty'));
		$this->form->addElement($idElt);

		$descElt = \tao_helpers_form_FormFactory::getElement('description', 'Textarea');
		$descElt->setDescription(__('Description'));
		$this->form->addElement($descElt);
		
		$extIds = array();
		foreach (\common_ext_ExtensionsManager::singleton()->getInstalledExtensions() as $ext) {
		    $extIds[$ext->getId()] = $ext->getId();
		}
		$depElt = \tao_helpers_form_FormFactory::getElement('dependencies', 'Checkbox');
		$depElt->setDescription(__('Depends on'));
		$depElt->setOptions($extIds);
		$depElt->setValue('tao');
		$this->form->addElement($depElt);
		
		$chainingElt = \tao_helpers_form_FormFactory::getElement('samples', 'Checkbox');
		$chainingElt->setDescription(__('Samples'));
		$chainingElt->setOptions(array(
		    'structure' =>  __('sample structure')
			,'theme' => __('custom theme')
		    ,'model' => __('sample model (todo)')
		    ,'rdf' => __('sample rdf install (todo)')
		    ,'install' => __('sample post install script (todo)')
		    ,'uninstall' => __('sample uninstall script (todo)')
		    ,'entry' => __('sample entry point (todo)')
		    ,'itemmodel' => __('sample item model (todo)')
		    ,'testmodel' => __('sample test model todo)')
		    ,'deliverymodel' => __('sample delivery model (todo)')
		));
		$chainingElt->setValue('structure');
		$this->form->addElement($chainingElt);
    }
90357
public function initElements()
    {
        
        $guiOrderProperty = new core_kernel_classes_Property(TaoOntology::PROPERTY_GUI_ORDER);
    	
    	//get the list of properties to set in the form
    	$defaultProperties 	= tao_helpers_form_GenerisFormFactory::getDefaultProperties();
		$editedProperties = $defaultProperties;
		$excludedProperties = (isset($this->options['excludedProperties']) && is_array($this->options['excludedProperties']))?$this->options['excludedProperties']:array();
		$additionalProperties = (isset($this->options['additionalProperties']) && is_array($this->options['additionalProperties']))?$this->options['additionalProperties']:array();
		$finalElements = array();
    	
		$classProperties = array();
		foreach ($this->classes as $class) {
			$classProperties = array_merge(tao_helpers_form_GenerisFormFactory::getClassProperties($class));
		}
		if(!empty($additionalProperties)){
			$classProperties = array_merge($classProperties, $additionalProperties);
		}
		
		foreach($classProperties as $property){
			if(!isset($editedProperties[$property->getUri()]) && !in_array($property->getUri(), $excludedProperties)){
				$editedProperties[$property->getUri()] = $property;
			}
		}
			
		foreach($editedProperties as $property){

			$property->feed();
			$widget = $property->getWidget();
			if($widget == null || $widget instanceof core_kernel_classes_Literal) {
				continue;
			}
			else if ($widget instanceof core_kernel_classes_Resource &&	$widget->getUri() == WidgetRdf::PROPERTY_WIDGET_TREEVIEW){
			    continue;
			}
			
			//map properties widgets to form elments 
			$element = tao_helpers_form_GenerisFormFactory::elementMap($property);
			
			if(!is_null($element)){
				
				//set label validator
				if($property->getUri() == OntologyRdfs::RDFS_LABEL){
					$element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
				}

				// 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() == OntologyRdfs::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]);
		}
		
		// @todo currently tao cannot handle multiple classes
		/*
		$classUriElt = tao_helpers_form_FormFactory::getElement('classes', 'Hidden');
		$uris = array();
		foreach ($this->classes as $class) {
			$uris[] = $class->getUri();
		}
		$classUriElt->setValue($uris);
		*/
		
		//add an hidden elt for the class uri
		$classUriElt = tao_helpers_form_FormFactory::getElement('classUri', 'Hidden');
		$classUriElt->setValue(tao_helpers_Uri::encode($class->getUri()));
		$this->form->addElement($classUriElt);
		
		$this->form->addElement($classUriElt);

		$this->addSignature();
        
    }
840093
public function initElement()
    {
        if(is_null($this->settings)) {
            $this->settings = new InputSettings();
        }

        return $this->build($this->settings);
    }
1138695
protected function initElements()
    {

        
    	$chainingElt = tao_helpers_form_FormFactory::getElement('chaining', 'Radiobox');
		$chainingElt->setDescription(__('Filtering mode'));
		$chainingElt->setOptions(array('or' =>  __('Exclusive (OR)'), 'and' => __('Inclusive (AND)')));
		$chainingElt->setValue('or');
		$this->form->addElement($chainingElt);
		
		$recursiveElt = tao_helpers_form_FormFactory::getElement('recursive', 'Checkbox');
		$recursiveElt->setDescription(__('Scope'));
		$recursiveElt->setOptions(array('0' =>  __('Search sub-classes')));
		$this->form->addElement($recursiveElt);

		$searchClassUriElt = tao_helpers_form_FormFactory::getElement("clazzUri", "Hidden");
		$searchClassUriElt->setValue(tao_helpers_Uri::encode($this->clazz->getUri()));
		$this->form->addElement($searchClassUriElt);
		
		$langElt = tao_helpers_form_FormFactory::getElement('lang', 'Combobox');
		$langElt->setDescription(__('Language'));
		
		$languages = array_merge(array('-- any --'), tao_helpers_I18n::getAvailableLangsByUsage(new core_kernel_classes_Resource(tao_models_classes_LanguageService::INSTANCE_LANGUAGE_USAGE_DATA)));
		$langElt->setOptions($languages);
		$langElt->setValue(0);
		$this->form->addElement($langElt);
		
		$this->form->createGroup('params', __('<del>Options</del>'), array('chaining', 'recursive', 'lang'));
		

		$filters = array();

		$defaultProperties 	= tao_helpers_form_GenerisFormFactory::getDefaultProperties();
		$classProperties	= $this->getClassProperties();

		
		$properties = array_merge($defaultProperties, $classProperties);
		
		(isset($this->options['recursive'])) ? $recursive = $this->options['recursive'] : $recursive = false;
		if($recursive){
			foreach($this->clazz->getSubClasses(true) as $subClass){
				$properties = array_merge($subClass->getProperties(false), $properties);
			}
		}
		
		foreach($properties as $property){
	
			$element = tao_helpers_form_GenerisFormFactory::elementMap($property);
			if( ! is_null($element) && 
				! $element instanceof tao_helpers_form_elements_Authoring && 
				! $element instanceof tao_helpers_form_elements_Hiddenbox &&
				! $element instanceof tao_helpers_form_elements_Hidden ){
				
				if($element instanceof tao_helpers_form_elements_MultipleElement){
					$newElement = tao_helpers_form_FormFactory::getElement($element->getName(), 'Checkbox');
					$newElement->setDescription($element->getDescription());
					$newElement->setOptions($element->getOptions());
					$element = $newElement;
				}
				if($element instanceof tao_helpers_form_elements_Htmlarea){
					$newElement = tao_helpers_form_FormFactory::getElement($element->getName(), 'Textarea');
					$newElement->setDescription($element->getDescription());
					$element = $newElement;
				}
				
				$this->form->addElement($element);
				$filters[] = $element->getName();
			}
		}
		$this->form->createGroup('filters', __('<del>Filters</del>'), $filters);
    	
        
    }
346513
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( PasswordConstraintsService::singleton()->getValidators() );
			    $pass2Element->setBreakOnFirstError( false );
				$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);
        
    }
1073577
public function initialize()
    {
        if ($this->initialized) {
            return;
        }

        $this->initialized = true;
        $this->repository = app(RepositoryInterface::class);
        $this->repository->setClass($this->class);

        $model = $this->makeModel();
        parent::setModel($model);
        $this->getButtons()->setModel($model);

        parent::initialize();

        if (! $this->hasHtmlAttribute('enctype')) {

            // Recursive iterate subset of form elements
            // and if subset contains an upload element then add to for
            $this->recursiveIterateElements(function ($element) {
                if ($element instanceof Upload) {
                    $this->withFiles();

                    return true;
                }
            });
        }

        $this->getButtons()->setModelConfiguration(
            $this->getModelConfiguration()
        );
    }
175553
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);
        }

    }
1318438
protected function init()
    {
        if (null === $this->items) {
            list($constraints, $sorting, $joins) = $this->translate($this->filter, $this->sorting);

            if (empty($constraints)) {
                $constraints = '';
            } else {
                $constraints = ' WHERE ' . implode(' AND ', $constraints);
            }

            if ($this->prefetch) {
                $this->initEntities($constraints, $this->makeJoins($joins), $this->makeOrderBy($sorting, $joins));
            } else {
                $this->initKeys($constraints, $this->makeJoins($joins), $this->makeOrderBy($sorting, $joins));
            }

            $this->rewind();
        }
    }
168408
public function initElements()
    {

        if(!isset($this->options['class_properties'])){
    		throw new Exception('No class properties found');
    	}
    	if(!isset($this->options['csv_column'])){
    		throw new Exception('No csv columns found');
    	}

        $columnsOptions = array();
        $columnsOptionsLabels = array();
    	$columnsOptionsLiteral =  array();
    	$columnsOptionsLiteral['csv_select'] = ' --- ' . __('Select') . ' --- ';
    	$columnsOptionsLiteral['csv_null']  = ' --- ' . __("Don't set");
        
        $columnsOptionsRanged = array();
        $columnsOptionsRanged['csv_select'] = ' --- ' . __('Select') . ' --- ';
        $columnsOptionsRanged['csv_null'] = ' --- ' . __('Use default value');
    	
    	// We build the list of CSV columns that can be mapped to
    	// the target class properties. 
    	if (isset($this->options[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES])
    	    && $this->options[tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES]){
	    	foreach($this->options['csv_column'] as $i => $column){
	    		$columnsOptions[$i.tao_models_classes_import_CsvImporter::OPTION_POSTFIX] = __('Column') . ' ' . ($i + 1) . ' : ' . $column;
                $columnsOptionsLabels[$i.tao_models_classes_import_CsvImporter::OPTION_POSTFIX] = $this->prepareString($column);
	    	}
    	} else {
    		// We do not know column so we display more neutral information
    		// about columns to the end user.
    		for ($i = 0; $i < count($this->options['csv_column']); $i++){
				$columnsOptions[$i.tao_models_classes_import_CsvImporter::OPTION_POSTFIX] = __('Column') . ' ' . ($i + 1);
	    	}
    	}

    	foreach($this->options['class_properties'] as $propertyUri => $propertyLabel){

    		$propElt = tao_helpers_form_FormFactory::getElement($propertyUri, 'Combobox');
    		$propElt->setDescription($propertyLabel);

            // literal or ranged?
            $options = array_key_exists($propertyUri, $this->options['ranged_properties'])
                ? array_merge($columnsOptionsRanged, $columnsOptions)
                : array_merge($columnsOptionsLiteral, $columnsOptions);

			$value = 'csv_select';
			if (isset($_POST[$propertyUri]) && isset($options[$_POST[$propertyUri]])) {
				$value = $_POST[$propertyUri];
			}

            // We trying compare current label with option labels from file and set most suitable
            $label = $this->prepareString($propertyLabel);
            $value = key(preg_grep("/^$label$/", $columnsOptionsLabels)) ?: $value;

            $propElt->setOptions($options);
            $propElt->setValue($value);

			/** Add mandatory label */
			if (tao_helpers_Uri::decode($propertyUri)==OntologyRdfs::RDFS_LABEL) {
				$elementEqualsToCsvSelect = new tao_helpers_form_elements_xhtml_Hidden();
				$elementEqualsToCsvSelect->setValue('csv_select');
				$elementEqualsToCsvSelect->setDescription(' to null');
				$propElt->addValidator(tao_helpers_form_FormFactory::getValidator(
					'Equals', array(
						'reference' => $elementEqualsToCsvSelect,
						'invert' => true
					)
				));
			}

    		$this->form->addElement($propElt);
    	}
        if(count($this->options['class_properties']) > 0){
            $this->form->createGroup('property_mapping', __('Map the properties to the CSV columns'), array_keys($this->options['class_properties']));
        }
    	$ranged = array();
    	foreach($this->options['ranged_properties'] as $propertyUri => $propertyLabel){
    		$property = new core_kernel_classes_Property(tao_helpers_Uri::decode($propertyUri));
    		$propElt = tao_helpers_form_GenerisFormFactory::elementMap($property);
    		if(!is_null($propElt)){
    			$defName = tao_helpers_Uri::encode($property->getUri()) . self::DEFAULT_VALUES_SUFFIX;
    			$propElt->setName($defName);
				if ($this->form->getElement($propertyUri)->getRawValue()=='csv_null') {
					$propElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
				}
    			$this->form->addElement($propElt);
    			$ranged[$defName] = $propElt;
    		}
    	}

    	if(count($this->options['ranged_properties']) > 0){
    		$this->form->createGroup('ranged_property', __('Define the default values'), array_keys($ranged));
		}
    	
    	$importFileEle = tao_helpers_form_FormFactory::getElement('importFile', 'Hidden');
    	$this->form->addElement($importFileEle);
    	
    	$optDelimiter = tao_helpers_form_FormFactory::getElement(tao_helpers_data_CsvFile::FIELD_DELIMITER, 'Hidden');
		$this->form->addElement($optDelimiter);
		
		$optEncloser = tao_helpers_form_FormFactory::getElement(tao_helpers_data_CsvFile::FIELD_ENCLOSER, 'Hidden');
		$this->form->addElement($optEncloser);
		
		$optMulti = tao_helpers_form_FormFactory::getElement(tao_helpers_data_CsvFile::MULTI_VALUES_DELIMITER, 'Hidden');
		$this->form->addElement($optMulti);

		if (isset($this->options[tao_models_classes_import_CsvUploadForm::IS_OPTION_FIRST_COLUMN_ENABLE])){
		    if ($this->options[tao_models_classes_import_CsvUploadForm::IS_OPTION_FIRST_COLUMN_ENABLE] === true){
                $optFirstColumn = tao_helpers_form_FormFactory::getElement(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES, 'Hidden');
                $this->form->addElement($optFirstColumn);
            }
        }else{
            $optFirstColumn = tao_helpers_form_FormFactory::getElement(tao_helpers_data_CsvFile::FIRST_ROW_COLUMN_NAMES, 'Hidden');
            $this->form->addElement($optFirstColumn);
        }
    }
323844
public function init()
    {
        foreach ($this->dynamic as $key => $data) {
            // Locate field.
            $path = explode('/', $key);
            $current = &$this->items;

            foreach ($path as $field) {
                if (\is_object($current)) {
                    // Handle objects.
                    if (!isset($current->{$field})) {
                        $current->{$field} = [];
                    }

                    $current = &$current->{$field};
                } else {
                    // Handle arrays and scalars.
                    if (!\is_array($current)) {
                        $current = [$field => []];
                    } elseif (!isset($current[$field])) {
                        $current[$field] = [];
                    }

                    $current = &$current[$field];
                }
            }

            // Set dynamic property.
            foreach ($data as $property => $call) {
                $action = 'dynamic' . ucfirst($call['action']);

                if (method_exists($this, $action)) {
                    $this->{$action}($current, $property, $call);
                }
            }
        }

        return $this;
    }
416795
protected function _init() {
		$hosts = [];
		foreach ((array) $this->_config['host'] as $host) {
			$host = HostString::parse($host) + [
				'host' => static::DEFAULT_HOST,
				'port' => static::DEFAULT_PORT
			];
			$hosts[] = "{$host['host']}:{$host['port']}";
		}
		if ($this->_config['login']) {
			$this->_config['dsn'] = sprintf(
				'mongodb://%s:%s@%s/%s',
				$this->_config['login'],
				$this->_config['password'],
				implode(',', $hosts),
				$this->_config['database']
			);
		} else {
			$this->_config['dsn'] = sprintf(
				'mongodb://%s',
				implode(',', $hosts)
			);
		}
		parent::_init();

		$this->_operators += [
			'like' => function($key, $value) {
				return new MongoRegex($value);
			},
			'$exists' => function($key, $value) {
				return ['$exists' => (boolean) $value];
			},
			'$type' => function($key, $value) {
				return ['$type' => (integer) $value];
			},
			'$mod' => function($key, $value) {
				$value = (array) $value;
				return ['$mod' => [current($value), next($value) ?: 0]];
			},
			'$size' => function($key, $value) {
				return ['$size' => (integer) $value];
			},
			'$elemMatch' => function($operator, $values, $options = []) {
				$options += [
					'castOpts' => [],
					'field' => ''
				];
				$options['castOpts'] += ['pathKey' => $options['field']];
				$values = (array) $values;

				if (empty($options['castOpts']['schema'])) {
					return ['$elemMatch' => $values];
				}
				foreach ($values as $key => &$value) {
					$value = $options['castOpts']['schema']->cast(
						null, $key, $value, $options['castOpts']
					);
				}
				return ['$elemMatch' => $values];
			}
		];
	}
562274
protected function initTypes()
    {
        $class = $this->getClassName(false);
        $types = $this->getModelTypes();
        $type = $this->_type;

        if (!$type || !is_array($type)) {
            if(!empty($types)){
                $this->_type = $types;
            }
        } elseif (!in_array($class, $type)) {
            $type[] = $class;
            $this->_type = $type;
        }

    }
152786
public function init() {
        parent::init();

        $defaults = [
            self::TYPE_INFO => ['{class}' => 'alert alert-info alert-dismissible', '{icon}' => '<i class="icon fa fa-info-circle"></i>', '{title}' => Yii::t('cza', 'Tips'), '{content}' => ''],
            self::TYPE_DANGER => ['{class}' => 'alert alert-danger alert-dismissible', '{icon}' => '<i class="icon fa fa-ban"></i>', '{title}' => Yii::t('cza', 'Alert'), '{content}' => ''],
            self::TYPE_WARNING => ['{class}' => 'alert alert-warning alert-dismissible', '{icon}' => '<i class="icon fa fa-warning"></i>', '{title}' => Yii::t('cza', 'Warning'), '{content}' => ''],
            self::TYPE_SUCCESS => ['{class}' => 'alert alert-success alert-dismissible', '{icon}' => '<i class="icon fa fa-info"></i>', '{title}' => Yii::t('cza', 'Alert'), '{content}' => ''],
        ];
        $this->blockTypes = array_replace_recursive($defaults, $this->blockTypes);
    }
952931
protected function initElements()
    {
        $clazz = $this->getClazz();
        $instance = $this->getInstance();
        $guiOrderProperty = new core_kernel_classes_Property(TaoOntology::PROPERTY_GUI_ORDER);

        //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 if ($element instanceof tao_helpers_form_elements_xhtml_ReadonlyLiteral){
                                        $element->setValue((string)$value);
                                    } 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() == OntologyRdfs::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, true);

        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, true);

            $hiddenId = tao_helpers_form_FormFactory::getElement('id', 'Hidden');
            $hiddenId->setValue($instance->getUri());
            $this->form->addElement($hiddenId, true);
        }
    }
841279
public function initElements()
	{
		//create the element to select the import format
		$formatElt = tao_helpers_form_FormFactory::getElement('importHandler', 'Radiobox');
		$formatElt->setDescription(__('Choose import format'));
		$formatElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); // should never happen anyway
		$importHandlerOptions= array();
		foreach ($this->importHandlers as $importHandler) {
			$importHandlerOptions[get_class($importHandler)] = $importHandler->getLabel();
		}
		$formatElt->setOptions($importHandlerOptions);
		

		$classUriElt = tao_helpers_form_FormFactory::getElement('classUri', 'Hidden');
//		$classUriElt->setValue($class->getUri());
		$this->form->addElement($classUriElt);

		$classUriElt = tao_helpers_form_FormFactory::getElement('id', 'Hidden');
		$this->form->addElement($classUriElt);
		
		$this->form->addElement($formatElt);

		if (!is_null($this->subForm)) {
//			load dynamically the method regarding the selected format
			$this->form->setElements(array_merge($this->form->getElements(), $this->subForm->getElements()));
			foreach ($this->subForm->getGroups() as $key => $group) {
				$this->form->createGroup($key,$group['title'],$group['elements'],$group['options']);
			}
		}
	}