shortcut for file field

@param   string          input name (dot notation for multi-dimensional array)
@param   string|array    Label string or array of label value and attributes
@param   array           input attributes
@return  string
339270
public function file($name, $label, $attr = array())
    {
        return $this->input(
            $name,
            $label,
            array_merge(
                $attr,
                array('type' => 'file')
            )
        );
    }
303041
public static function label($input, $text, array $attributes = null)
    {
        // Set the label target
        $attributes['for'] = $input;

        return '<label'.Html::attributes($attributes).'>'.$text.'</label>';
    }
1088991
def getinputfilename(self, inputtemplate, filename):
        
        if inputtemplate.filename:
            filename = inputtemplate.filename
        elif inputtemplate.extension:
            if filename.lower()[-4:] == '.zip' or filename.lower()[-7:] == '.tar.gz' or filename.lower()[-8:] == '.tar.bz2':
                #pass archives as-is
                return filename

            if filename[-len(inputtemplate.extension) - 1:].lower() != '.' +  inputtemplate.extension.lower():
                filename += '.' + inputtemplate.extension

        return filename
45557
public function upload_form($attrib, $name, $action, $input_attr = array())
    {
        // Get filesize, enable upload progress bar
        $max_filesize = $this->upload_init();

        $hint = html::div('hint', $this->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))));

        if ($attrib['mode'] == 'hint') {
            return $hint;
        }

        // set defaults
        $attrib += array('id' => 'rcmUploadbox', 'buttons' => 'yes');

        $event   = rcmail_output::JS_OBJECT_NAME . ".command('$action', this.form)";
        $form_id = $attrib['id'] . 'Frm';

        // Default attributes of file input and form
        $input_attr += array(
            'id'   => $attrib['id'] . 'Input',
            'type' => 'file',
            'name' => '_attachments[]',
        );

        $form_attr = array(
            'id'      => $form_id,
            'name'    => $name,
            'method'  => 'post',
            'enctype' => 'multipart/form-data'
        );

        if ($attrib['mode'] == 'smart') {
            unset($attrib['buttons']);
            $form_attr['class'] = 'smart-upload';
            $input_attr = array_merge($input_attr, array(
                // #5854: Chrome does not execute onchange when selecting the same file.
                //        To fix this we reset the input using null value.
                'onchange' => "$event; this.value=null",
                'class'    => 'smart-upload',
                'tabindex' => '-1',
            ));
        }

        $input   = new html_inputfield($input_attr);
        $content = $attrib['prefix'] . $input->show();

        if ($attrib['mode'] != 'smart') {
            $content  = html::div(null, $content);
            $content .= $hint;
        }

        if (rcube_utils::get_boolean($attrib['buttons'])) {
            $button   = new html_inputfield(array('type' => 'button'));
            $content .= html::div('buttons',
                $button->show($this->gettext('close'), array('class' => 'button', 'onclick' => "$('#{$attrib['id']}').hide()")) . ' ' .
                $button->show($this->gettext('upload'), array('class' => 'button mainaction', 'onclick' => $event))
            );
        }

        $this->output->add_gui_object($name, $form_id);

        return html::div($attrib, $this->output->form_tag($form_attr, $content));
    }
942134
private static function buildWrapper($field, $name, $label = '', $checkbox = false, $required)
        {
            $getter = 'get' . Inflector::camelize($name);
            $error = null;
            $actual = Session::instance('ThinForm')->getActual();

            if (null !== $actual) {
                $error = $actual->getErrors()->$getter();
            }

            $class = 'control-group';

            if (!empty(static::$controlGroupError) && !empty($error)) {
                $class .= ' ' . static::$controlGroupError;
            }

            $id = ' id="control-group-' . $name . '"';
            $out = '<div class="' . $class . '"' . $id . '>';
            $out .= static::buildLabel($name, $label, $required);
            $out .= '<div class="controls">' . PHP_EOL;
            $out .= ($checkbox === true) ? '<label class="checkbox">' : '';
            $out .= $field;

            if (!empty($error)) {
                $out .= '<span class="help-inline">' . $error . '</span>';
            }

            $out .= ($checkbox === true) ? '</label>' : '';
            $out .= '</div>';
            $out .= '</div>' . PHP_EOL;

            return $out;
        }
211328
public static function label(
        string $label, 
        string $for, 
        array $attributes = []
    ) : string
    {
        $preAttributesLabel = [
            "for" => $for,
        ];
        $attributesLabel = array_merge($preAttributesLabel, $attributes);
        return self::tag("label", $label, $attributesLabel);
    }
