绘制

@return string
170039
public function render() {
        if (extension_loaded('xml')) {
            $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><' . $this->root . '/>');
            $this->addNode($xml, $this->data);

            return $xml->asXML();
        } else {
            return '<?xml version="1.0" encoding="UTF-8"><error>xml extension is not installed</error>';
        }
    }
992948
public static function getRoute() {
        //获取请求URL
        $requestUrlArr = self::getRouteArray();

        //处理请求URL
        if (count($requestUrlArr) == 1) {//dev.example.com/aaa
            $data = array(array(
                    'act' => !empty($requestUrlArr[0]) ? $requestUrlArr[0] : 'index',
                    'op' => 'actionIndex',
                    'namespace' => ''
            ));
        } elseif (count($requestUrlArr) >= 2) {//dev.example.com/aaa/bbb //dev.example.com/aaa/bbb/index
            $origRequestUrlArr = $requestUrlArr;
            $lastParam = array_pop($requestUrlArr);
            if ($lastParam == 'index') {
                $data = array(array(
                        'act' => array_pop($requestUrlArr),
                        'op' => 'actionIndex',
                        'namespace' => implode('/', $requestUrlArr)
                ));
            } else {
                $data = array(
                    array(
                        'act' => array_pop($origRequestUrlArr),
                        'op' => 'actionIndex',
                        'namespace' => implode('/', $origRequestUrlArr),
                    ),
                    array(
                        'act' => array_pop($requestUrlArr),
                        'op' => 'action' . ucfirst($lastParam),
                        'namespace' => implode('/', $requestUrlArr),
                    )
                );
            }
        }

        return $data;
    }
1116922
public function result()
    {
        $string = "";
        while ($this->count > 0) {
            $string .= $this->util->cursor->startOfCurrentLine();
            $string .= $this->util->cursor->deleteCurrentLine();
            --$this->count;

            $string .= $this->util->cursor->up();
        }

        $string .= $this->util->cursor->down();

        return $string;
    }
327654
protected function getSelectString(): string
    {
        $statement = '';
        $fieldSelect    = $this->builder->getSelect();
        $aggregate = $this->builder->getAggregate();
        if (empty($fieldSelect) && empty($aggregate)) {
            return $statement;
        }

        $select = $this->getAggregateStatement($fieldSelect, $aggregate);

        // 字段组拼
        foreach ($select as $column => $alias) {
            // Filter db keyword
            if (array_key_exists($column, $fieldSelect) && trim($column) != '*' && strpos($column, '.') === false) {
                // 判断是否为函数调用
                if (strpos($column, '(') || strpos($column, ')')) {
                    $column = sprintf('%s', $column);
                } else {
                    $column = sprintf('`%s`', $column);
                }
            }

            $statement .= $column;
            if ($alias !== null) {
                $statement .= sprintf(' AS `%s`', $alias);
            }
            $statement .= ', ';
        }

        //select组拼
        $statement = substr($statement, 0, -2);
        if (!empty($statement)) {
            $statement = 'SELECT ' . $statement;
        }

        return $statement;
    }
477446
public function getNotify()
    {
        $data = Tools::xml2arr(file_get_contents("php://input"));
        if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS') {
            throw new InvalidResponseException('获取退款通知XML失败！');
        }
        if (!class_exists('Prpcrypt', false)) {
            include dirname(__DIR__) . '/WeChat/Contracts/Prpcrypt.php';
        }
        $pc = new \Prpcrypt(md5($this->config->get('mch_key')));
        $array = $pc->decrypt(base64_decode($data['req_info']));
        if (intval($array[0]) > 0) {
            throw new InvalidResponseException($array[1], $array[0]);
        }
        $data['decode'] = $array[1];
        return $data;
    }
