Generates an input.

@param string $type the input type
@param boolean $list whether the input is of dropdown list type

@return string the rendered input markup
962499
protected function getInput($type, $list = false)
    {
        if ($this->hasModel()) {
            $input = 'active' . ucfirst($type);
            return $list ?
                Html::$input($this->model, $this->attribute, $this->data, $this->options) :
                Html::$input($this->model, $this->attribute, $this->options);
        }

        $input = $type;
        $checked = false;
        if ($type == 'radio' || $type == 'checkbox') {
            $checked = ArrayHelper::remove($this->options, 'checked', '');
            if (empty($checked) && !empty($this->value)) {
                $checked = ($this->value == 0) ? false : true;
            } elseif (empty($checked)) {
                $checked = false;
            }
        }

        return $list ?
            Html::$input($this->name, $this->value, $this->data, $this->options) :
            (($type == 'checkbox' || $type == 'radio') ?
                Html::$input($this->name, $checked, $this->options) :
                Html::$input($this->name, $this->value, $this->options));
    }
349928
protected function getBasicTemplate(string $type) : string
    {
        $view = $this->config->getView();
        $result = $view->Form->control('{{name}}', [
            'value' => '{{value}}',
            'type' => $type,
            'label' => false
        ]);

        return $result;
    }
599100
protected function fill_collections($list=""){
		$options = array();
		foreach ($this->options as $k=>$v) { 
			$name = $k;
			$option="\"{$name}\":[";
			if (!is_string($this->options[$name])){
				$data = json_encode($this->options[$name]->render());
				$option.=substr($data,1,-1);
			} else
				$option.=$this->options[$name];
			$option.="]";
			$options[] = $option;
		}
		$this->extra_output .= implode($this->data_separator, $options);
	}
352597
public function setType($type)
    {
        $returnValue = (bool) false;

        
		$this->type = $type;
		$returnValue = true;
        

        return (bool) $returnValue;
    }
970278
public function backendListArrayToMultiAssocArray(stdClass $list)
    {
        $ret = array();

        if ( isset($list->ArrayOfString) ) {
            foreach ( $list->ArrayOfString as $a ) {
                if ( is_array($a) ) {      // 1 template only
                    $o         = new StdClass();
                    $o->string = $a;
                } else {                 // 2 or more templates
                    $o = $a;
                }
                unset($a);

                if ( isset($o->string) ) {
                    $date1 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 3 ]);
                    $date2 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 1 ]);
                    $ret[] = array(
                        'filename'   => $o->string[ 0 ] ,
                        'fileSize'   => ( integer ) $o->string[ 2 ] ,
                        'createTime' => ( integer ) $date1->getTimestamp() ,
                        'modifyTime' => ( integer ) $date2->getTimestamp() ,
                    );
                    unset($date1 , $date2);
                }
            }
        }

        return $ret;
    }
210361
public function generate($type)
    {
        return function ($row, $control, $templates = []) use ($type) {
            $data = $this->buildFieldByType($type, $row, $control);
            return $this->render($templates, $data);
        };
    }
760373
protected static function btnDropdown($type, $label, $items, $htmlOptions)
    {
        $menuOptions = TbArray::popValue('menuOptions', $htmlOptions, array());
        $groupOptions = TbArray::popValue('groupOptions', $htmlOptions, array());
        self::addCssClass('btn-group', $groupOptions);
        if (TbArray::popValue('dropup', $htmlOptions, false)) {
            self::addCssClass('dropup', $groupOptions);
        }
        $output = self::openTag('div', $groupOptions);
        $toggleButtonType = TbArray::popValue('type', $htmlOptions, self::BUTTON_TYPE_HTML);
        $toggleButtonType = is_array($toggleButtonType) ? $toggleButtonType[1] : $toggleButtonType;
        if (TbArray::popValue('split', $htmlOptions, false)) {
            $output .= self::createButton($type, $label, $htmlOptions);
            $label = '';
        }        
        if(in_array($toggleButtonType, array(self::BUTTON_TYPE_LINKBUTTON, self::BUTTON_TYPE_LINK))){
            $output .= self::dropdownToggleLink($label, $htmlOptions);       
        } else {
            $output .= self::dropdownToggleButton($label, $htmlOptions);
        }
        $output .= self::dropdown($items, $menuOptions);
        $output .= '</div>';
        return $output;
    }
880387
public static function input(string $type)
    {
        $self = self::$input[$type] ?? new self;

        self::$input[$type] = $self;

        switch (strtoupper($type)) {
            case 'GET':
            case 'POST':
                $self->params = filter_input_array(constant('INPUT_' . $type)) ?? [];
                break;
            case 'PUT':
            case 'DELETE':
                $self->params = self::getParsedInput();
                break;
        }

        return function ($key = null) use ($self) {
            $self->key = $key;

            return $self;
        };
    }