196574
public function input($type, $name, $label = null, $value = null, array $options = [])
    {
        $label = $this->getLabelTitle($label, $name);

        $optionsField = $this->getFieldOptions(array_except($options, ['suffix', 'prefix']), $name);

        $inputElement = '';

         if(isset($options['prefix'])) {
            $inputElement = $options['prefix'];
        }

        $inputElement .= $type === 'password' ? $this->form->password($name, $optionsField) : $this->form->{$type}($name, $value, $optionsField);

         if(isset($options['suffix'])) {
            $inputElement .= $options['suffix'];
        }

         if(isset($options['prefix']) || isset($options['suffix'])) {
            $inputElement = '<div class="input-group">' . $inputElement . '</div>';
        }

        $wrapperOptions = $this->isHorizontal() ? ['class' => $this->getRightColumnClass()] : [];
        $wrapperElement = '<div' . $this->html->attributes($wrapperOptions) . '>' . $inputElement . $this->getFieldError($name) . $this->getHelpText($name, $optionsField) . '</div>';

        return $this->getFormGroup($name, $label, $wrapperElement);
    }
1274282
public function fileField($model, $attribute, $htmlOptions = array())
    {
        return $this->createInput(TbHtml::INPUT_TYPE_FILE, $model, $attribute, $htmlOptions);
    }
434904
protected function backup_detail_input($label, $type, $name, $value, array $attributes = array(), $description = null) {
        if (!empty($description)) {
            $description = html_writer::tag('span', $description, array('class' => 'description'));
        } else {
            $description = '';
        }
        return $this->backup_detail_pair(
            $label,
            html_writer::empty_tag('input', $attributes + array('name' => $name, 'type' => $type, 'value' => $value)) . $description
        );
    }
547906
private String getFileName(Field field) {
        String fileName = field.getAnnotation(Plugin.Data.class).value();
        if ("##default".equals(fileName)) {
            fileName = getName() + ".json";
        }
        return fileName;
    }
883727
public function input($filename, $input)
    {
        if (substr($filename, strlen($this->_settings['ext']) * -1) !== $this->_settings['ext']) {
            return $input;
        }

        $tmpfile = tempnam(TMP, 'asset_compress_less');
        $this->_generateScript($tmpfile, $input);

        $bin = $this->_settings['node'] . ' ' . $tmpfile;
        $env = array('NODE_PATH' => $this->_settings['node_path']);
        $return = $this->_runCmd($bin, '', $env);
        unlink($tmpfile);
        return $return;
    }
23554
public function input($name, $options = array())
    {
        $options += array(
            "type"  => "text",
            "id"    => $this->id($name),
            "name"  => $this->name($name),
            "error" => true,
            "class" => "",
            "value" => "",
            "label" => null
        );

        $currentValue = $this->getCurrentValue($options['name']);

        $errorHtml = "";
        $fieldHasErrors = false;

        if (!is_null($this->associatedEntity)) {
            // Checkboxes may be posted has data[name][0] and therefore
            // we need to remove it to get the absolute field name.
            $validationName = $options["type"] === "checkbox" ?
                preg_replace('/\[\d+\]$/', '', $name) :
                $name;

            if ($this->associatedEntity->hasErrors($validationName)) {
                if ((bool)$options['error']) {
                    $errorHtml = $this->generateInlineErrors($validationName);
                }
                $fieldHasErrors = true;
                $options['class'] .= " error ";
            }
        }
        unset($options["error"]);

        $label = "";
        if (!is_null($options['label'])) {
            $labelOptions = array(
                "for"    => $options["id"],
                "class" => $fieldHasErrors ? "error" : "",
                "label" => $options["label"],
            );

            $label .= $this->label($options['name'], $labelOptions);
        }
        unset($options['label']);

        switch (strtolower($options['type'])) {
            case "textarea":
                return $label . "\n" . $this->generateTextarea($options, $currentValue) . $errorHtml . "\n";
            case "select":
                return $label . "\n" . $this->generateSelect($options, $currentValue) . $errorHtml . "\n";
            case "radio":
                return $this->generateRadio($options, $currentValue) . $errorHtml . "\n" . $label . "\n";
            case "checkbox":
                return $this->generateCheckbox($options, $currentValue) . $errorHtml . "\n" . $label . "\n";
            case "hidden":
                return $label . "\n" . $this->generateHidden($options, $currentValue) . $errorHtml . "\n";
            default:
                return $label . "\n" . $this->generateTextinput($options, $currentValue) . $errorHtml . "\n";
        }
    }
375639
public function checkbox($name, $label, $attr = array())
    {
        return $this->input(
            $name,
            $label,
            array_merge(
                $attr,
                array('type' => 'checkbox')
            )
        );
    }