1330204
protected function getMergedContent(): string
    {
        $content = $this->getTemplateSource();
        // 处理include合并
        // /
        // /{include mobile/header}
        // /
        $this->processIncludeTag($content);
        // 处理动态包含
        // /
        // /{template mobile/header}
        // /
        $this->processDynamicTag($content);
        // 处理扩展
        if ($this->hasExtendRule()) {
            $this->extendTemplate($content);
        }
        // 处理变量输出
        // /
        // /{$a}
        // /
        $this->processVars($content);
        // 处理变量输出(过滤特殊符号)
        // /
        // /{text $a}
        // /
        $this->processTextVars($content);
        // /处理url标签
        // /
        // /{url image}path/to/image.png{/url}
        // /
        $this->processUrlTag($content);
        // 处理php标签
        // /
        // /{php}echo hello world;{/php}
        // /
        $this->processPhpTag($content);
        // 处理block
        $this->processBlocks($content);
        // 处理注释
        // /
        // /{info this is a comment}
        // /
        $this->processComment($content);
        // 处理if标签
        // /
        // /{if true}
        // /
        $this->processIfCondition($content);
        // 处理elseif标签
        // /
        // /{elseif true}
        // /
        $this->processElseifCondition($content);
        // 处理else标签
        // /
        // /{else}
        // /
        $this->processElseCondition($content);
        // 处理条件结束标签
        // /
        // /{/if}
        // /
        // /
        // /{/loop}
        // /
        $this->processEndCondition($content);
        // 处理loop循环标签
        // /
        // /{loop $arr $val}
        // /
        // /
        // /{loop $arr $key $val}
        // /
        $this->processLoop($content);
        // 编译时间记录
        // /
        // /{build_time}
        // /
        $this->processBuildTime($content);
        // 处理不转换的标签
        // /
        // /{!}{$val}
        // /
        $this->processNoConvert($content);
        // /合并PHP标签
        $this->mergePhpContent($content);
        return $content;
    }
261296
public function auth(){
        $uid                = self::sessionGet('user.uid');
        $controller         = Loader::parseName($this->controller,1); //字符串命名风格转换
        $rule               = strtolower("{$this->module}/{$controller}/{$this->action}");
        //如果用户角色是1，则无需判断
        if(empty($uid)){
            return false;
        }
        if($uid == 1){
            self::actionLog($rule);
            return true;
        }
        //无需认证
        $noNeedCheckRules   = array_merge($this->noNeedCheckRules,[$this->module.'/auth/openfile',$this->module.'/auth/cache']);
        if( !in_array($rule,$noNeedCheckRules) ){
            return self::authCheck($rule,'or');
        }else{
            return true;
        }

    }
1361919
private function _get_table_name()
    {
        if ($this->table_name == '') {
            // 如果是在实例化后使用，则使用当前模型名称
            $current_class = get_class($this);
            if ($current_class != 'model') {
                $this->table_name = strtolower(substr($current_class, strrpos($current_class, '\\')+1, -5));

                // 如果设置了表前缀
                if (true == ($tb_prefix = Config::get('dbconfig.'.$this->db_config_name . '.tb_prefix'))) {
                    $this->table_name = $tb_prefix . $this->table_name;
                }
            } else {
                throw_error('Tablename cannot automatically infer.');
            }
        }

        return $this->table_name;
    }
12771
private function get_token(){

        if(self::$token==null){
            $config = $this->get_config();
            $file = $config['TOKEN_PATH'];
            if( Storage::disk()->exists($file) && TIMESTAMP - ( $createTime = Storage::disk()->lastModified($file) ) <= 7200 ){
                $token = Storage::disk()->get($file);
                self::$token = json_encode(array(
                    'token'=>$token,
                    'createtime'=>$createTime
                ));
                return $token;
            }
        }else{
            $token = json_decode(self::$token,true);
            if($token['createtime'] + 7200 > TIMESTAMP){
                return $token['token'];
            }
        }

        //返回远程token
        return $this->get_remote_token();
    }
1245007
public function toString()
    {
        $metaString = '#';

        $metaString .= $this->fields['MetaName'];

        if (!empty($this->fields['MetaValue']))
            $metaString .= '="'. $this->fields['MetaValue'] .'"';

        return $metaString;
    }
682898
public function getPathinfo()
    {
        //pathinfo已经被重写过
        if ($this->_pathinfo !== null) {
            return $this->_pathinfo;
        }
        $pathinfo = $this->get('PATH_INFO');
        if (!$pathinfo) {
            //兼容模式
            $vitex = Vitex::getInstance();
            if ($vitex->getConfig('router.compatible')) {
                $pathinfo = isset($_GET['u']) ? $_GET['u'] : '';
            }
        }
        return $pathinfo;
    }
1087502
public function lBrackets()
    {
        if ($this->sql['where'] == '') {
            $this->sql['where'] = 'WHERE ';
        } else {
            if ($this->whereNeedAddAndOrOr === 1) {
                $this->sql['where'] .= ' AND ';
            } else if ($this->whereNeedAddAndOrOr === 2) {
                $this->sql['where'] .= ' OR ';
            }
        }
        $this->sql['where'] .= ' (';
        //移除下一次where操作默认加上AND
        $this->whereNeedAddAndOrOr = 0;
        return $this;
    }
1018369
protected function getAllHeaders() {
        if (function_exists('getallheaders')) {
            return getallheaders();
        }

        //对没有getallheaders函数做处理
        $headers = array();
        foreach ($_SERVER as $name => $value) {
            if (is_array($value) || substr($name, 0, 5) != 'HTTP_') {
                continue;
            }

            $key = $this->formatHeaderKey($name);
            $headers[$key] = $value;
        }

        return $headers;
    }
