Exemplo n.º 1
0
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     // 编辑员工
     $dispatcher->getRouter()->addRoute('staffUpdateRewrite', new Yaf_Route_Rewrite('/admin/staff/update/:userId', array('module' => 'admin', 'controller' => 'staff', 'action' => 'update')));
     // 删除员工
     $dispatcher->getRouter()->addRoute('staffDeleteRewrite', new Yaf_Route_Rewrite('/admin/staff/delete/:userId', array('module' => 'admin', 'controller' => 'staff', 'action' => 'delete')));
 }
Exemplo n.º 2
0
 /**
  * 
  * @param \Yaf_Dispatcher $dispatcher
  * @param  string $jqueryVer 使用的jquery文件,默认值:jquery-1.11.2.min.js
  * @return view
  */
 public static function initYafBySooh($dispatcher, $jqueryVer = 'jquery-1.11.2.min.js')
 {
     $router = $dispatcher->getRouter();
     $router->addRoute("byVar", new \Yaf_Route_Supervar(SOOH_ROUTE_VAR));
     \Yaf_Loader::getInstance()->registerLocalNameSpace($GLOBALS['CONF']['localLibs']);
     $req = $dispatcher->getRequest();
     $tmp = $req->get('__ONLY__');
     if ($tmp == 'body') {
         \SoohYaf\Viewext::$bodyonly = true;
     }
     $tmp = trim($req->get('__VIEW__'));
     //html(default),wap,  json
     define('VIW_INC_PATH', APP_PATH . '/application/views/_inc/');
     \SoohYaf\Viewext::$jqueryVer = $jqueryVer;
     if (!empty($tmp)) {
         $tmp = strtolower($tmp);
         \Sooh\Base\Ini::getInstance()->viewRenderType($tmp);
         if ($tmp == 'jsonp') {
             \Sooh\Base\Ini::getInstance()->initGobal(array('nameJsonP' => $req->get('jsonp', 'jsonp')));
         }
     }
     //		$tmp = $dispatcher->getRequest()->get('__GZIP__');
     //		if(!empty($tmp)){
     //			$tmp = strtolower ($tmp);
     //			if($tmp=='gzip')define("ZIP_OUTPUT",$tmp);
     //		}
     $view = new \SoohYaf\Viewext(null);
     $dispatcher->setView($view);
     $dispatcher->registerPlugin(new SoohPlugin());
     return $view;
 }
Exemplo n.º 3
0
 /**
  * [路由设置]
  */
 public function _initRoutes(Yaf_Dispatcher $dispatcher)
 {
     $router = $dispatcher->getRouter();
     //$router->addConfig(Yaf_Registry::get('config')->routes);
     Yaf_Loader::import(APP_CONFIG . '/route.php');
     $router->addConfig($routeConfigs);
 }
Exemplo n.º 4
0
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     $routes = $this->config->routes;
     if (!empty($routes)) {
         $router = $dispatcher->getRouter();
         $router->addConfig($routes);
     }
 }
Exemplo n.º 5
0
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     //在这里注册自己的路由协议,默认使用简单路由
     $fileName = APPLICATION_PATH . "/conf/routes.ini";
     if (file_exists($fileName)) {
         $config = new Yaf_Config_Ini($fileName);
         $dispatcher->getRouter()->addConfig($config->routes);
     }
 }
Exemplo n.º 6
0
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     //在这里注册自己的路由协议,默认使用简单路由
     $router = $dispatcher->getRouter();
     //创建一个路由协议实例
     $router->addRoute('index', new Yaf_Route_Regex('#^/$#', array('controller' => 'index', 'action' => 'index')));
     $router->addRoute('country', new Yaf_Route_Rewrite('route/:country', array('controller' => 'router', 'action' => 'country')));
     $router->addRoute('province', new Yaf_Route_Rewrite('route/:country/:province', array('controller' => 'router', 'action' => 'province')));
     $router->addRoute('city', new Yaf_Route_Rewrite('route/:country/:province/:city', array('controller' => 'router', 'action' => 'city')));
 }
Exemplo n.º 7
0
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     $router = $dispatcher->getRouter();
     //$router->addConfig(Yaf_Registry::get("config")->routes);
     //$route = new Yaf_Route_Rewrite(
     //	'exp/:ident',
     //	array(
     //		'controller' =>'index',
     //		'action' => 'index'
     //	)
     //);
     //$router -> addRoute('exp',$route);
     $route = new Yaf_Route_Rewrite('/admin/:action/:id', array('controller' => 'admin', 'action' => ':action'));
     $router->addRoute('name', $route);
 }
Exemplo n.º 8
0
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     $router = $dispatcher->getRouter();
     $router->addRoute("userlogin", new Yaf_Route_rewrite("/user/login", array('module' => 'user', 'controller' => "index", 'action' => "login")));
 }
Exemplo n.º 9
0
 /**
  * 开启调试输出
  * @method _initRoute
  * @author NewFuture
  */
 public function _initRoute(Yaf_Dispatcher $dispatcher)
 {
     $dispatcher->getRouter()->addConfig(Config::get('routes'));
 }
Exemplo n.º 10
0
 function _initBase(Yaf_Dispatcher $dispatcher)
 {
     // 如果非命令行,则输出 header 头
     if (!core::is_cmd()) {
         header("Expires: 0");
         header("Cache-Control: private, post-check=0, pre-check=0, max-age=0");
         header("Pragma: no-cache");
         header('Content-Type: text/html; charset=UTF-8');
         header('X-Powered-By: http://www.lianchuangbrothers.com/');
         // 隐藏 PHP 版本 X-Powered-By: PHP/5.5.9
         header('Server: Microsoft-IIS/11.11');
     }
     //错误处理
     $dispatcher->setErrorHandler([get_class($this), 'error_handler']);
     //添加路由协议
     $dispatcher->getRouter()->addConfig((new Yaf_Config_Ini(APP_PATH . '/conf/routes.ini'))->routes);
     //注册本地类
     Yaf_Loader::getInstance()->registerLocalNameSpace(['helper', 'misc']);
     // 加载数据库
     Yaf_Registry::set('db', new medoo(Yaf_Registry::get("config")->get('database')->default->toArray()));
     //memcache
     //Yaf_Registry::set('memcache', new Memcache);
     //Yaf_Registry::get('memcache')->pconnect(Yaf_Registry::get("config")->get('memcache')->default->host, Yaf_Registry::get("config")->get('memcache')->default->port, 2.5);
     //redis
     Yaf_Registry::set('redis', new redis());
     //连接redis
     Yaf_Registry::get('redis')->pconnect(Yaf_Registry::get("config")->get('redis')->default->host, Yaf_Registry::get("config")->get('redis')->default->port, 2.5);
     //redis密码
     Yaf_Registry::get('redis')->auth(Yaf_Registry::get("config")->get('redis')->default->password);
     //使用php内置的serialize/unserialize 方法对数据进行处理
     Yaf_Registry::get('redis')->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
     //rediskey加前缀
     Yaf_Registry::get('redis')->setOption(Redis::OPT_PREFIX, Yaf_Registry::get("config")->get('redis')->default->prefix);
     core::ob_start();
 }