Beispiel #1
0
 private function _initTemplateEngine()
 {
     if ($this->_engine) {
         return $this->_engine;
     }
     if (\hmvc\Web\Config::get('view.template')) {
         $engine = sprintf("\\hmvc\\Web\\Template\\%s", \hmvc\Web\Config::get('view.template'));
         if (!class_exists($engine)) {
             $engine = "\\hmvc\\Web\\Template\\View";
         }
         $this->_engine = new $engine();
     }
     return $this->_engine;
 }
Beispiel #2
0
Datei: Twig.php Projekt: h1soft/h
 public function __construct()
 {
     $this->setViewPath(\hmvc\Web\Application::themesPath());
     $this->setTheme(\hmvc\Web\Config::get('view.theme'));
     $this->tplFullPath = $this->getViewPath() . \hmvc\Web\Config::get('view.theme', 'default') . '/';
     if (\hmvc\Web\Config::get('view.cache', false) === false) {
         $this->cachePath = false;
     } else {
         $this->cachePath = \hmvc\Web\Application::varPath() . 'cache/';
     }
     if (!isset($this->_loader)) {
         \Twig_Autoloader::register();
         $this->_loader = new \Twig_Loader_Filesystem($this->tplFullPath);
         $this->_twigEnv = new \Twig_Environment($this->_loader, array('cache' => $this->cachePath));
         $this->initFunctions();
     }
 }
Beispiel #3
0
Datei: Db.php Projekt: h1soft/h
 private static function _initConnection($_dbname)
 {
     $dbconf = Config::get("databases.{$_dbname}");
     if ($dbconf && is_array($dbconf) && isset($dbconf['driver'])) {
         switch ($dbconf['driver']) {
             case 'mysqli':
                 self::$_connect_pools[$_dbname] = new \hmvc\Db\Driver\MySQLi($dbconf);
                 break;
             case 'pdo_mysql':
                 break;
             case 'sqlite':
                 break;
             default:
                 return NULL;
                 break;
         }
         return self::$_connect_pools[$_dbname];
     } else {
         return NULL;
     }
 }
Beispiel #4
0
Datei: View.php Projekt: h1soft/h
 public function __construct()
 {
     $this->setTheme(Config::get('view.theme'));
     $this->setViewPath(rootPath() . 'themes/' . $this->getTheme() . '/');
 }
Beispiel #5
0
/**
 * 读取配置文件
 * @param string $_key
 * @param mixed $_default
 * @return null or value
 */
function config($_key, $_default = NULL)
{
    return \hmvc\Web\Config::get($_key, $_default);
}
Beispiel #6
0
 private function _defaultController()
 {
     Application::checkController(\hmvc\Web\Config::get('router.controller'), 'Index');
     Application::checkAction(\hmvc\Web\Config::get('router.action'), 'Index');
 }
Beispiel #7
0
 public static function checkAction($_name)
 {
     if (!self::$_router->getController()) {
         Application::checkController(\hmvc\Web\Config::get('router.controller'), 'Index');
     }
     if (self::$_router->getController() instanceof Controller && method_exists(self::$_router->getController(), $_name . 'Action')) {
         self::$_router->setAction($_name . 'Action');
         return true;
     } else {
         if (self::$_router->getController() instanceof RestController) {
             self::$_router->setAction($_name);
             return true;
         }
     }
     return false;
 }
Beispiel #8
0
 private function _initTemplateEngine()
 {
     if ($this->_engine) {
         return $this->_engine;
     }
     if (\hmvc\Web\Config::get('view.template')) {
         $engine = sprintf("\\hmvc\\Web\\Template\\%s", \hmvc\Web\Config::get('view.template', 'View'));
         if (!class_exists($engine)) {
             throw new \Exception("模版引擎不存在");
         }
         $this->_engine = new $engine();
     }
     return $this->_engine;
 }