Forges a new View object based on the extension

@param   string  $file         view filename
@param   array   $data         view data
@param   bool    $auto_encode  auto encode boolean, null for default
@return  object  a new view instance
422066
public static function forge($file = null, $data = null, $auto_encode = null)
	{
		$class = null;

		if ($file !== null)
		{
			$extension = pathinfo($file, PATHINFO_EXTENSION);

			$class = \Config::get('parser.extensions.'.$extension, null);
		}

		if ($class === null)
		{
			$class = get_called_class();
		}

		// Only get rid of the extension if it is not an absolute file path
		if ($file !== null and $file[0] !== '/' and $file[1] !== ':')
		{
			$file = $extension ? preg_replace('/\.'.preg_quote($extension).'$/i', '', $file) : $file;
		}

		// Class can be an array config
		if (is_array($class))
		{
			$class['extension'] and $extension = $class['extension'];
			$class = $class['class'];
		}

		// Include necessary files
		foreach ((array) \Config::get('parser.'.$class.'.include', array()) as $include)
		{
			if ( ! array_key_exists($include, static::$loaded_files))
			{
				require $include;
				static::$loaded_files[$include] = true;
			}
		}

		// Instantiate the Parser class without auto-loading the view file
		if ($auto_encode === null)
		{
			$auto_encode = \Config::get('parser.'.$class.'.auto_encode', null);
		}

		$view = new $class(null, $data, $auto_encode);

		if ($file !== null)
		{
			// Set extension when given
			$extension and $view->extension = $extension;

			// Load the view file
			$view->set_filename($file);
		}

		return $view;
	}
424962
public function create($file = '')
    {
        $this->file   = $file;
        $this->memory = '';
        $this->fh     = 0;

        if ($this->file) {
            // determine compression
            if ($this->comptype == Archive::COMPRESS_AUTO) {
                $this->setCompression($this->complevel, $this->filetype($file));
            }

            if ($this->comptype === Archive::COMPRESS_GZIP) {
                $this->fh = @gzopen($this->file, 'wb'.$this->complevel);
            } elseif ($this->comptype === Archive::COMPRESS_BZIP) {
                $this->fh = @bzopen($this->file, 'w');
            } else {
                $this->fh = @fopen($this->file, 'wb');
            }

            if (!$this->fh) {
                throw new ArchiveIOException('Could not open file for writing: '.$this->file);
            }
        }
        $this->writeaccess = true;
        $this->closed      = false;
    }
824153
public function create($view, $data = [])
    {
        $filename = $this->getFinder()->find($view);

        $mergeMethod = ($data instanceof Data) ? 'addAll' : 'merge';

        $this->getData()->$mergeMethod($data);

        return new View($filename, $this->getData(), new Context($this));
    }
1349581
public function render($file, $data=[])
    {
        \Twig_Autoloader::register();
        $loader = new \Twig_loader_Filesystem($this->themes_dir);
        $twig = new \Twig_Environment(
                    $loader,
                    [
                        'cache' => false, //或者直接指定路径
                        'debug' => false
                    ]
                );
        $template = $twig->loadTemplate($file);
        $html = $template->render($data);
        return $html;
    }
690626
public function render(string $data, string $file = null){
		return $this->initOutputInterface($data)->dump($file);
	}
959173
public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
    {
        // It is possible an array of null data will be passed in. Check for this.
        if (!is_array($data) || !isset($data['file']) || is_null($data['file'])) {
            return;
        }

        $file = $this->getFilePath($data['file']);
        $filesize = (file_exists($file) && is_readable($file)) ? filesize($file) : null;
        $item = new XMLElement($this->get('element_name'));
        $item->setAttributeArray(array(
            'size' =>   !is_null($filesize) ? General::formatFilesize($filesize) : 'unknown',
            'bytes' =>  !is_null($filesize) ? $filesize : 'unknown',
            'path' =>   General::sanitize(
                str_replace(WORKSPACE, null, dirname($file))
            ),
            'type' =>   $data['mimetype']
        ));

        $item->appendChild(new XMLElement('filename', General::sanitize(basename($file))));

        $m = unserialize($data['meta']);

        if (is_array($m) && !empty($m)) {
            $item->appendChild(new XMLElement('meta', null, $m));
        }

        $wrapper->appendChild($item);
    }
842289
public function getView($filename, $data = null)
    {
        // $data = ($data === null) ? $this->_data : $data;
        return $this->getTemplateFile($this->getTemplateFolder().$filename, $data);
    }
