路由反解析函数

@param string $name 路由配置表名称
@param array $value 路由填充值
@param string $prefix 最终合成路径的前缀
@return string
5696
public function url($name, array $value = NULL, $prefix = NULL) {
        $route = $this->routingTable[$name];

        if(!$route) {
            return '';
        }
        //交换数组键值
        $pattern = [];
        foreach ($route['params'] as $row) {
            $pattern[$row] = isset($value[$row]) ? $value[$row] : '{' . $row . '}';
        }

        $path = vsprintf($route['format'], $pattern);
        if($prefix) {
            $path = (0 === strpos($path, './')) ? substr($path, 2) : $path;
            return rtrim($prefix, '/') . '/' . str_replace('//', '/', ltrim($path, '/'));
        }
        return $path;
    }
1096748
public function getPrefixString($array, $prefix)
    {
        $items = array();

        if(!empty($array)){
            foreach($array as $item){
                preg_match('/'.$prefix.'(.*)/', $item, $results);
                if(isset($results[1])){
                    $items[] = $results[1];
                }
            }
        }

        return $items;
    }
230724
public function hasPrefix($prefix_value){
        $clientPrefixes = ClientPrefixes::where("client_id", $this->client_id)->get();
        foreach ($clientPrefixes as $clientPrefix) {
            if($prefix_value ==  $clientPrefix->prefix->prefix_value)
                return true;
        }
        return false;
    }
586983
public function bindParams($name, $value=null) {
        
        if (is_array($name)) {
            foreach ($name as $k=>$v) {
                $this->binds[':'.$k]  =   $v;
            }
        } elseif ($value) {
            $this->binds[':'.$name] = $value;
        }
        
        return $this;
    }
767180
public function value( $name, $value = null )
    {
        if ( is_array( $name ) ) {
            $this->values += $name;
        } elseif ( func_num_args() > 1 ) {
            $this->values[ $name ] = $value;
        }
        return $this;
    }
332994
public static function _realName($name,$prefix=null){
		$name = preg_replace('/^'.$prefix.'/','',$name);
		$name = preg_replace('/([A-Z]{1})/','_$1',$name);
		$name = strtolower($name);
		$name = trim($name,'_');
		return $name;
	}
1086652
private static function handleConfigNamespace(&$namespace, $prefix)
    {
        if ($prefix == "" && $namespace == "") {
            $namespace = "App\\Controllers";
            return;
        }

        if ($namespace == "") {
            $file = empty(self::$router_file) ? 'app/routers.php' : str_replace(['/', '\\'], DIRECTORY_SEPARATOR, self::$router_file);
            throw new \ErrorException("{$file}路由文件有错误！当指定路由前缀或模块化开发时，'namespace'不能为空");
        }
    }
391185
public function set($name, $value, $expire = null) {
        if (is_null($expire)) {
            $expire = $this->options['expire'];
        }
        //$key = $name;
        //对数组/对象数据进行缓存处理，保证数据完整性
        $value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
        if (is_int($expire) && $expire) {
            $result = $this->handler->setex($name, $expire, $value);
        }
        else {
            $result = $this->handler->set($name, $value);
        }
        return $result;
    }
302742
public function addPrefix($values, $prefix)
    {
        $new_values = array();
        foreach ($values as $s) {
            $new_values[] = $prefix . $s;
        }

        return $new_values;
    }
1004874
public function getNamePrefix($value)
    {
        if (empty($value)) {
            return null;
        }
        preg_match('/(?:\@(?P<prefix>INLINE))?(?P<value>.+)/is', $value, $matches);

        return [
            'prefix' => Helper::getValue($matches['prefix']),
            'value' => Helper::getValue($matches['value'])
        ];
    }
556072
private function _merge($name, $value)
    {
        if (is_array($name)) {
            $config = $this->_get($name);
            if (is_array($config)) {
                $value = ArrayHelper::merge($config, $value);
            }
        }
        return $value;
    }