1005115
public function datalist($id, $list = [])
    {
        $this->type = 'datalist';

        $attributes['id'] = $id;

        $html = [];

        if ($this->isAssociativeArray($list)) {
            foreach ($list as $value => $display) {
                $html[] = $this->option($display, $value, null, []);
            }
        } else {
            foreach ($list as $value) {
                $html[] = $this->option($value, $value, null, []);
            }
        }

        $attributes = $this->html->attributes($attributes);

        $list = implode('', $html);

        return $this->toHtmlString("<datalist{$attributes}>{$list}</datalist>");
    }
542947
public function isValid($type, $render = false)
    {
        $original = $type;

        if (in_array($type, ['json', 'array'])) {
            $type = 'body';
        }

        $type = $type == 'multiple' ? 'dropdown' : $type;
        $fields = $this->config[$type];
        $valid = true;

        // mapping all data
        $this->data->map(function ($item) use ($fields, &$valid, $type) {

            foreach ($fields as $field) {
                if ($valid && !empty($field)) {
                    $valid = isset($item[$field]);
                }
            }

        });

        // render data
        if ($valid && $render) {
            return call_user_func([$this, 'renderAs'.ucfirst($original)]);
        }

        return $valid;
    }
846160
public function createList($list = null)
    {
        $node = new Item();

        if ($list instanceof Item) {
            $node = $list;
        } elseif ($list instanceof Element) {
            $node->entity->setEntityName($list->entity->getEntityName());
            $node->childNodes->push($list);
        } else {
            if (is_numeric($list)) {
                $node->entity->setEntityName('list-' . $list);
            }

            if (isset($list)) {
                $node->entity->setEntityName($list);
                $node->textContent->push($list);
            }
        }

        $this->pushChildNode($node);

        return $this->childNodes->last();
    }
993320
public static function build($list)
    {
        if (is_string($list)) {
            return $list;
        }

        if ($list instanceof self) {
            $list = $list->tokens;
        }

        $ret = '';
        if (is_array($list)) {
            foreach ($list as $tok) {
                $ret .= $tok->token;
            }
        }

        return $ret;
    }
1322608
public static function inList($check, array $list, $caseInsensitive = false)
    {
        if ($caseInsensitive) {
            $list = array_map('mb_strtolower', $list);
            $check = mb_strtolower($check);
        } else {
            $list = array_map('strval', $list);
        }

        return in_array((string)$check, $list, true);
    }
1055369
public function input ($field, $type = 'string', $default = null, $separator = ',')
	{
		// Check for array type
		$array = false;
		if (substr ($type, -2) === '[]') {
			$arrtype = substr ($type, 0, -2);
			$type = 'string';
			$array = true;
		}

		// Check post
		$value = Tools::getInput ($this->getPost (), $field, $type);
		if ($value === null)
		{
			// Check get
			$value = Tools::getInput ($this->getParameters (), $field, $type);
		}

		if ($value === null)
		{
			return $default;
		}

		// Check if array?
		if ($array) {
			$values = explode ($separator, $value);

			$value = array ();
			foreach ($values as $v) {
				if (Tools::checkInput ($v, $arrtype)) {
					$value[] = $v;
				}
			}
		}

		return $value;
	}
338767
public function renderFields($type, $fields = [])
    {
        if (empty($fields)) {
            $fields = $this->getFields();
        }
        $output = '';

        switch ($type) {
        case 'form-create':
            $output .= $this->fieldHelper->formCreate($fields);
            break;
        case 'form-edit':
            $output .= $this->fieldHelper->formEdit($fields);
            break;
        case 'table-headings':
            $output .= $this->fieldHelper->tableHeadings($fields);
            break;
        case 'table-content':
            $output .= $this->fieldHelper->tableContent($fields, $this->instance);
            break;
            // JavaScript Variables
        case 'js-var':
            foreach ($fields as $f) {
                $output .= 'var '.$f.' = '.$this->instance->$f.'; ';
            }
            break;
        case 'js-modal-create':
            foreach ($fields as $f) {
                $output .= '"'.$f.'": $(\'#createItem'.$f.'\').val(), ';
            }
            break;
        default:
            break;
        }

        echo $output;
    }
1128287
public function optionMetadata($type)
    {
        if (in_array($type, ['modules', 'languages'])) {
            switch ($type) {
                case 'modules':
                    $line = PHP_EOL . print_r(modules()->getRegistry(), true);
                    break;

                case 'languages':
                    $line = PHP_EOL . print_r(language()->getRegistry(), true);
                    break;
            }

            if (isset($line)) {
                output()->write($line);

                exit(EXIT_SUCCESS);
            }
        }
    }
272814
public static function select($name, $list = [], $selected = null, $options = [])
    {
        self::exclure($options, ['name']);
        //
        $options['name'] = $name;
        //
        $sub = '';
        //
        if (!empty($list)) {
            foreach ($list as $value) {
                $sub .= self::option($value, (!is_null($selected) && $value == $selected));
            }
        }
        //
        $options = Html::attributes($options);
        //
        return '<select'.$options.">\n".$sub."</select>\n";
    }