703419
public function view($view, array $data = array())
    {
        $this->view = $view;

        $this->viewData = $data;

        return $this;
    }
129712
public function render($file, $data = [])
    {
        $engine = $this->getEngine();

        $path = $this->findFile($file);

        $engine->setLoader($this->getLoader(dirname($path)));

        return $engine->render($file, $data);
    }
897166
public function render($file, $data = [])
    {
        $content = $this->renderContents($file, $data);
        $stream  = $this->response->getBody();
        $stream->rewind();
        $stream->write($content);

        return $this->response;
    }
686180
private function createImagens(string $file, array $data, string $pathFile)
    {
        Helper::createFolderIfNoExist(PATH_HOME . "assetsPublic/img");
        foreach ($data as $datum) {
            if (!empty($datum['imagens']) && !file_exists(PATH_HOME . "assetsPublic/img/{$datum['nome']}")) {
                Helper::createFolderIfNoExist(PATH_HOME . "assetsPublic/img/{$datum['nome']}");
                foreach ($datum['imagens'] as $file) {
                    if (!file_exists(PATH_HOME . "assetsPublic/img/{$datum['nome']}/{$file['name']}"))
                        copy($file['content'], PATH_HOME . "assetsPublic/img/{$datum['nome']}/{$file['name']}");
                }
            }
        }
    }
959615
public function make($file) {
        if (!$file instanceof File && is_file($file)) {
            $file = new File($file);
        }
        if (!$file instanceof File) {
            $file = $this->directory->childFile($this->fileSuffix($file));
        }
        if (!$file->exist()) {
            throw new FileException($file);
        }
        if (!$this->engine instanceof EngineObject) {
            return new View($this, $file);
        }
        /** IF HAS ENGINE*/
        $cacheFile = $this->cache->getCacheFile($file->getFullName());
        if (!$cacheFile->exist() || $cacheFile->modifyTime() < $file->modifyTime()) {
            $this->engine->compile($file, $cacheFile);
        }
        return new View($this, $file, $cacheFile);
    }
914663
static public function load($file, $auto_decrypt=false)
	{
		if (substr(trim($file), -4) !== '.php') {
		    return false;
		}
		
		$fileIdentifier = md5($file);
		if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier]) && file_exists($file)) {
			$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
			
			if (!$auto_decrypt) {
			    return require $file;
			}
			
			$value = file_get_contents($file);
			if (strpos($value, '<') !== false) {
			    $value = require $file;
			} else {
			    $value = Crypt::instance()->decrypt($value);
			    
			    //创建了一个临时文件
			    $handle = tmpfile();
			    
			    //向里面写入了数据
			    $numbytes = fwrite($handle, $value);
			    
			    $value = require stream_get_meta_data($handle)['uri'];
			    
			    //关闭临时文件，文件即被删除
			    fclose($handle);
			}
			
			return $value;
		}
		
		return false;
	}
1141470
public function getModeByFile($file, $extension = null)
    {
        if (!$extension) {
            $extension = strtolower(substr($file, strrpos($file, '.')));
        }
        if (strpos($extension, '.') !== false) {
            if ($extension == '.csv') {
                return DATA_MANIPULATION_CREATE_MODE_CSV;
            }
            if ($extension == '.xls') {
                return DATA_MANIPULATION_CREATE_MODE_XLS;
            }
            if ($extension == '.xlsx') {
                return DATA_MANIPULATION_CREATE_MODE_XLSX;
            }
            if ($extension == '.ods') {
                return DATA_MANIPULATION_CREATE_MODE_ODS;
            }
        }
    }
135440
private function doRender($file, $data)
    {
        $this->view_data               = array_merge($this->view_data, $data);
        if (is_array($file)) {
            foreach($file as $key => $val) {
                $this->section->set($key, $val);
            }
        }
        elseif(!$this->view_file = $this->getPath($file)) {
            return null;
        }
        else {
            $this->setContent($this->renderViewFile());
        }
        if (!isset($this->layout_file)) {
            return $this->section->get('content');
        }
        $layout              = clone($this);
        $layout->layout_file = null;
        return $layout->doRender($this->layout_file, $this->view_data);
    }
194926
public static function get($file, $data = [])
    {
        $path = self::load('views.' . $file);

        extract($data, EXTR_SKIP);

        include $path;
    }
298145
public static function forge($data = array(), $new = true, $view = null, $cache = true)
	{
		return new static($data, $new, $view, $cache);
	}