1135465
static function input($input_type, $name, $value=null, $settings=[])
    {
        $settings = static::formatSettings($settings);
        is_array($value) && $value = current($value);
        $str = '';
        $pre_input_type = $input_type;
        switch ($input_type) {
            case 'checkbox':
            case 'radio':
                $settings['class'] = isset($settings['class']) ? $settings['class'] : 'ace ace-switch ace-switch-5';
                $str .= '<label>' . PHP_EOL ;
                break;
            case 'text':
            case 'password':
                $settings['id'] = isset($settings['id']) ? static::formatId($settings['id']) : static::formatId($name);
                $settings['class'] = isset($settings['class']) ? 'form-control ' . $settings['class'] : 'form-control';
                break;
            case 'datetime':
            case 'date':
                $input_type = 'text';
                $value = $pre_input_type == 'datetime' ? DataHelper::fromUnixtime($value) : DataHelper::toDate($value);
                $settings['id'] = isset($settings['id']) ? static::formatId($settings['id']) : static::formatId($name);
                $settings['class']  = isset($settings['class']) ? $settings['class'] . ' form-control date-picker' : ' form-control date-picker';
                break;
            default:
                $settings['class'] = isset($settings['class']) ? $settings['class'] : '';
                break;
        }
        
        $str .= '<input type="' . $input_type . '" name="' . $name . '"';
        
        if ($input_type == 'checkbox' || $input_type == 'radio') {
            // 处理 value, checked
            $o_form_value = !is_null($value) || $value !== '' ? $value : '1';
            $value   = $value ? : '1';
            if (isset($settings['checked'])) {
                if (is_array($settings['checked'])) {
                    $_checked = in_array($value, $settings['checked']) ? true : false;
                } elseif (in_array($settings['checked'], ['', 1,0,true,false])) {
                    $_checked = $settings['checked'];
                } else {
                    $_checked = $value == $settings['checked'] ? true : false;
                }
                $str .= $_checked ? ' checked="checked"' : '';
            } elseif (is_numeric($o_form_value) || is_bool($o_form_value)) {
                if (intval($o_form_value) == 1) {
                    $str .= ' checked="checked"';
                }
            }
        }
        
        $str .= ' value="' . $value . '"';
        
        foreach($settings as $k => $v) {
            if (in_array($k, array('class', 'onchange', 'id', 'readonly', 'style', 'placeholder'))) {
                $str .= " $k=\"$v\"";
            } elseif($k == 'checked' && ($input_type !== 'checkbox' && $input_type !== 'radio')) {
                $str .= " $k=\"$v\"";
            }
        }
        $str .= '> ';
        
        if ($input_type == 'checkbox' || $input_type == 'radio') {
            $title = isset($settings['title']) ? $settings['title'] : '';
            $str .= ' <span class="lbl"> '.$title.' </span> ' . PHP_EOL;
            $str .= '</label>' . PHP_EOL ;
        }
        
        /**
         * 处理日期输入控件，依赖于 jquery.js, jquery-ui.datetime.js, datetimepicker.js, datetimepicker.css
         * <script src='{$rootUrl}/static/jquery/jquery-1.10.2.min.js'></script>
         * <link type="text/css" rel="stylesheet" href="{$rootUrl}/static/datetimepicker-2.5.3/jquery.datetimepicker.css"/>
         * <script src="{$rootUrl}/static/datetimepicker-2.5.3/jquery.datetimepicker.full.min.js"></script>
         */
        if ($pre_input_type == 'datetime' || $pre_input_type == 'date') {
            $innerJs = "";
            $dformat = $pre_input_type == 'datetime' ? 'Y-m-d H:i:s' : 'Y-m-d';
            if (!static::$isLoaded['datetime']) {
                $web_url = Config::getRootUrl();
                $innerJs .= <<<EOF
                    <link type="text/css" rel="stylesheet" href="${web_url}/static/datetimepicker-2.5.3/jquery.datetimepicker.css"/>
EOF;
                static::$isLoaded['datetime'] = true;
            }
            $innerJs .= <<<EOF
                <script>
                    require(['jquery.datetime'], function() {
                        $("#${settings['id']}").datetimepicker({
                    		format:	"{$dformat}",
                    	});
                    });
                </script>
EOF;
            $dt_str = '<div class="input-group input-group-sm">' . PHP_EOL;
            $dt_str .= $str . PHP_EOL;
            $dt_str .= '<span class="input-group-addon">' . PHP_EOL;
            $dt_str .= '    <i class="fa fa-clock-o bigger-110"></i>' . PHP_EOL;
            $dt_str .= '</span>' . PHP_EOL;
            $dt_str .= '</div>' . PHP_EOL;
            $dt_str .= $innerJs;
            	
            $str = & $dt_str;
        }
         
        return $str;
    }
614112
@Override
	public void loadInputData(String fileName) {
		Reader r = media.openFile(fileName);

		List<PathLabel> refs = new ArrayList<>();
		try {
			BufferedReader reader = new BufferedReader(r);

			String line;
			while( (line = reader.readLine()) != null ) {

				String[]z = line.split(":");
				String[] names = new String[z.length-1];
				for( int i = 1; i < z.length; i++ ) {
					names[i-1] = baseDirectory+z[i];
				}

				refs.add(new PathLabel(z[0],names));
			}

			setInputList(refs);

		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
27921
public function user_filter_simpleselect($name, $label, $advanced, $field, $options) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($name, $label, $advanced, $field, $options);
    }
423188
public function label($name)
    {
        $path = $this->path.'.attributes.'.$name;

        return $this->translator->get($path);
    }