上传组件

@param        $field
@param        $title
@param        $action
@param string $value
@param string $type
@return Upload
188355
public static function upload($field, $title, $action, $value = '', $type = Upload::TYPE_FILE)
    {
        $upload = new Upload($field, $title, $value);
        $upload->uploadType($type)->action($action);
        return $upload;
    }
1349334
public function addField(
        $fieldOrName,
        $classes = [],
        string $type = null,
        $value = null,
        string $title = null
    ) : self {
        if (!$fieldOrName instanceof Field) {
            $fieldOrName = new Field(
                $fieldOrName,
                is_array($classes) ? $classes : [$classes],
                $type,
                $value,
                $title
            );
        }

        $this->fields[] = $fieldOrName;

        return $this;
    }
753650
public static function frameInputOne($field, $title, $src, $value = '')
    {
        return self::frame($field, $title, $src, (string)$value);
    }
1111585
public static function city($field, $title, $province = [], $city = '')
    {
        if (is_array($province))
            $value = $province;
        else
            $value = [(string)$province, (string)$city];

        $cascader = self::cascader($field, $title, $value, Cascader::TYPE_CITY);
        $cascader->jsData('province_city');
        return $cascader;
    }
1361470
public function addDocument($type, $value)
    {
        if ($type && $value) {
            if (count($this->documents) == 0) {
                $document = new PagSeguroSenderDocument($type, $value);
                $this->documents[] = $document;
            }
        }
    }
911890
public function scheduleForUpload($value, $entity, $field)
    {
        if (is_string($value)) {
            // try to locate the file on disk
            $value = new FixtureFile($this->fileManager->getFilePath($entity, $field, $value));
        }

        if ($value instanceof File) {
            $replaceFile = isset($value->metaData['keep_previous_filename']) and $value->metaData['keep_previous_filename'];
            $path = $this->fileManager->prepare($value, $entity, $field, !$replaceFile);
            $fileName = basename($path);
            PropertyHelper::setValue($entity, $field, $fileName);
            $this->unitOfWork[spl_object_hash($entity)][$field]['save'] = function ($fm) use ($value, $path) {
                $fm->save($value, $path);
            };
            return $fileName;
        } else {
            throw new \InvalidArgumentException("Invalid argument to scheduleForUpload(): " . gettype($value));
        }
    }
559459
public function addChange(
        string $field,
        $value,
        int $type = self::TYPE_VALUE
    ): self {
        $this->changes[] = [
            'field' => $field,
            'type' => $type,
            'value' => $value,
        ];

        return $this;
    }
1155318
public static function select($field, $title, $value = '')
    {
        $multiple = is_array($value) ? true : false;
        $select = new Select($field, $title, $value);
        $select->multiple($multiple);
        return $select;
    }
47876
protected function update($type, $field, $value)
    {
        $this->update[$field] = [$type, $value];

        return $this;
    }
1328885
public function addInput($type = 'text' ,$name , $title ='' ,$value = '' , $placeholder = '' , $required = false , $msg = '', $group = '' , $readonly = false){

        $data = [

            'type' => $type,
            'name' => $name,
            'title' => $title,
            'id'  => $this->formName . '-' . $name ,
            'placeholder' => $placeholder,
            'value' => $value,
            'msg' => $msg,
            'group' => $group
        ];

        if ($required == true){
            $data['required'] = $required;
        }
        if ($readonly == true){
            $data['readonly'] = $readonly;
        }

        $this->addElement($data);

        return $this;
    }
979374
public function upload($file, $type)
    {
        if (!$file || !$type) {
            $this->setError('参数缺失');

            return false;
        }

        if (!file_exists($file)) {
            $this->setError('文件路径不正确');

            return false;
        }

        $data          = [];
        $data['media'] = '@' . realpath($file);

        Api::setPostQueryStr('type', $type);

        $node = 'upload';

        $res = $this->_post($node, $data, false);

        return $res;
    }
395616
public static function textarea($field, $title, $value = '')
    {
        return self::input($field, $title, $value, Input::TYPE_TEXTAREA);
    }
