Parse the form group and model properties.

@return array
509520
protected function parsedFormProperties()
    {
        if ($this->parsedFormProperties === null) {
            $this->finalizeStructure();

            $groupProperties     = $this->groupProperties();
            $availableProperties = $this->structProperties();

            $structProperties = [];
            if (!empty($groupProperties)) {
                foreach ($groupProperties as $propertyIdent => $propertyMetadata) {
                    if (is_string($propertyMetadata)) {
                        $propertyIdent    = $propertyMetadata;
                        $propertyMetadata = null;
                    }

                    if (!isset($availableProperties[$propertyIdent])) {
                        continue;
                    }

                    if (is_array($propertyMetadata)) {
                        $propertyMetadata = array_merge($propertyMetadata, $availableProperties[$propertyIdent]);
                    } else {
                        $propertyMetadata = $availableProperties[$propertyIdent];
                    }

                    $structProperties[$propertyIdent] = $propertyMetadata;
                }
            }

            if (empty($structProperties)) {
                $structProperties = $availableProperties;
            }

            $this->parsedFormProperties = $structProperties;
        }

        return $this->parsedFormProperties;
    }
882551
protected static function define_properties() {
        return array(
            'userid' => array(
                'type' => PARAM_INT
            ),
            'name' => array(
                'type' => PARAM_TEXT
            ),
            'description' => array(
                'type' => PARAM_CLEANHTML,
                'default' => '',
            ),
            'descriptionformat' => array(
                'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN),
                'type' => PARAM_INT,
                'default' => FORMAT_HTML,
            ),
            'url' => array(
                'type' => PARAM_URL,
                'default' => '',
                'message' => new lang_string('invalidurl', 'core_competency')
            )
        );
    }
1316066
public function getForm() {

		$form = new Form();
		
		// build a select control
		$getSelectControl = function ($property, $field, $values) use ($form) {
			
			$control = $form->addSelect($property)->setListByAssociativeArray($values, $values);
			
			if (static::isNullable($field) or static::isEmptiable($field)) {
				$control->prependEmpty();
			}
			
			return $control;
			
		};

		$properties = $this->getAllProperties();

		// these db column types will go into a textarea
		$textAreaTypes = ['tinytext', 'text', 'mediumtext', 'longtext'];

		foreach ($properties as $propName => $value) {

			$field = static::getMappedField($propName);

			// primary key
			if ($this->isKeyProperty($propName)) {

				$control = $form->addInput($propName)->setType('hidden');

			} else {
				
				$column = static::getColumnType($field);
				
				switch ($this->getPropertyType($propName)) {

					// checkbox
					case 'bool':
						$control = $form->addInput($propName)->setType('bool');
						break;
					
					// date or datetime
					case 'DateTime':
						$type = 'date' == $column->type ? 'date' : 'datetime'; 
						$control = $form->addInput($propName)->setType($type);
						break;

					// number with two decimals
					case 'float':
						$control = $form->addInput($propName)->setType('number')->setStep('0.01');
						break;

					// integer
					case 'int':
						$control = $form->addInput($propName)->setType('number');
						break;

					// multiple select
					case 'csv':
						$control = $getSelectControl($propName, $field, $column->length);
						$control->setMultiple();
						break;
					
					// select, textarea or text
					default:
						if ('enum' == $column->type) {
							$control = $getSelectControl($propName, $field, $column->length);
						} else if ('set' == $column->type) {
							$control = $getSelectControl($propName, $field, $column->length);
							$control->setMultiple();
						} else if (in_array($column->type, $textAreaTypes)) {
							$control = $form->addTextarea($propName);
						} else {
							$control = $form->addInput($propName);
							if (isset($column->length[0])) {
								$control->setMaxLength($column->length[0]);
							}
						}
						break;

				}

			}
			
			// check if is required
			if (!static::isNullable($field) and !static::isEmptiable($field)) {
				$control->setRequired();
			}

			// set the object value
			$control->setValue($value);

		}

		return $form;
		
	}
