Пример #1
0
 /**
  * 初始化smarty
  * 
  */
 private function initSmarty()
 {
     $this->smarty = new Smarty();
     $config = Imp::app()->instance('config')->get();
     // debug关卡
     if ($config['debug']) {
         $this->smarty->debugging = true;
     }
     $this->smarty->debugging = false;
     // 缓存关卡
     $this->smarty->setCaching($config['smarty_config']['cache']);
     // 设置缓存时间
     $this->smarty->cache_lifetime = isset($config['smarty_config']['cache_lifetime']) ? $config['smarty_config']['cache_lifetime'] : 120;
     // 分界符
     $this->smarty->left_delimiter = $config['smarty_config']['left_delimiter'];
     $this->smarty->right_delimiter = $config['smarty_config']['right_delimiter'];
     // 设置配置目录路径,不设默认"configs"
     // $this->smarty->setConfigDir($config['smarty_config']['config_dir']);
     // 设置模板目录路径,不设默认"templates"
     $this->smarty->setTemplateDir(Imp::app()->basePath() . $config['smarty_config']['template_dir']);
     // 设置编译目录路径,不设默认"templates_c"
     $this->smarty->setCompileDir(Imp::app()->basePath() . $config['smarty_config']['compile_dir']);
     // 设置插件目录路径,不设默认"plugins"
     // $this->smarty->setPluginsDir($config['smarty_config']['plugins_dir']);
 }
Пример #2
0
Файл: Mc.php Проект: Rgss/imp
 /**
  * 切换mc节点
  * 
  * @param string $name
  */
 public static function reConnect($name)
 {
     $configs = Imp::app()->instance('config')->get('memcache');
     if (!isset($configs[$name])) {
         die("memcache {$name} 配置错误");
     }
     Mc::getInstance($configs[$name]);
 }
Пример #3
0
Файл: Log.php Проект: Rgss/imp
 /**
  * log路径
  * 
  * @return string
  */
 public static function getPath()
 {
     $path = dirname(Imp::app()->basePath()) . self::LOG_PATH . date('Y') . '/' . date('m') . '/' . date('d') . '/';
     if (!is_dir($path)) {
         @mkdir($path, '0777', true);
     }
     return $path;
 }
Пример #4
0
Файл: Imp.php Проект: Rgss/imp
 /**
  * autoload app file
  *
  */
 public static function loadAppAutoload()
 {
     $files = Imp::app()->instance('config')->get('autoload');
     foreach ((array) $files as $k => $v) {
         foreach ((array) $v as $n) {
             $className = ($k == 'imp' ? 'vendor' : 'app') . '/' . ucfirst($k) . '/' . $n;
             Loader::load($className);
         }
     }
 }
Пример #5
0
 /**
  * 实例 db 对象
  * 
  * @param array $config
  */
 public static function getInstance($config = array())
 {
     if (empty($config)) {
         $configs = Imp::app()->instance('config')->get('database');
         $config = $configs['default'];
     }
     // 当前db id
     $dbID = md5($config['host'] . $config['port'] . $config['dbname']);
     if (!isset(self::$instances[$dbID])) {
         // 加载数据库驱动类
         $class = ucfirst($config['type']);
         $driveFile = 'vendor/Imp/Database/' . $class . '/' . $class;
         Loader::load($driveFile);
         // 实例化数据库
         $class = strtolower($class) == 'mysqli' ? 'Mysql' : $class;
         self::$instances[$dbID] = new $class($config);
     }
     return self::$instance = self::$instances[$dbID];
 }
Пример #6
0
 /**
  * 启动系统
  * 
  */
 public function run()
 {
     Imp::loadAppAutoload();
     // register request
     $this->register('request', new Request());
     // register respone
     $this->register('response', new Response());
     // register hook
     $this->register('hook', new Hook());
     // register event
     // $this->register('event', new Event);
     // register router
     $this->register('router', new Router());
     // register mvc
     $this->register('mvcBuilder', new MvcBuilder($this->basePath));
     // start start-hook
     Imp::app()->instance('hook')->call('start');
     // 初始化
     $this->init();
 }
Пример #7
0
 /**
  * 设置参数
  *
  */
 public function setParams()
 {
     $this->params = Imp::app()->instance('router')->getParams();
 }
Пример #8
0
 /**
  * model文件后缀
  *
  */
 public function getFileSubfix()
 {
     return Imp::app()->instance('config')->get('model_file_subfix');
 }
Пример #9
0
 /**
  * 指定视图文件
  *
  * @param string $file
  */
 public function getRenderFile($file = null)
 {
     $file = str_replace(array('.', '#'), array('/', '.'), $file);
     if (false === strpos($file, '/')) {
         $file = $this->path . ucfirst($file) . '.php';
     } else {
         $file = Imp::app()->basePath() . 'Views' . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $file) . '.php';
     }
     return $file;
 }
Пример #10
0
 /**
  * 注册视图
  * 
  */
 private function registerView()
 {
     Imp::app()->instance('event')->call(Imp::app()->instance('mvcBuilder'), 'registerViewBuilder', array());
     Imp::app()->instance('event')->call(Imp::app()->instance('mvcBuilder')->mvc(), 'register', array('view', new View()));
     $this->view = Imp::app()->instance('mvcBuilder')->mvc()->view();
 }
