设置配置文件
@param  $name
@param  null $val
@throws Exception
@return self
505382
public function setConfig($name, $val = null)
    {
        $setting = $this->settings;
        if (is_array($name)) {
            $setting = array_merge($setting, $name);
        } elseif ($val === null) {
            if (file_exists($name)) {
                $configs = include $name;
                $setting = array_merge($setting, $configs);
            } else {
                throw new Exception("不存在的配置文件:" . $name);
            }
        } else {
            $setting[$name] = $val;
        }
        $this->settings = $setting;
        return $this;
    }
1028783
public function up($name=null)
	{
		if(null===$name)
		{
			$files=$this->parseFiles($_FILES);
		}
		else 
		{
			$files=$this->parseFiles(array($name=>$_FILES[$name]));
		}
		$this->result=array();
		$this->files=array();
		$result=true;
		foreach($files as $key=>$item)
		{
			if(isset($item['name']))
			{
				// 单文件上传
				if(!$this->uploadSingle($item,$r))
				{
					$result=false;
				}
			}
			else
			{
				// 多文件上传
				if(!$this->uploadMulti($item,$r))
				{
					$result=false;
				}
			}
			$this->result[$key]=$r;
		}
		return $result;
	}
1185159
public function set($key, $val = null)
    {
        if (is_array($key)) {
            $this->_setpost = array_merge($this->_setpost, $key);
        } else {
            $this->_setpost[$key] = $val;
        }
        return $this;
    }
1300642
public function addToArray($name, $val)
    {
        $names = explode('.', $name);

        // We still want to do this even if we have strict path checking for legacy code
        $var = &$this->data;
        $diffVar = &$this->changedData;

        foreach ($names as $n) {
            $var = &$var[$n];
            $diffVar = &$diffVar[$n];
        }

        $var[] = $val;
        $diffVar[sizeof($var) - 1] = $val;
    }
26582
private function renderResult($name, $val)
    {
        $this->code = "\${$this->code}{$name}";

        if ($this->codeif) {
            // Echo if
            echo "{$this->indentation}@if ({$this->code})<br>";

            // Increase indentation
            $this->increaseIndentation();
        }

        // Wrap with {{ }} or {!! !!}
        if (Utils::doesStringContainMarkup($val)) {
            $this->code = "{!! {$this->code} !!}";
        } else {
            $this->code = "{{ {$this->code} }}";
        }

        // Echo code
        echo "{$this->indentation}{$this->code}<br>";
        
        if ($this->codeif) {
            // Increase indentation
            $this->decreaseIndentation();

            // Echo endif
            echo "{$this->indentation}@endif<br>";
        }
    }
67316
public function set ($name, $val, $validate = TRUE)
	{
		
		// If the attribute doesn't exists
		
		if (!$this->attributeExists ($name))
		{
			throw new Exception (get_called_class () . '->' . $name . ' attribute does not exist!');
		}
		
		// If attribute setter isn't set or is disabled
		
		if (!$this->attributeSet ($name))
		{
			throw new Exception (get_called_class () . '->' . $name . ' attribute set is disabled!');
		}
		
		// If we're validating the value
		
		if ($validate)
		{
			
			// Set friendly name if one exists
			
			$friendlyName	= isset (static::$attributes[$name]['name'])? static::$attributes[$name]['name'] : $name;
			
			// Validate it using the parser method
			
			$this->parser->Validate ($friendlyName, static::$attributes[$name], $val);
			
		}
		
		// Set the attribute value
		
		$this->attributeValues[$name]	= $val;
		
	}
642340
private function _createFile($dir, $name, $ext)
    {
        if (!empty($this->rootDir)) {
            if (!file_exists($this->_getFileDir($dir))) {
                mkdir($this->_getFileDir($dir), 0777, true);
            }
            if (!file_exists($this->_getFilePath($dir, $name, $ext))) {
                if (file_put_contents($this->_getFilePath($dir, $name, $ext), '') === false) {
                    throw new \Exception("Could not create $ext for {$this->username}.");
                }
            }
        }
    }
517435
public function set($name, $value = null)
	{
		is_null($name) or \Arr::set($this->data, $name, $value);

		return $this;
	}
639774
public function attachment(string $file, ?string $name = null)
  {
    $this->attachment[] = ['file' => $file, 'name' => $name];
    return $this;
  }
546932
public function prop(string $name, $val=null)
    {
        if ($val !== null) { // set attribute for all nodes
            foreach ($this->nodes as $node) {
                $node->$name = $val;
            }

            return $this;
        }
        // get property value for first element
        if ($name === 'outerHTML') {
            return $this->getOuterHtml();
        }
        if ($node = $this->getFirstElmNode()) {
            if (isset($node->$name)) {
                return $node->$name;
            }
        }
    }
