From aecff9993270481cfd97d5d701452b51009d11c5 Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 24 Jul 2019 17:49:40 +0800 Subject: [PATCH] * Fix bug of view a flow page by path_info. --- framework/router.class.php | 68 +++++++++++++++++++++++++++++++------- lib/pager/pager.class.php | 54 ++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 12 deletions(-) diff --git a/framework/router.class.php b/framework/router.class.php index daf1c430b1..fd9aee2c1c 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -233,9 +233,7 @@ class router extends baseRouter */ public function loadConfig($moduleName, $appName = '') { - $appName = ''; - - return parent::loadModuleConfig($moduleName, $appName); + return parent::loadModuleConfig($moduleName); } /** @@ -278,16 +276,15 @@ class router extends baseRouter { if($flow->buildin && $this->methodName == 'browselabel') { - $this->workflowModule = $this->moduleName; - $this->workflowMethod = 'browse'; + $this->workflowModule = $this->moduleName; + $this->workflowMethod = 'browse'; - $this->loadModuleConfig('workflowaction'); + $this->loadModuleConfig('workflowaction'); - $moduleName = 'flow'; - $methodName = 'browse'; + $moduleName = 'flow'; + $methodName = 'browse'; - $this->setModuleName($moduleName); - $this->setMethodName($methodName); + $this->setFlowURI($moduleName, $methodName); } else { @@ -302,8 +299,7 @@ class router extends baseRouter $moduleName = 'flow'; $methodName = in_array($this->methodName, $this->config->workflowaction->default->actions) ? $this->methodName : 'operate'; - $this->setModuleName($moduleName); - $this->setMethodName($methodName); + $this->setFlowURI($moduleName, $methodName); } } } @@ -313,6 +309,54 @@ class router extends baseRouter return parent::setControlFile($exitIfNone); } + /** + * Reset URI to flow's URI. + * + * @param string $moduleName + * @param string $methodName + * @access public + * @return void + */ + public function setFlowURI($moduleName, $methodName) + { + $this->rawURI = $this->URI; + $this->setModuleName($moduleName); + $this->setMethodName($methodName); + if($this->config->requestType != 'GET') + { + $params = explode($this->config->requestFix, $this->URI); + /* Remove module and method. */ + $params = array_slice($params, 2); + /* Prepend other params. */ + array_unshift($params, $this->workflowModule); + array_unshift($params, $methodName); + array_unshift($params, $moduleName); + + $this->URI = implode($this->config->requestFix, $params); + } + else + { + $params = parse_url($this->URI); + /* Extract $path and $query from $params. */ + extract($params); + parse_str($query, $params); + /* Remove module and method. */ + unset($params[$this->config->moduleVar]); + unset($params[$this->config->methodVar]); + + $params = array_reverse($params); + + /* Prepend other params. */ + $params['module'] = $this->workflowModule; + $params[$this->config->methodVar] = $methodName; + $params[$this->config->moduleVar] = $moduleName; + + $params = array_reverse($params); + + $this->URI = $path . '?' . http_build_query($params); + } + } + /** * PATH_INFO方式解析,获取$URI和$viewType。 * Parse PATH_INFO, get the $URI and $viewType. diff --git a/lib/pager/pager.class.php b/lib/pager/pager.class.php index 4a2d462b18..09493b48a6 100644 --- a/lib/pager/pager.class.php +++ b/lib/pager/pager.class.php @@ -20,6 +20,60 @@ helper::import(dirname(dirname(__FILE__)) . '/base/pager/pager.class.php'); */ class pager extends basePager { + /** + * 设置模块名。 + * Set the $moduleName property. + * + * @access public + * @return void + */ + public function setModuleName() + { + if(isset($this->app->workflowModule)) + { + $this->moduleName = $this->app->workflowModule; + } + else + { + $this->moduleName = $this->app->getModuleName(); + } + } + + /** + * 设置方法名。 + * Set the $methodName property. + * + * @access public + * @return void + */ + public function setMethodName() + { + if(isset($this->app->workflowMethod)) + { + $this->methodName = $this->app->workflowMethod; + } + else + { + $this->methodName = $this->app->getMethodName(); + } + } + + /** + * 从请求网址中获取记录总数、每页记录数、页码。 + * Get recTotal, recPerpage, pageID from the request params, and add them to params. + * + * @access public + * @return void + */ + public function setParams() + { + parent::setParams(); + if(isset($this->app->workflowModule) && isset($this->app->workflowMethod)) + { + unset($this->params['module']); + } + } + /** * Show pager. *