689043
protected function getClassProperties(){
        $testTakerProps = \tao_helpers_form_GenerisFormFactory::getClassProperties($this->clazz, $this->getTopClazz());
        $userProps = \tao_helpers_form_GenerisFormFactory::getClassProperties(new \core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_USER), $this->getTopClazz());
        return array_merge($testTakerProps,$userProps);
    }
93701
public function getForm() {
		$form = new Form();
		
		$useBlacklist = (count($this->propertyBlacklist) > 0) ? true : false;
		$useWhitelist = (count($this->propertyWhitelist) > 0) ? true : false;
		
		$properties = EntityReader::getProperties($this->entityNamespace);
		foreach ($properties as $property) {
			$name = $property->getName();
			if (($useWhitelist && !in_array($name, $this->propertyWhitelist)) || ($useBlacklist && in_array($name, $this->propertyBlacklist))) {
				continue;
			}
			
			switch ($property->getType()) {
				case Property::PROPERTY_TYPE_COLUMN:
					if (!($property->getAnnotation() instanceof \Doctrine\ORM\Mapping\Id)) {
						$this->addColumnElementToForm($form, $property);
					}
					break;
				case Property::PROPERTY_TYPE_REF_ONE:
					$this->addSingleSelecterElementToForm($form, $property);
					break;
				case Property::PROPERTY_TYPE_REF_MANY:
					$this->addMultiSelecterElementToForm($form, $property);
					break;
				default:
					continue 2;
			}
		}
		
		$submit = new Submit('save');
		$submit->setValue('save');
		$form->add($submit);
		
		return $form;
	}
695040
protected function propertiesFromAttributes(): array
    {
        // Get all managed properties
        $propertyNames = $this->entityMap->getProperties();

        $propertyAttributes = array_only($this->attributes, $propertyNames);
        $attributesArray = array_except($this->attributes, $propertyNames);

        $attributesArrayName = $this->entityMap->getAttributesArrayName();

        if ($attributesArrayName) {
            $propertyAttributes[$attributesArrayName] = $attributesArray;
        }

        return $propertyAttributes;
    }
1082861
public function properties()
    {
        $myFormContainer = new tao_actions_form_UserSettings($this->getUserSettings());
        $myForm = $myFormContainer->getForm();
        if ($myForm->isSubmited() && $myForm->isValid()) {
            $userLangService = $this->getServiceLocator()->get(UserLanguageServiceInterface::class);

            $currentUser = $this->getUserService()->getCurrentUser();
            $userSettings = [
                GenerisRdf::PROPERTY_USER_TIMEZONE => $myForm->getValue('timezone'),
            ];

            $uiLang = $this->getResource($myForm->getValue('ui_lang'));
            $userSettings[GenerisRdf::PROPERTY_USER_UILG] = $uiLang->getUri();
            if ($userLangService->isDataLanguageEnabled()) {
                $dataLang = $this->getResource($myForm->getValue('data_lang'));
                $userSettings[GenerisRdf::PROPERTY_USER_DEFLG] = $dataLang->getUri();
            }

            $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($currentUser);

            if($binder->bind($userSettings)){

                $this->getSession()->refresh();
                $uiLangCode		= tao_models_classes_LanguageService::singleton()->getCode($uiLang);
                $extension      = $this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('tao');
                tao_helpers_I18n::init($extension, $uiLangCode);

                $this->setData('message', __('Settings updated'));

                $this->setData('reload', true);
            }
        }
        $userLabel = $this->getUserService()->getCurrentUser()->getLabel();
        $this->setData('formTitle', __("My settings (%s)", $userLabel));
        $this->setData('myForm', $myForm->render());

        //$this->setView('form.tpl');
        $this->setView('form/settings_user.tpl');
    }
