Short description of method initElements

@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@throws Exception
@throws common_Exception
@return mixed
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);
        }
    }
549983
public static function init() {
		
		$found = false;
		$patternExtension = Config::getOption("patternExtension");
		self::loadRules();
		
		foreach (self::$rules as $rule) {
			if ($rule->test($patternExtension)) {
				self::$instance = $rule;
				$found = true;
				break;
			}
		}
		
		if (!$found) {
			Console::writeError("the supplied pattern extension didn't match a pattern loader rule. check your config...");
		}
		
	}
841130
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);
    }
1045629
protected function initItems()
    {
        if (is_null($this->_items)) {
            // Set the element classes
            $model = $this->getModel();
            $keys  = $model->getKeys();

            foreach ($model->getItemNames() as $item) {
                if (($item == $this->receptionCodeItem) || in_array($item, $this->editItems)) {
                    continue;
                }
                if (in_array($item, $this->exhibitItems)) {
                    $model->set($item, 'elementClass', 'Exhibitor');
                } elseif (in_array($item, $this->hiddenItems)) {
                    $model->set($item, 'elementClass', 'Hidden');
                } elseif (in_array($item, $keys)) {
                    $model->set($item, 'elementClass', 'Hidden');
                } else {
                    $model->set($item, 'elementClass', 'None');
                }
            }

            $this->_items = array_merge(
                    $this->hiddenItems,
                    $this->exhibitItems,
                    array($this->receptionCodeItem),
                    $this->editItems
                    );
        }
    }
952001
function initElement(\HTML_QuickForm2_Node $element) {
        \Debugbar::addMessage(($this->namespace ? $this->namespace . '::' : '') . 'models/' . $this->model->getEntity() . '.' . $element->getName());
        $config = \Config::get(($this->namespace ? $this->namespace . '::' : '') . 'models/' . $this->model->getEntity() . '.' . $element->getName());
        if (is_array($config)) {
            foreach ($config as $k => $v) {
                $method = \Str::camel('set_' . $k);
                if (is_callable([$element, $method])) {
                    call_user_func([$element, $method], $v);
                }
            }
        }
        return $element;
    }
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();
        
    }
930020
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', array('message' => '')));
        }
        $fileElt->addValidators(array(
            \tao_helpers_form_FormFactory::getValidator('FileSize', array('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 = array();
        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'), array(
            $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);
        }

    }
276565
@Override
    protected void init() throws Exception {
        BootstrapContextImpl bootstrapContext = bootstrapContextRef.getServiceWithException();

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(this, tc, "loading", mcfImplClassName);
        if (mcfImplClassName == null) // TODO: get the real config element name of the nested properties
            throw new IllegalArgumentException(Utils.getMessage("J2CA8504.incorrect.props.list", "properties", configElementName, id));
        mcf = (ManagedConnectionFactory) bootstrapContext.loadClass(mcfImplClassName).newInstance();
        bootstrapContext.configure(mcf, jndiName, properties, null, null, null);

        if (connectionManagerRef == null)
            conMgrSvc = ConnectionManagerService.createDefaultService(jndiName);
        else
            conMgrSvc = (ConnectionManagerService) priv.locateService(componentContext, CONNECTION_MANAGER);
        conMgrSvc.addObserver(this);
        isInitialized.set(true);

        conMgrSvc.addRaClassLoader(bootstrapContext.getRaClassLoader());
    }
977912
public function load() {

        if (!$this->hasRequestParameter('uri')) {
            throw new common_exception_MissingParameter('uri', __METHOD__);
        }
        if (!$this->hasRequestParameter('stylesheetUri')) {
            throw new common_exception_MissingParameter('stylesheetUri', __METHOD__);
        }
        if (!$this->hasRequestParameter('lang')) {
            throw new common_exception_MissingParameter('lang', __METHOD__);
        }
        
        $item = new \core_kernel_classes_Resource($this->getRequestParameter('uri'));
        $lang = $this->getRequestParameter('lang');
        $styleSheet = $this->getRequestParameter('stylesheetUri');
        if (!\tao_helpers_File::securityCheck($styleSheet, true)) {
            throw new \common_exception_Error('invalid stylesheet path "'.$styleSheet.'"');
        }



        $cssArray = CssHelper::loadCssFile($item, $lang, $styleSheet);
        echo json_encode($cssArray);
    }
571428
protected function initElements()
    {
        parent::initElements();
        
        $elementId = tao_helpers_Uri::encode(taoItems_models_classes_ItemsService::PROPERTY_ITEM_MODEL);
        $ele = $this->form->getElement($elementId);
        $ele->feed();
        $modelUri = $ele->getEvaluatedValue();
        
        if (empty($modelUri)) {
            
            // remove deprecated models
            $statusProperty = new core_kernel_classes_Property(ItemModelStatus::CLASS_URI);
            $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() != ItemModelStatus::INSTANCE_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, true);
            
            // 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, true);
        }
    }