604160
public function attr(string $name, $val=null)
    {
        if ($val !== null) { // set attribute for all nodes
            foreach ($this->getElements() as $node) {
                $node->setAttribute($name, $val);
            }
            return $this;
        }
        if ($node = $this->getFirstElmNode()) { // get attribute value for first element
            return $node->getAttribute($name);
        }
    }
339270
public function file($name, $label, $attr = array())
    {
        return $this->input(
            $name,
            $label,
            array_merge(
                $attr,
                array('type' => 'file')
            )
        );
    }
631407
public function save($val)
    {
        // Current ident
        $i = $this->ident();

        // Upload file, if in request.
        if (isset($_FILES[$i])
            && (isset($_FILES[$i]['name']) && $_FILES[$i]['name'])
            && (isset($_FILES[$i]['tmp_name']) && $_FILES[$i]['tmp_name'])
        ) {
            $file = $_FILES[$i];

            if (is_array($file['name']) && $this->multiple() && $this->l10n()) {
                $f = [];
                foreach ($file['name'] as $lang => $langVal) {
                    $f[$lang] = [];
                    if (!$file['name'][$lang]) {
                        $f[$lang] = isset($val[$lang]) ? $val[$lang] : '';
                        continue;
                    }
                    $k = 0;
                    $total = count($file['name'][$lang]);
                    for (; $k < $total; $k++) {
                        $data = [];
                        $data['name'] = $file['name'][$lang][$k];
                        $data['tmp_name'] = $file['tmp_name'][$lang][$k];
                        $data['error'] = $file['error'][$lang][$k];
                        $data['type'] = $file['type'][$lang][$k];
                        $data['size'] = $file['size'][$lang][$k];

                        $f[$lang][] = $this->fileUpload($data);
                    }
                }
            } elseif (is_array($file['name']) && $this->multiple()) {
                $f = [];
                $k = 0;
                $total = count($file['name']);
                for (; $k < $total; $k++) {
                    $data = [];
                    $data['name'] = $file['name'][$k];
                    $data['tmp_name'] = $file['tmp_name'][$k];
                    $data['error'] = $file['error'][$k];
                    $data['type'] = $file['type'][$k];
                    $data['size'] = $file['size'][$k];

                    $f[] = $this->fileUpload($data);
                }
            } elseif (is_array($file['name']) && $this->l10n()) {
                // Not so cool
                // Both the multiple and l10n loop could and
                // should be combined into one.
                // Not sure how
                $f = [];
                foreach ($file['name'] as $lang => $langVal) {
                    $data = [];

                    if (!$file['name'][$lang]) {
                        $f[$lang] = isset($val[$lang]) ? $val[$lang] : '';
                        continue;
                    }
                    $data['name'] = $file['name'][$lang];
                    $data['tmp_name'] = $file['tmp_name'][$lang];
                    $data['error'] = $file['error'][$lang];
                    $data['type'] = $file['type'][$lang];
                    $data['size'] = $file['size'][$lang];

                    $f[$lang] = $this->fileUpload($data);
                }
            } else {
                $f = $this->fileUpload($file);
            }

            return $f;
        }

        // Check in vals for data: base64 images
        // val should be an array if multiple...
        if ($val !== null) {
            if ($this->l10n()) {
                $l10nVal = ($val instanceof Translation) ? $val->data() : $val;

                $f = [];
                foreach ($l10nVal as $v) {
                    if ($this->isDataUri($v)) {
                        $f[] = $this->dataUpload($v);
                    }
                }

                if (!empty($f)) {
                    return $f;
                }
            } elseif ($this->multiple()) {
                $f = [];
                foreach ($val as $v) {
                    if ((is_array($v) && isset($v['id'])) || $this->isDataUri($v)) {
                        $f[] = $this->dataUpload($v);
                    }
                }

                if (!empty($f)) {
                    return $f;
                }
            } elseif ($this->isDataUri($val)) {
                $f = $this->dataUpload($val);

                return $f;
            }
        }

        return $val;
    }
523486
protected function checkFileHeader($content, $header, $name)
    {
        $len = strlen($header);
        $flag = substr($content, 0, $len);
        if ($flag != $header) {
            throw new \Exception("$name 文件已损坏");
        }
        return substr($content, $len);
    }
406881
public function sendFile($field = null, $name = null)
    {
        if (!$name && (!$name = $this->getFirstFileName())) {
            return false;
        }
        $file = $this->getFilePath($field, $name);
        if (!$name || !file_exists($file)) {
            throw new NotFoundHttpException;
        }
        \Yii::$app->response->sendFile($file, $name);
    }
1329679
public function useName($name)
    {
        if (empty($name)) {
            throw new \Exception('Given name is empty!');
        }

        if (!isset($_FILES[$name])) {
            throw new \Exception('Given name not exists in $_FILES var!');
        }

        $this->data = $_FILES[$name];

        return $this;
    }
1262292
public function set($key, $val)
    {
        // set the variable
        if (empty($key)) return $this;

        $node = new Node($this->mainNode, $key, $val);
        $this->mainNode->addChild($node);

        return $this;
    }