815247
public function getInputSpecification() : array
    {
        $spec = [
            'name'     => $this->getName(),
            'required' => $this->isRequired(),
        ];

        $filters = $this->getFilters();

        if ($this->node->hasAttribute('data-filters')) {
            foreach ($this->parseDataAttribute($this->node->getAttribute('data-filters')) as $name => $options) {
                $filters[] = [
                    'name'    => $name,
                    'options' => $options,
                ];
            }
        }

        if (! empty($filters)) {
            $spec['filters'] = $filters;
        }

        $validators = $this->getValidators();

        if ($this->node->hasAttribute('data-validators')) {
            foreach ($this->parseDataAttribute($this->node->getAttribute('data-validators')) as $name => $options) {
                $validators[] = [
                    'name'    => $name,
                    'options' => $options,
                ];
            }
        }

        if (! empty($validators)) {
            $spec['validators'] = $validators;
        }

        return $spec;
    }
1003148
public function getForm()
	{
		$form = new App_Form_New();

		$elements = [];

		foreach($this->_settings as $column => $setting)
		{
			if(!$this->recordColumnExists($column) )
			{
				continue;
			}

			if(isset($setting['show_in']) && (isset($setting['show_in']) && !in_array('form', $setting['show_in'])))
			{
				continue;
			}

			$settingColumn = array(
				'type' => 'text'
			);

			if(isset($setting['formOptions']))
			{
				$settingColumn['options'] = $setting['formOptions'];
			}
			elseif(!array_key_exists('options', $settingColumn))
			{
				$settingColumn['options'] = array();
			}

			$type = 'text';
			if(isset($setting['type']))
			{
				$type = $setting['type'];
			}
			if(isset($setting['label']))
			{
				$settingColumn['options']['label'] = $setting['label'];
			}
			elseif(isset($setting['title']))
			{
				$settingColumn['options']['label'] = $setting['title'];
			}

			if(isset($setting['options']['validators']))
			{
				$settingColumn['options']['validators'] = $setting['validators'];
			}
			if(isset($setting['filters']))
			{
				$settingColumn['options']['filters'] = $setting['filters'];
			}
			if(isset($setting['decorators']))
			{
				$settingColumn['options']['decorators'] = $setting['decorators'];
			}

			if(isset($setting['helper']) && isset($setting['helper']['name']))
			{
				/* TODO 20150401 : make helper definition compatible with FormElement one
				$settingColumn['options']['helper'] = $setting['helper']['name'];
				*/
			}

			switch($type)
			{
				case "boolean":
				case "bool":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "array":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "date":
					if(!isset($settingColumn['options']['validators']['date']))
					{
						$settingColumn['options']['validators']['date'] = array('Date',false,array('Y-m-d'));
					}
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "datetime":
					if(!isset($settingColumn['options']['validators']['date']))
					{
						$settingColumn['options']['validators']['date'] = array('Date',false,array('Y-m-d H:i:s'));
					}
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "time":
					if(!isset($settingColumn['options']['validators']['date']))
					{
						$settingColumn['options']['validators']['date'] = array('Date',false,array('H:i:s'));
					}
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "uint":
				case "int":
					@$settingColumn['options']['validators'][] = 'Int';
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "float":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "email":
					@$settingColumn['options']['validators'][] = 'EmailAddress';
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "host":
					@$settingColumn['options']['validators'][] = 'Hostname';
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "text":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "hidden":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->hiddenDecorators;
					}
					break;
				default:
					debug_assert(false !== array_search($type, self::$types), "Unknown Form Type `{$type}`");
					break;
			}

			if(isset($setting['formType']))
			{
				$settingColumn['type'] = $setting['formType'];
			}
			else
			{
				$settingColumn['type'] = $this->_getFormType($type);
			}
			if(isset($setting['unique']) && $setting['unique'] == true)
			{
				if(!isset($settingColumn['options']['validators']))
				{
					$settingColumn['options']['validators'] = array();
				}
				if(!isset($settingColumn['options']['validators']['unique']))
				{
					$settingColumn['options']['validators']['unique'] = array('Db_RecordNotExistOrIsUnique', false, array(array(
						'table' => $this->getTable(),
						'field' => $column,
						'primary_key' => $this->getPrimaryKey()
					)));
				}
			}
			if(isset($setting['required']) && $setting['required'] == true)
			{
				$settingColumn['options']['required'] = true;
			}

			if(isset($setting['multiOptions']))
			{
				$multiOptions = $setting['multiOptions'];
				if($settingColumn['type'] == 'select' || (isset($settingColumn['formType']) && $settingColumn['formType'] == 'select'))
				{
					$multiOptions = array('' => 'LABEL_SELECT') + $multiOptions;
				}
				$settingColumn['options']['multiOptions'] = $multiOptions;

				if(isset($setting['otherMultioption']) && $setting['formType'] == 'multiCheckbox')
				{
					$settingColumn['options']['otherMultioption'] = $setting['otherMultioption'];
				}
			}

			if(isset($setting['hidden']) && $setting['hidden'] == true)
			{
				$settingColumn['options']['decorators'] = $form->hiddenDecorators;
				$settingColumn['type'] = 'hidden';
			}

			$elements[$column] = $settingColumn;
		}

		$form->setOptions([
			'elements' => $elements
		]);
		$form->setDisableLoadDefaultDecorators(true);

		return $form;
	}
