From 7b4b2b820b73623cd4facf92191d80004d73e59f Mon Sep 17 00:00:00 2001 From: wangyuting Date: Thu, 29 Feb 2024 14:39:12 +0800 Subject: [PATCH] * Add required function for old view pages. --- framework/model.class.php | 73 +++++++++++++++++++++++++++++++++++++++ module/common/model.php | 56 +++++++++++++++++++++++++++++- 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/framework/model.class.php b/framework/model.class.php index 08e1e08069..62d8f1b480 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -126,6 +126,79 @@ class model extends baseModel return false; } + /** + * Build menu of a module. + * + * @param string $moduleName + * @param string $methodName + * @param string $params + * @param object $data + * @param string $type + * @param string $icon + * @param string $target + * @param string $class + * @param bool $onlyBody + * @param string $misc + * @param string $title + * @param bool $returnHtml + * @access public + * @return string + */ + + public function buildMenu($moduleName, $methodName, $params, $data, $type = 'view', $icon = '', $target = '', $class = '', $onlyBody = false, $misc = '' , $title = '', $returnHtml = true) + { + if(strpos($moduleName, '.') !== false) list($appName, $moduleName) = explode('.', $moduleName); + + if(strpos($methodName, '_') !== false && strpos($methodName, '_') > 0) list($module, $method) = explode('_', $methodName); + + if(empty($module)) $module = $moduleName; + if(empty($method)) $method = $methodName; + + static $actions = array(); + if(isset($this->config->bizVersion)) + { + if(empty($actions[$moduleName])) + { + $actions[$moduleName] = $this->dao->select('*')->from(TABLE_WORKFLOWACTION) + ->where('module')->eq($moduleName) + ->andWhere('buildin')->eq('1') + ->andWhere('status')->eq('enable') + ->beginIF(!empty($this->config->vision))->andWhere('vision')->eq($this->config->vision)->fi() + ->fetchAll('action'); + } + } + + $enabled = true; + if(!empty($actions) and isset($actions[$moduleName][$methodName])) + { + $action = $actions[$moduleName][$methodName]; + + if($action->extensionType == 'override') return $this->loadModel('flow')->buildActionMenu($moduleName, $action, $data, $type); + + $conditions = json_decode($action->conditions); + if($conditions and $action->extensionType == 'extend') + { + if($icon != 'copy' and $methodName != 'create') $title = $action->name; + if($conditions) $enabled = $this->loadModel('flow')->checkConditions($conditions, $data); + } + else + { + if(method_exists($this, 'isClickable')) $enabled = $this->isClickable($data, $method, $module); + } + } + else + { + if(method_exists($this, 'isClickable')) $enabled = $this->isClickable($data, $method, $module); + } + + if(!$returnHtml) return $enabled; + + $html = ''; + $type = $type == 'browse' ? 'list' : 'button'; + $html = common::buildIconButton($module, $method, $params, $data, $type, $icon, $target, $class, $onlyBody, $misc, $title, '', $enabled); + return $html; + } + /** * Build menu of actions created by workflow action. * diff --git a/module/common/model.php b/module/common/model.php index 9abce2e6af..609642a4e0 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -2596,7 +2596,7 @@ class commonModel extends model $currentMethod = strtolower($method); if(!commonModel::hasPriv($module, $method, $object, $vars) and !in_array("$currentModule.$currentMethod", $config->openMethods)) return false; - $link = helper::createLink($module, $method, $vars, '', $onlyBody); + $link = helper::createLink($module, $method, $vars, '', $onlyBody ? true : false); /* Set the icon title, try search the $method defination in $module's lang or $common's lang. */ if(empty($title)) @@ -3449,6 +3449,60 @@ class commonModel extends model echo html::a(helper::createLink($module, $method, $vars, '', $onlyBody), $label, $target, $misc, $newline); return true; } + + /** + * Print pre and next link + * + * @param string $preAndNext + * @param string $linkTemplate + * @static + * @access public + * @return void + */ + public static function printPreAndNext($preAndNext = '', $linkTemplate = '') + { + global $lang, $app; + if(isonlybody()) return false; + + $moduleName = ($app->getModuleName() == 'story' and $app->tab == 'project') ? 'projectstory' : $app->getModuleName(); + echo "'; + } } class common extends commonModel