12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
-
- namespace weapp\Ask\behavior\plugins;
-
- use think\Db;
-
- load_trait('controller/Jump');
- class AskBehavior
- {
- use \traits\controller\Jump;
- protected static $actionName;
- protected static $controllerName;
- protected static $moduleName;
- protected static $method;
-
- /**
- * 构造方法
- *
- * @param Request $request Request对象
- *
- * @access public
- */
- public function __construct()
- {
- ! isset(self::$moduleName) && self::$moduleName = request()->module();
- ! isset(self::$controllerName) && self::$controllerName = request()->controller();
- ! isset(self::$actionName) && self::$actionName = request()->action();
- ! isset(self::$method) && self::$method = strtoupper(request()->method());
- }
-
- /**
- * 模块初始化
- *
- * @param array $params 传入参数
- *
- * @access public
- */
- public function moduleInit(&$params)
- {
- if (isMobile() && file_exists('./template/plugins/ask/mobile/')) {
- !defined('THEME_STYLE') && define('THEME_STYLE', 'mobile'); // mobile端模板
- } else {
- !defined('THEME_STYLE') && define('THEME_STYLE', 'pc'); // pc端模板
- }
- }
-
- /**
- * 操作开始执行
- *
- * @param array $params 传入参数
- *
- * @access public
- */
- public function actionBegin(&$params)
- {
-
- }
-
- /**
- * 视图内容过滤
- *
- * @param array $params 传入参数
- *
- * @access public
- */
- public function viewFilter(&$params)
- {
-
- }
-
- /**
- * 应用结束
- *
- * @param array $params 传入参数
- *
- * @access public
- */
- public function appEnd(&$params)
- {
- $this->clearHtmlCache();
- }
-
- /**
- * 数据变动之后,清理页面和数据缓存
- */
- private function clearHtmlCache()
- {
- /*在以下相应的控制器和操作名里执行,以便提高性能*/
- if ('POST' == self::$method && 'plugins' == self::$moduleName && 'Ask' == self::$controllerName) {
- try {
- foreach ([HTML_PATH."plugins/ask/",CACHE_PATH] as $k2 => $v2) {
- delFile($v2);
- }
- } catch (\Exception $e) {}
- }
- }
- }
|