49089
private static function _parse_form_attributes($attributes, $default)
    {
        if (is_array($attributes)) {
            foreach ($default as $key => $val) {
                if (isset($attributes[$key])) {
                    $default[$key] = $attributes[$key];
                    unset($attributes[$key]);
                }
            }

            if (count($attributes) > 0) {
                $default = array_merge($default, $attributes);
            }
        }

        $att = '';

        foreach ($default as $key => $val) {
            if ($key == 'value') {
                $val = self::form_prep($val, $default['name']);
            }

            $att .= $key . '="' . $val . '" ';
        }

        return $att;
    }
390220
protected static function define_properties() {
        return array(
            'shortname' => array(
                'type' => PARAM_TEXT
            ),
            'idnumber' => array(
                'type' => PARAM_RAW
            ),
            'description' => array(
                'default' => '',
                'type' => PARAM_CLEANHTML
            ),
            'descriptionformat' => array(
                'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN),
                'type' => PARAM_INT,
                'default' => FORMAT_HTML
            ),
            'sortorder' => array(
                'default' => 0,
                'type' => PARAM_INT
            ),
            'parentid' => array(
                'default' => 0,
                'type' => PARAM_INT
            ),
            'path' => array(
                'default' => '/0/',
                'type' => PARAM_RAW
            ),
            'ruleoutcome' => array(
                'choices' => array(self::OUTCOME_NONE, self::OUTCOME_EVIDENCE, self::OUTCOME_COMPLETE, self::OUTCOME_RECOMMEND),
                'default' => self::OUTCOME_NONE,
                'type' => PARAM_INT
            ),
            'ruletype' => array(
                'type' => PARAM_RAW,
                'default' => null,
                'null' => NULL_ALLOWED
            ),
            'ruleconfig' => array(
                'default' => null,
                'type' => PARAM_RAW,
                'null' => NULL_ALLOWED
            ),
            'scaleid' => array(
                'default' => null,
                'type' => PARAM_INT,
                'null' => NULL_ALLOWED
            ),
            'scaleconfiguration' => array(
                'default' => null,
                'type' => PARAM_RAW,
                'null' => NULL_ALLOWED
            ),
            'competencyframeworkid' => array(
                'default' => 0,
                'type' => PARAM_INT
            ),
        );
    }