127258
public function set($field, $value, $type = 'HOME')
    {
        $field   = strtolower($field);
        $type_uc = strtoupper($type);

        switch ($field) {
        case 'name':
        case 'displayname':
            $this->raw['FN'][0][0] = $this->displayname = $value;
            break;

        case 'surname':
            $this->raw['N'][0][0] = $this->surname = $value;
            break;

        case 'firstname':
            $this->raw['N'][0][1] = $this->firstname = $value;
            break;

        case 'middlename':
            $this->raw['N'][0][2] = $this->middlename = $value;
            break;

        case 'prefix':
            $this->raw['N'][0][3] = $value;
            break;

        case 'suffix':
            $this->raw['N'][0][4] = $value;
            break;

        case 'nickname':
            $this->raw['NICKNAME'][0][0] = $this->nickname = $value;
            break;

        case 'organization':
            $this->raw['ORG'][0][0] = $this->organization = $value;
            break;

        case 'photo':
            if (strpos($value, 'http:') === 0) {
                // TODO: fetch file from URL and save it locally?
                $this->raw['PHOTO'][0] = array(0 => $value, 'url' => true);
            }
            else {
                $this->raw['PHOTO'][0] = array(0 => $value, 'base64' => (bool) preg_match('![^a-z0-9/=+-]!i', $value));
            }
            break;

        case 'email':
            $this->raw['EMAIL'][] = array(0 => $value, 'type' => array_filter(array('INTERNET', $type_uc)));
            $this->email[] = $value;
            break;

        case 'im':
            // save IM subtypes into extension fields
            $typemap = array_flip($this->immap);
            if ($field = $typemap[strtolower($type)]) {
                $this->raw[$field][] = array(0 => $value);
            }
            break;

        case 'birthday':
        case 'anniversary':
            if (($val = rcube_utils::anytodatetime($value)) && ($fn = self::$fieldmap[$field])) {
                $this->raw[$fn][] = array(0 => $val->format('Y-m-d'), 'value' => array('date'));
            }
            break;

        case 'address':
            if ($this->addresstypemap[$type_uc]) {
                $type = $this->addresstypemap[$type_uc];
            }

            $value = $value[0] ? $value : array('', '', $value['street'], $value['locality'], $value['region'], $value['zipcode'], $value['country']);

            // fall through if not empty
            if (!strlen(join('', $value))) {
                break;
            }

        default:
            if ($field == 'phone' && $this->phonetypemap[$type_uc]) {
                $type = $this->phonetypemap[$type_uc];
            }

            if (($tag = self::$fieldmap[$field]) && (is_array($value) || strlen($value))) {
                $this->raw[$tag][] = (array) $value;
                if ($type) {
                    $index   = count($this->raw[$tag]) - 1;
                    $typemap = array_flip($this->typemap);
                    $this->raw[$tag][$index]['type'] = explode(',', $typemap[$type_uc] ?: $type);
                }
            }
            else {
                unset($this->raw[$tag]);
            }

            break;
        }
    }
1372471
public function createProject($title, $type, $reference, $options = array())
    {
        // Create base project and use updateProject() to set its properties:
        $project = new Project();
        return $this->updateProject($project, $title, $type, $reference, $options);
    }
739748
public static function month($field, $title, $value = '')
    {
        return self::datePicker($field, $title, (string)$value, DatePicker::TYPE_MONTH);
    }
606748
public function createNode($type, $title)
    {
        // @todo make this easily extensible.
        $node = (object) array(
        'title' => $title,
        'type' => $type,
        );
        $saved = $this->nodeCreate($node);
        // Set internal page on the new node.
        $this->getSession()->visit($this->locatePath('/node/' . $saved->nid));
    }
87757
public function addDocument($type, $value)
    {
        if ($type && $value) {
            if (count($this->documents) == 0) {
                $data = array(
                    'type' => $type,
                    'value' => $value
                );
                $document = new PagSeguroDocument($data);
                $this->documents = $document;
            }
        }
    }