333289
@Override
  public final synchronized void init() throws Exception {
    FactoryBldServices<ResultSet> factoryBldServices =
      new FactoryBldServices<ResultSet>();
    factoryBldServices.setFactoryAppBeans(this);
    setFactoryBldServices(factoryBldServices);
    FactoryReplicatorXmlHttps<ResultSet> factoryReplicatorXmlHttps =
      new FactoryReplicatorXmlHttps<ResultSet>();
    factoryReplicatorXmlHttps.setFactoryAppBeans(this);
    setFactoryReplicatorXmlHttps(factoryReplicatorXmlHttps);
    FactoryDatabaseWriterXml<ResultSet> factoryDatabaseWriterXml =
      new FactoryDatabaseWriterXml<ResultSet>();
    factoryDatabaseWriterXml.setFactoryAppBeans(this);
    setFactoryDatabaseWriterXml(factoryDatabaseWriterXml);
  }
907313
protected function initData()
    {
        if (is_null($this->data) && is_null($this->baseModel)) {
            throw new \ErrorException("Error initialize multiple model input. Base model or data not set");
        }

        $attrPart = explode(']', $this->attribute);
        $this->_realAttribute = $this->attribute; //end($attrPart);

        if (is_null($this->data) && $this->model instanceof Model) {
            $this->data = [];
            foreach ((array)$this->model->{$this->_realAttribute} as $index => $value) {
                $this->data[$index] = [];

                $class = $this->baseModel;
                /** @var ActiveRecord|Model $model */
                $model = new $class($value);

                if (method_exists($model, 'setIsNewRecord')) {
                    $pkName = $model->getPrimaryKey(true);
                    $model->setIsNewRecord(count($pkName) == 0);
                }

                foreach ($model->attributes as $_name => $_value) {
                    $this->data[$index][$_name] = $_value;
                }
            }
        }
    }
383600
protected function initialize()
    {
        if ($this->isInitialized) {
            return;
        }
        if (!$this->dbAdapter instanceof Adapter) {
            throw new \Exception('No db adapter present');
        }
        if (!$this->hydrator instanceof HydratorInterface) {
            $this->hydrator = new ClassMethods;
        }
        if (!is_object($this->entityPrototype)) {
            throw new \Exception('No entity prototype set');
        }

        $this->isInitialized = true;
    }
1323414
public function initElements()
    {

    	$itemService = taoItems_models_classes_ItemsService::singleton();

		$fileName = '';
    	$options = array();
    	$disabledOptions = array();
    	if(isset($this->data['instance'])){
    		$item = $this->data['instance'];
    		if($item instanceof core_kernel_classes_Resource){
    			if($itemService->hasItemModel($item, array(ItemModel::MODEL_URI))){
    				$fileName = strtolower(tao_helpers_Display::textCleaner($item->getLabel()));
					try{
						$this->isInstanceValid($item);
					}catch(\common_exception_UserReadableException $e){
						$disabledOptions[$item->getUri()] = $e->getUserMessage();
					}
    				$options[$item->getUri()] = $item->getLabel();
    			}
    		}
    	}
    	else {
    		if(isset($this->data['class'])){
	    		$class = $this->data['class'];
	    	}
	    	else{
	    		$class = $itemService->getRootClass();
	    	}
    		if($class instanceof core_kernel_classes_Class){
                    $fileName =  strtolower(tao_helpers_Display::textCleaner($class->getLabel(), '*'));
                    foreach($class->getInstances(true) as $instance){
                        if($itemService->hasItemModel($instance, array(ItemModel::MODEL_URI))){
							try{
								$this->isInstanceValid($instance);
							}catch(\common_exception_UserReadableException $e){
								$disabledOptions[$instance->getUri()] = $e->getUserMessage();
							}
							$options[$instance->getUri()] = $instance->getLabel();
                        }
                    }
    		}
    	}

		$nameElt = tao_helpers_form_FormFactory::getElement('filename', 'Textbox');
		$nameElt->setDescription(__('File name'));
		$nameElt->setValue($fileName);
		$nameElt->setUnit(".zip");
		$nameElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
    	$this->form->addElement($nameElt);

    	$instanceElt = tao_helpers_form_FormFactory::getElement('instances', 'Checkbox');
    	$instanceElt->setDescription(__('Items'));

		if(count($options) > 1){
			$instanceElt->setAttribute('checkAll', true);
		}

		$instanceElt->setOptions(tao_helpers_Uri::encodeArray($options, tao_helpers_Uri::ENCODE_ARRAY_KEYS));
		$instanceElt->setReadOnly(tao_helpers_Uri::encodeArray($disabledOptions, tao_helpers_Uri::ENCODE_ARRAY_KEYS));
    	foreach(array_keys($options) as $value){
			if(!isset($disabledOptions[$value])){
				$instanceElt->setValue($value);
			}
		}
		$this->form->addElement($instanceElt);


    	$this->form->createGroup('options', '<h3>'.$this->getFormGroupName().'</h3>', array('filename', 'instances'));
    }