285513
protected function getGroups()
	{
		$groups = array();
		$label = 0;

		$select = new HtmlSelect;

		// Try to inject the text object into the field
		try
		{
			$select->setText($this->getText());
		}
		catch (\RuntimeException $exception)
		{
			// A Text object was not set, ignore the error and try to continue processing
		}

		/** @var \SimpleXMLElement $element */
		foreach ($this->element->children() as $element)
		{
			switch ($element->getName())
			{
				// The element is an <option />
				case 'option':
					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Create a new option object based on the <option /> element.
					$tmp = $select->option(
						($element['value']) ? (string) $element['value'] : trim((string) $element),
						$this->getText()->alt(trim((string) $element), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), 'value', 'text',
						((string) $element['disabled'] == 'true')
					);

					// Set some option attributes.
					$tmp->class = (string) $element['class'];

					// Set some JavaScript option attributes.
					$tmp->onclick = (string) $element['onclick'];

					// Add the option.
					$groups[$label][] = $tmp;
					break;

				// The element is a <group />
				case 'group':
					// Get the group label.
					if ($groupLabel = (string) $element['label'])
					{
						$label = $this->translateLabel ? $this->getText()->translate($groupLabel) : $groupLabel;
					}

					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Iterate through the children and build an array of options.
					/** @var \SimpleXMLElement $option */
					foreach ($element->children() as $option)
					{
						// Only add <option /> elements.
						if ($option->getName() != 'option')
						{
							continue;
						}

						// Create a new option object based on the <option /> element.
						$tmp = $select->option(
							($option['value']) ? (string) $option['value'] : $this->getText()->translate(trim((string) $option)),
							$this->getText()->translate(trim((string) $option)), 'value', 'text', ((string) $option['disabled'] == 'true')
						);

						// Set some option attributes.
						$tmp->class = (string) $option['class'];

						// Set some JavaScript option attributes.
						$tmp->onclick = (string) $option['onclick'];

						// Add the option.
						$groups[$label][] = $tmp;
					}

					if ($groupLabel)
					{
						$label = count($groups);
					}
					break;

				// Unknown element type.
				default:
					throw new \UnexpectedValueException(
						sprintf('Unsupported element %1$s in %2$s', $element->getName(), __CLASS__),
						500
					);
			}
		}

		reset($groups);

		return $groups;
	}
1063241
private function parse() {

		$lines = file($this -> viewmodel -> getFile());

		$this -> code = '';

		$classes = [

			'MatchEcho',
			'MatchForeach',
			'MatchEndForeach',
			'MatchFor',
			'MatchEndFor',
			'MatchIf',
			'MatchIsset',
			'MatchNotIsset',
			'MatchEmpty',
			'MatchNotEmpty',
			'MatchElseIf',
			'MatchElse',
			'MatchEndIf',
			'MatchEndIsset',
			'MatchEndNotIsset',
			'MatchEndEmpty',
			'MatchEndNotEmpty',
			'MatchForm',
			'MatchTranslation',
			'MatchEscape',
			'MatchRouter',
			'MatchHelper',
			'MatchPartial',
			'MatchFails',
			'MatchPasses',
			'MatchPHPTags'
		];

		foreach($lines as $linenumber => $line) {
			
			foreach($classes as $class) {
				
				$class = self :: NAMESPACE_MATCH . $class;
				$match = new $class($line);
				$line  = $match -> replace() -> getLine();
			}

			//User defined functions
			foreach(TemplateData :: getTemplateFunctions() as $action => $closure) {

				$class = self :: NAMESPACE_MATCH . 'MatchUserDefined';
				$match = new $class($line, $action);
				$line  = $match -> replace() -> getLine();
			}
			
			$this -> code .= trim($line) . "\n";
		}

		$this -> code = trim($this -> code);

		return $this -> code;
	}
