Exemplo n.º 1
0
 /**
  * 插件配置初始化
  * @return bool
  * @throws Typecho_Plugin_Exception
  */
 public static function init()
 {
     if (is_null(self::$sys_config)) {
         self::$sys_config = Helper::options();
     }
     if (is_null(self::$plugin_config)) {
         self::$plugin_config = self::$sys_config->plugin('TpCache');
     }
     if (self::$plugin_config->cache_driver == '0') {
         return false;
     }
     if (is_null(self::$cache)) {
         $driver_name = self::$plugin_config->cache_driver;
         $class_name = "typecho_{$driver_name}";
         $file_path = "driver/{$class_name}.class.php";
         require_once 'driver/cache.interface.php';
         require_once $file_path;
         self::$cache = call_user_func(array($class_name, 'getInstance'), self::$plugin_config);
     }
     if (is_null(self::$request)) {
         self::$request = new Typecho_Request();
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * 插件配置初始化
  * @param $pathInfo
  * @return bool
  * @throws Typecho_Plugin_Exception
  */
 public static function init($pathInfo = '')
 {
     if (is_null(self::$sys_config)) {
         self::$sys_config = Helper::options();
     }
     if (is_null(self::$plugin_config)) {
         self::$plugin_config = self::$sys_config->plugin('TpCache');
     }
     if (self::$plugin_config->cache_driver == '0') {
         return false;
     }
     if (empty($pathInfo)) {
         if (is_null(self::$request)) {
             self::$request = new Typecho_Request();
         }
         //获取路径信息
         $pathInfo = self::$request->getPathInfo();
         //判断是否需要缓存
         if (!self::needCache($pathInfo)) {
             return false;
         }
     } else {
         if (!self::needCache($pathInfo)) {
             return false;
         }
     }
     self::init_driver();
     return true;
 }