1134103
protected function Init()
    {
        $this->repeater = ContentRepeater::Schema()->ByContent($this->content);
        $this->current = $this->tree->FirstChildOf($this->item);
        $this->isEmpty = !$this->current;
        return parent::Init();
    }
257197
public function init()
    {
        //Get element slug
        $sElementSlug = $this->property('slug');
        if (empty($sElementSlug)) {
            return;
        }

        //Get element by slug
        $this->obElement = $this->getElementObject($sElementSlug);
        if (empty($this->obElement)) {
            return;
        }

        //Get element item
        $this->obElementItem = $this->makeItem($this->obElement->id, $this->obElement);
        if ($this->bNeedSmartURLCheck && $this->property('smart_url_check') && !$this->smartUrlCheck()) {
            $this->obElement = null;
            $this->obElementItem = null;
        }
    }
701974
public function initElements()
    {
        //create file upload form box
		$fileElt = tao_helpers_form_FormFactory::getElement('source', 'AsyncFile');
		$fileElt->setDescription(__("Add a CSV file"));
  	  	if(isset($_POST['import_sent_csv'])){
			$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/plain',
                        'text/csv',
                        'text/comma-separated-values',
                        'text/anytext',
                        'application/csv',
                        'application/txt',
                        'application/csv-tab-delimited-table',
                        'application/excel',
                        'application/vnd.ms-excel',
                        'application/vnd.msexcel',
                    ),
                    'extension' => array('csv', 'txt')
                )),
            tao_helpers_form_FormFactory::getValidator('FileSize',
                array('max' => SystemHelper::getFileUploadLimit()))
        ));
		
		$this->form->addElement($fileElt);
		$this->form->createGroup('file', __('Import Metadata from CSV file'), array('source'));
		
		$csvSentElt = tao_helpers_form_FormFactory::getElement('import_sent_csv', 'Hidden');
		$csvSentElt->setValue(1);
		$this->form->addElement($csvSentElt);
		
		// options
		$optDelimiter = tao_helpers_form_FormFactory::getElement(tao_helpers_data_CsvFile::FIELD_DELIMITER, 'Textbox');
		$optDelimiter->setDescription(__("Field delimiter"));
		$optDelimiter->setValue(';');
		$optDelimiter->addAttribute("size", 6);
		$optDelimiter->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
		$this->form->addElement($optDelimiter);
		
		$optEncloser = tao_helpers_form_FormFactory::getElement(tao_helpers_data_CsvFile::FIELD_ENCLOSER, 'Textbox');
		$optEncloser->setDescription(__("Field encloser"));
		$optEncloser->setValue('"');
		$optEncloser->addAttribute("size", 6);
		$optEncloser->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
		$this->form->addElement($optEncloser);
		
		/*
		$optMulti = tao_helpers_form_FormFactory::getElement(tao_helpers_data_CsvFile::MULTI_VALUES_DELIMITER, 'Textbox');
		$optMulti->setDescription(__("Multiple values delimiter"));
		$optMulti->setValue('|');
		$optMulti->addAttribute("size", 6);
		$optMulti->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
		$this->form->addElement($optMulti);
		*/

		if (isset($this->options[static::IS_OPTION_FIRST_COLUMN_ENABLE])){
		    if ($this->options[static::IS_OPTION_FIRST_COLUMN_ENABLE] === true){
                $optFirstColumn = $this->addFirstColumnElement();
            }
        }else{
		    //backwards compatible
            $optFirstColumn = $this->addFirstColumnElement();
        }

        $opts = [$optDelimiter, $optEncloser];

        if (isset($optFirstColumn)){
		    $opts[] = $optFirstColumn;
        }

		$this->form->createGroup('options', __('CSV Options'),$opts);
    }