527469
function parseForms()
	{
		preg_match_all('/<form.*>.+<\/form>/isU', $this->html_data, $forms);
		foreach ($forms[0] as $form) {
			$this->button_counter = 0;

			//form details
			preg_match('/<form.*?name=["\']?([\w\s-]*)["\']?[\s>]/is', $form, $form_name);
			if ($form_name) {
				$this->_return[$this->_counter]['form_data']['name'] = preg_replace('/["\'<>]/', '', $form_name[1]);
			}
			preg_match('/<form.*?action=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $form, $action);
			if ($action) {
				$this->_return[$this->_counter]['form_data']['action'] = preg_replace('/["\'<>]/', '', $action[1]);
			}
			preg_match('/<form.*?method=["\']?([\w\s]*)["\']?[\s>]/is', $form, $method);
			if ($method) {
				$this->_return[$this->_counter]['form_data']['method'] = preg_replace('/["\'<>]/', '', $method[1]);
			}
			preg_match('/<form.*?enctype=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $form, $enctype);
			if ($enctype) {
				$this->_return[$this->_counter]['form_data']['enctype'] = preg_replace('/["\'<>]/', '', $enctype[1]);
			}
			preg_match('/<form.*?id=["\']?([\w\s-]*)["\']?[\s>]/is', $form, $id);
			if ($id) {
				$this->_return[$this->_counter]['form_data']['id'] = preg_replace('/["\'<>]/', '', $id[1]);
			}

			// form elements: input type = hidden
			if (preg_match_all('/<input[^<>]+type=["\']hidden["\'][^<>]*>/isU', $form, $hiddens)) {
				foreach ($hiddens[0] as $hidden) {
					$this->_return[$this->_counter]['form_elements'][$this->_getName($hidden)] = array(
						'type'  =>  'hidden',
						'value'  =>  $this->_getValue($hidden)
					);
				}
			}

			// form elements: input type = text
			if (preg_match_all('/<input[^<>]+type=["\']text["\'][^<>]*>/isU', $form, $texts)) {
				foreach ($texts[0] as $text) {
					$this->_return[$this->_counter]['form_elements'][$this->_getName($text)] = array(
						'type' => 'text',
						'value' => $this->_getValue($text),
						'id' => $this->_getId($text),
						'class' => $this->_getClass($text)
					);
				}
			}

			/**
			 * HJW 18-7-2014 Magento 1.9.01. uses email as type for user credential
			 * form elements: input type = email
			 */
			if (preg_match_all('/<input[^<>]+type=["\']email["\'][^<>]*>/isU', $form, $texts)) {
				foreach ($texts[0] as $text) {
					$this->_return[$this->_counter]['form_elements'][$this->_getName($text)] = array(
						'type'  => 'email',
						'value'  =>  $this->_getValue($text),
						'id'  =>  $this->_getId($text),
						'class'  =>  $this->_getClass($text)
					);
				}
			}

            // form elements: input type = email
            if (preg_match_all('/<input[^<>]+type=["\']email["\'][^<>]*>/isU', $form, $texts)) {
                foreach ($texts[0] as $text) {
                    $this->_return[$this->_counter]['form_elements'][$this->_getName($text)] = array(
                        'type'  => 'email',
                        'value'  =>  $this->_getValue($text),
                        'id'  =>  $this->_getId($text),
                        'class'  =>  $this->_getClass($text)
                    );
                }
            }

			// form elements: input type = password
			if (preg_match_all('/<input[^<>]+type=["\']password["\'][^<>]*>/isU', $form, $passwords)) {
				foreach ($passwords[0] as $password) {
					$this->_return[$this->_counter]['form_elements'][$this->_getName($password)] = array(
						'type'  =>  'password',
						'value'  =>  $this->_getValue($password)
					);
				}
			}

			// form elements: textarea
			if (preg_match_all('/<textarea.*>.*<\/textarea>/isU', $form, $textareas)) {
				foreach ($textareas[0] as $textarea) {
					preg_match('/<textarea.*>(.*)<\/textarea>/isU', $textarea, $textarea_value);
					$this->_return[$this->_counter]['form_elements'][$this->_getName($textarea)] = array(
						'type'  =>  'textarea',
						'value'  =>  $textarea_value[1]
					);
				}
			}

			// form elements: input type = checkbox
			if (preg_match_all('/<input[^<>]+type=["\']checkbox["\'][^<>]*>/isU', $form, $checkboxes)) {
				foreach ($checkboxes[0] as $checkbox) {
					if (preg_match('/checked/is', $checkbox)) {
						$this->_return[$this->_counter]['form_elements'][$this->_getName($checkbox)] = array(
							'type'  =>  'checkbox',
							'value'  =>  'on'
						);
					} else {
						$this->_return[$this->_counter]['form_elements'][$this->_getName($checkbox)] = array(
							'type'  =>  'checkbox',
							'value'  =>  ''
						);
					}
				}
			}

			// form elements: input type = radio
			if (preg_match_all('/<input[^<>]+type=["\']radio["\'][^<>]*>/isU', $form, $radios)) {
				foreach ($radios[0] as $radio) {
					if (preg_match('/checked/i', $radio)) {
						$this->_return[$this->_counter]['form_elements'][$this->_getName($radio)] = array(
							'type'  =>  'radio',
							'value'  =>  $this->_getValue($radio)
						);
					}
				}
			}

			// form elements: input type = submit
			if (preg_match_all('/<input[^<>]+type=["\']submit["\'][^<>]*>/isU', $form, $submits)) {
				foreach ($submits[0] as $submit) {
					$this->_return[$this->_counter]['buttons'][$this->button_counter] = array(
						'type'  => 'submit',
						'name'  => $this->_getName($submit),
						'value'  => $this->_getValue($submit)
					);
					$this->button_counter++;
				}
			}

			// form elements: input type = button
			if (preg_match_all('/<input[^<>]+type=["\']button["\'][^<>]*>/isU', $form, $buttons)) {
				foreach ($buttons[0] as $button) {
					$this->_return[$this->_counter]['buttons'][$this->button_counter] = array(
						'type'  => 'button',
						'name'  => $this->_getName($button),
						'value'  => $this->_getValue($button)
					);
					$this->button_counter++;
				}
			}

			// form elements: input type = reset
			if (preg_match_all('/<input[^<>]+type=["\']reset["\'][^<>]*>/isU', $form, $resets)) {
				foreach ($resets[0] as $reset) {
					$this->_return[$this->_counter]['buttons'][$this->button_counter] = array(
						'type'  => 'reset',
						'name'  => $this->_getName($reset),
						'value'  => $this->_getValue($reset)
					);
					$this->button_counter++;
				}
			}

			// form elements: input type = image
			if (preg_match_all('/<input[^<>]+type=["\']image["\'][^<>]*>/isU', $form, $images)) {
				foreach ($images[0] as $image) {
					$this->_return[$this->_counter]['buttons'][$this->button_counter] = array(
						'type'  => 'image',
						'name'  => $this->_getName($image),
						'value'  => $this->_getValue($image)
					);
					$this->button_counter++;
				}
			}

			// input type=select entries
			// Here I have to go on step around to grep at first all select names and then
			// the content. Seems not to work in an other way
			if (preg_match_all('/<select.*>.+<\/select>/isU', $form, $selects)) {
				foreach ($selects[0] as $select) {
					if (preg_match_all('/<option.*>.+<\/option>/isU', $select, $all_options)) {
						$option_value = '';
						foreach ($all_options[0] as $option) {
							if (preg_match('/selected/i', $option)) {
								if (preg_match('/value=["\'](.*)["\']\s/isU', $option, $option_value)) {
									$option_value = $option_value[1];
									$found_selected = 1;
								} else {
									preg_match('/<option.*>(.*)<\/option>/isU', $option, $option_value);
									$option_value = $option_value[1];
									$found_selected = 1;
								}
							}
						}
						if (!isset($found_selected)) {
							if (preg_match('/value=["\'](.*)["\']/isU', $all_options[0][0], $option_value)) {
								$option_value = $option_value[1];
							} else {
								preg_match('/<option>(.*)<\/option>/isU', $all_options[0][0], $option_value);
								$option_value = $option_value[1];
							}
						} else {
							unset($found_selected);
						}
						$this->_return[$this->_counter]['form_elements'][$this->_getName($select)] = array(
							'type'  => 'select',
							'value'  => trim($option_value)
						);
					}
				}
			}

			# form elements: input type = --not defined--
			if ( preg_match_all('/<input[^<>]+name=["\'](.*)["\'][^<>]*>/isU', $form, $inputs)) {
				foreach ($inputs[0] as $input) {
					if ( !preg_match('/type=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $input) ) {
						if ( !isset($this->_return[$this->_counter]['form_elements'][$this->_getName($input)]) ) {
							$this->_return[$this->_counter]['form_elements'][$this->_getName($input)] =
								array(
									'type'  => 'text',
									'value'  =>  $this->_getValue($input),
									'id'  =>  $this->_getId($input),
									'class'  =>  $this->_getClass($input)
								);

						}
					}
				}
			}

			// Update the form counter if we have more then 1 form in the HTML table
			$this->_counter++;
		}

		return $this->_return;
	}
134287
protected function getGroups()
	{
		// Initialize variables.
		$groups = array();
		$label = 0;

		foreach ($this->element->children() as $element)
		{
			switch ($element->getName())
			{
				// The element is an <option />
				case 'option':
					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Create a new option object based on the <option /> element.
					$tmp = Dropdown::option(
						($element['value']) ? (string) $element['value'] : trim((string) $element),
						App::get('language')->alt(trim((string) $element), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), 'value', 'text',
						((string) $element['disabled'] == 'true')
					);

					// Set some option attributes.
					$tmp->class = (string) $element['class'];

					// Set some JavaScript option attributes.
					$tmp->onclick = (string) $element['onclick'];

					// Add the option.
					$groups[$label][] = $tmp;
					break;

				// The element is a <group />
				case 'group':
					// Get the group label.
					if ($groupLabel = (string) $element['label'])
					{
						$label = App::get('language')->txt($groupLabel);
					}

					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Iterate through the children and build an array of options.
					foreach ($element->children() as $option)
					{
						// Only add <option /> elements.
						if ($option->getName() != 'option')
						{
							continue;
						}

						// Create a new option object based on the <option /> element.
						$tmp = Dropdown::option(
							($option['value']) ? (string) $option['value'] : App::get('language')->txt(trim((string) $option)),
							App::get('language')->txt(trim((string) $option)), 'value', 'text', ((string) $option['disabled'] == 'true')
						);

						// Set some option attributes.
						$tmp->class = (string) $option['class'];

						// Set some JavaScript option attributes.
						$tmp->onclick = (string) $option['onclick'];

						// Add the option.
						$groups[$label][] = $tmp;
					}

					if ($groupLabel)
					{
						$label = count($groups);
					}
				break;

				// Unknown element type.
				default:
					App::abort(500, App::get('language')->txt('JLIB_FORM_ERROR_FIELDS_GROUPEDLIST_ELEMENT_NAME', $element->getName()));
				break;
			}
		}

		reset($groups);

		return $groups;
	}
789457
public function properties()
    {
        if ($this->properties === null) {
            $model = $this->proto();
            $props = $model->metadata()->properties();

            $collectionIdent = $this->collectionIdent();
            if ($collectionIdent) {
                $metadata      = $model->metadata();
                $adminMetadata = isset($metadata['admin']) ? $metadata['admin'] : null;

                if (isset($adminMetadata['lists'][$collectionIdent]['properties'])) {
                    // Flipping to have property ident as key
                    $listProperties = array_flip($adminMetadata['lists'][$collectionIdent]['properties']);
                    // Replacing values of listProperties from index to actual property values
                    $props = array_replace($listProperties, $props);
                    // Get only the keys that are in listProperties from props
                    $props = array_intersect_key($props, $listProperties);
                }
            }

            $this->properties = $props;
        }

        return $this->properties;
    }
66840
public function formProperties()
    {
        $sidebars = $this->sidebars;
        if (!is_array($sidebars)) {
            yield null;
        } else {
            foreach ($this->formProperties as $formProperty) {
                if ($formProperty->active() === false) {
                    continue;
                }

                $GLOBALS['widget_template'] = $formProperty->inputType();

                yield $formProperty->propertyIdent() => $formProperty;

                $GLOBALS['widget_template'] = '';
            }
        }
    }