866549
public function set($name, $value,$expire=null) {
        $data   =  serialize($value);
        $name   =  $this->options['prefix'].addslashes($name);
        N('cache_write',1);
        if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
            //数据压缩
            $data   =   gzcompress($data,3);
        }
        if(C('DATA_CACHE_CHECK')) {//开启数据校验
            $crc  =  md5($data);
        }else {
            $crc  =  '';
        }
        if(is_null($expire)) {
            $expire  =  $this->options['expire'];
        }
        $expire	    =   ($expire==0)?0: (time()+$expire) ;//缓存有效期为0表示永久缓存
        $result     =   $this->handler->query('select `cachekey` from `'.$this->options['table'].'` where `cachekey`=\''.$name.'\' limit 0,1');
        if(!empty($result) ) {
        	//更新记录
            $result  =  $this->handler->execute('UPDATE '.$this->options['table'].' SET data=\''.$data.'\' ,datacrc=\''.$crc.'\',expire='.$expire.' WHERE `cachekey`=\''.$name.'\'');
        }else {
        	//新增记录
             $result  =  $this->handler->execute('INSERT INTO '.$this->options['table'].' (`cachekey`,`data`,`datacrc`,`expire`) VALUES (\''.$name.'\',\''.$data.'\',\''.$crc.'\','.$expire.')');
        }
        if($result) {
            if($this->options['length']>0) {
                // 记录缓存队列
                $this->queue($name);
            }
            return true;
        }else {
            return false;
        }
    }
463062
static public function ueditor($name, $value=null, $settings=array())
    {
        if (empty($value)) {
            $value = "编辑内容";
        }
        
        $defultSettings = array(
            'width'     => "100%",
            'height'    => "400",
            'type'      => "simple",
            'js_mode'   => false
        );
        $settings = array_merge($defultSettings, $settings);
        
        $pluginFile = rtrim(Config::getWebRootPath(), '/') . '/lib/ueditor-1.4.3/use/ueditor.php';
        require_once($pluginFile);
        $UEditor = new \UEditor();
        $UEditor->basePath = Config::getRootUrl() . '/lib/ueditor-1.4.3/';
        
        $config = $events = array();
        if (isset($GLOBALS['editor_toolbar'])) {
            $config['toolbars'] = $GLOBALS['editor_toolbar'][$settings['type']];
        }
        $config['minFrameHeight']       = $settings['height'];
        $config['initialFrameHeight']   = $settings['height'];
        $config['initialFrameWidth']    = $settings['width'];
        $config['autoHeightEnabled']    = false;
        
        if (!$settings['js_mode']) {
            $code = $UEditor->editor($name, $value, $config, $events);
        } else {
            $code = $UEditor->jseditor($name, $value, $config, $events);
        }
        return $code;
    }
33987
public function get($name) {
        N('cache_read',1);
        $value = $this->handler->get($this->options['prefix'].$name);
        $jsonData  = json_decode( $value, true );
        return ($jsonData === NULL) ? $value : $jsonData;	//检测是否为JSON数据 true 返回JSON解析数组, false返回源数据
    }
631786
public static function values($array, $prefix = null)
    {
        $values = array_values($array);

        if (! empty($prefix)) {
            $values = static::prefix($values, $prefix);
        }

        return $values;
    }
284473
public static function set($name, $value, $expired = null)
    {
        // 处理过期时间
        if (null === $expired)
        {
            $expired = Cookie::$expiration;
        }
        if ($expired !== 0)
        {
            $expired += time();
        }

        // Add the salt to the cookie value
        $value = Cookie::salt($name, $value) . '~' . $value;

        return Base::getHttp()->setCookie($name, $value, $expired, Cookie::$path, Cookie::$domain, Cookie::$secure, Cookie::$httpOnly);
    }
738938
public static function value($alias,$value=''){
        if (isset(self::$pool[$alias])) {
            return self::$pool[$alias];
        }
        //value('name','hello',function ($hello){});
        //value('name',function (){});
        //value('name',new Hook());
        //value('name',2);
        //value('name',[]);
        //获取参数数量
        $num = func_num_args();

        if($num<3) {
            $value = ($value instanceof \Closure)?$value():$value;
        }
        elseif($num == 3) {
            $func = func_get_arg(2);
            $value = $func($value);
        }
        else {
            $args = func_get_args();
            $alias = $args[0];
            $value = $args[--$num];
            unset($args[0]);
            unset($args[$num]);
            $value = call_user_func_array($value,$args);
        }

        //固化
        if(in_array($alias,Config::$o->pool)) {
            self::$solidify[$alias] = $value;
        }

        return self::$pool[$alias] = $value;
    }