Пример #11
0
Файл: View.php Проект: Rgss/imp
 /**
  * 展现系统页面
  * 
  * @param string $file
  * @param array $data
  */
 public static function showPage($file, $data = array())
 {
     $file = Imp::app()->instance('mvcBuilder')->mvc()->view()->getRenderFile($file);
     if (!empty($file) && is_array($data)) {
         extract($data);
     }
     require $file;
     die;
 }
Пример #12
0
 /**
  * 注册mvc
  * 
  * @param string $path
  */
 public function registerMvc($path)
 {
     $hmvc = Imp::app()->instance('config')->get('hmvc');
     if (!empty($hmvc)) {
         Loader::load('vendor/Imp/Mvc/HMvc');
         $class = 'HMvc';
     } else {
         Loader::load('vendor/Imp/Mvc/CMvc');
         $class = 'CMvc';
     }
     $this->mvc = new $class($path);
 }
Пример #13
0
<?php

/**
 * 系统启动程序入口
 *
 * @package Imp
 * @author 		Imp <*****@*****.**>
 * @copyright 	2015-2016 Imp All rights reserved.
 * @version 	1.0
 * @link
 */
!defined(APP_PATH) or die('undefine APP_PATH');
!defined(IMP_PATH) or die('undefine IMP_PATH');
!defined(ROOT_PATH) or die('undefine ROOT_PATH');
// 系统跟踪信息
$GLOBALS['_TRACE']['beginTime'] = microtime(true);
ob_start();
require __DIR__ . DIRECTORY_SEPARATOR . '../Imp.php';
// 添加时间跟踪器
//Tracer::time('start');
// 应用配置
$config = (require APP_PATH . 'Configs/Config.php');
// 创建应用
$app = Imp::createWebApplication($config, dirbane(__DIR__));
// 添加时间跟踪器
Tracer::time('end_create_app');
return $app;
// 注册自动装载方法
// spl_autoload_register(array('Imp', 'autoload'));
Пример #14
0
 /**
  * load model
  * 
  * @param string $name
  */
 public static function model($name)
 {
     // package to path
     $name = str_replace('.', DIRECTORY_SEPARATOR, $name);
     return self::load('app/Models/' . $name . Imp::app()->instance('config')->get('model_file_subfix'));
 }
Пример #15
0
Файл: Hook.php Проект: Rgss/imp
 /**
  * __construct
  * 
  */
 public function __construct()
 {
     $this->hooks = Imp::app()->instance('config')->get('hooks');
 }
Пример #16
0
 /**
  * return database config
  * 
  * @param string $name
  */
 public static function getConfig($name = null)
 {
     if (self::$configs === null) {
         self::$configs = Imp::app()->instance('config')->get('database');
     }
     if ($name == null) {
         $name = 'default';
     }
     return isset(self::$configs[$name]) ? self::$configs[$name] : false;
 }
Пример #17
0
<?php

/**
 * 系统启动程序入口
 *
 * @package Imp
 * @author 		Imp <*****@*****.**>
 * @copyright 	2015-2016 Imp All rights reserved.
 * @version 	1.0
 * @link
 */
/**
 * 载系统启动程序
 * 
 */
require dirname(dirname(__FILE__)) . '/../vendor/Imp/Autoloader.php';
/**
 * 创建应用
 * 
 */
$app = Imp::createWebApplication(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
/**
 * 添加时间跟踪器
 * 
 */
//Tracer::time('end_create_app');
/**
 * return $app
 */
return $app;
Пример #18
0
<?php

/**
 * 系统启动程序入口
 *
 * @package Imp
 * @author 		Imp <*****@*****.**>
 * @copyright 	2015-2016 Imp All rights reserved.
 * @version 	1.0
 * @link
 */
/**
 * 载系统启动程序
 * 
 */
require dirname(__FILE__) . '/Imp.php';
require dirname(__FILE__) . '/Core/Loader.php';
Loader::load('app/Helpers/tools');
tools::markTime();
/**
 * autoload register
 * 
 */
//spl_autoload_register(['Imp', 'autoload'], true, true);
/**
 * load system core file
 *
 */
$classMap = (require dirname(__FILE__) . '/Classes.php');
Imp::loadSystemFile($classMap);
Пример #19
0
 function instance($name)
 {
     return Imp::app()->instance($name);
 }
Пример #20
0
 public function __construct()
 {
     $this->param = Imp::app()->instance('param');
 }
Пример #21
0
 /**
  * 得路由配置
  *
  * @param string $name 名称,如果名称为空则返回所有路由配置
  * @return array
  */
 public static function get($name = '')
 {
     return Imp::app()->instance('router')->getRouter($name);
 }
Пример #22
0
Файл: CMvc.php Проект: Rgss/imp
 /**
  * 视图目录
  *
  * @return string
  */
 public function viewPath()
 {
     $controller = ucfirst(Imp::app()->instance('router')->getController());
     return $this->path . 'Views' . DIRECTORY_SEPARATOR . $controller . DIRECTORY_SEPARATOR;
 }
Пример #23
0
Файл: DB.php Проект: Rgss/imp
 /**
  * db config
  * 
  * @param unknown $dbName
  */
 public static function getConfig($dbName)
 {
     if (empty(self::$configs)) {
         self::$configs = Imp::app()->instance('config')->get('database');
     }
     return !isset(self::$configs[$dbName]) ? self::$configs['default'] : self::$configs[$dbName];
 }