874786
public function selected()
    {
        // 请求参数
        $param['__EVENTTARGET'] = '';
        $param['__EVENTARGUMENT'] = '';
        $param['__VIEWSTATE'] = true;
        $param['zymc'] = "";
        $param['xx'] = "";
        $param['Button8'] = iconv('utf-8', 'gb2312', '已选课程');

        $header = [
            'code', 'name', 'property', 'direction', 'credit', 'hour', 'exam_time', '', 'status'
        ];

        return $this->getSelect($param, $param, $header, 10);
    }
603938
public function parseURL() {

        $appConfigs = getConfigs(); //获取app配置

        self::$urlMappingRules = $appConfigs['url_mapping_rules'];
        //优先处理短链接映射
        $this->requestUri = self::url2source($this->requestUri);
        $_SERVER['REQUEST_URI'] = $this->requestUri;

        $defaultUrl = $appConfigs['default_url'];
        $urlInfo = parse_url($this->requestUri);

        if ( $urlInfo['path'] && $urlInfo['path'] != '/' ) {
            $filename = str_replace(EXT_URI, '', $urlInfo['path']);
            $filename = rtrim($filename, "/");
            $pathInfo = explode('/', $filename);
            array_shift($pathInfo);
            if ( $pathInfo[0] ) $this->setModule($pathInfo[0]);
            if ( $pathInfo[1] ) $this->setAction($pathInfo[1]);
            if ( $pathInfo[2] ) $this->setMethod($pathInfo[2]);

            //提取pathinfo参数
            if ( count($pathInfo) > 3 ) {
                if ( isset($pathInfo[3]) ) {
                    $params = explode('-', $pathInfo[3]);
                    for ( $i = 0; $i < count($params); $i++ ) {
                        if ( $i % 2 == 0 ) {
                            if ( trim($params[$i]) == '' ) {
                                continue;
                            }
                            $_GET[$params[$i]] = $params[$i+1];
                        }
                    }
                }
            }

            //提取query参数
            if ( isset($urlInfo['query']) ) {
                $params = explode('&', $urlInfo['query']);
                foreach ( $params as $values ) {
                    $__p = explode('=', $values);
                    if ( trim($__p[0]) == '' ) {
                        continue;
                    }
                    $_GET[$__p[0]] = urldecode($__p[1]);
                }
            }

        }

        //如果没有任何参数，则访问默认页面。如http://www.herosphp.my这种格式
        if ( !$this->module ) $this->setModule($defaultUrl['module']);
        if ( !$this->action ) $this->setAction($defaultUrl['action']);
        if ( !$this->method ) $this->setMethod($defaultUrl['method']);

        $this->setParameters($_GET + $_POST);

        //die();
    }
1002327
public function render(){
        //获取组件的class
        $class = self::getClass(self::$set['component_name']);
        //获取组件的属性
        $component_attr = $class::attr();
        //外部调用设定代替默认值
        //赋值一个id的属性
        self::$set['id'] = self::$uniqid_id;

        $class::$attr = array_merge($component_attr ,self::$set);


        if(isset($component_attr['layFilter'])){ //如果组件有这个属性 ，但却没有设置，则默认 是 uniqid_id
            $class::$attr['layFilter'] = ( !isset(self::$set['layFilter']) )  ? self::$uniqid_id  : self::$set['layFilter'];
        }

        //记录当前页面使用了哪些组件
        array_push(self::$components ,[
            'component_name' => self::$set['component_name'] ,
            'uniqid_id' => self::$uniqid_id,
            'set' => $class::$attr
        ]);

        $dom = $class::dom();

        //销毁静态变量 保留了 self::$components 用于 调用组件的js
        self::$set = $class::$attr = $class::$id = null;

        return $dom;
    }
32836
public function getFieldInfo() {
        $name = C('sql', "table") . '.' . $this->table;
        $sql  = "Select COLUMN_NAME ub_field, DATA_TYPE ub_type, COLUMN_COMMENT ub_explain
from INFORMATION_SCHEMA.COLUMNS
Where table_name = '" . $this->table . "' # #表名
AND table_schema = '" . C('sql', "table") . "' # #数据库名";
        if (!$result = $this->query($sql)) {
            return FALSE;
        }
        $data = [];
        foreach ($result as $key => $res) {
            $data[$key]['field']   = $res['ub_field'];
            $data[$key]['type']    = $res['ub_type'];
            $data[$key]['explain'] = empty($res['ub_explain']) ? "-" : $res['ub_explain'];
        }
        return $data;
    }