From 000addf3922b9365bb04cc7589f0bb809113a5d3 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 25 Oct 2016 15:52:23 +0800 Subject: [PATCH] * finish task #2671. --- module/custom/js/ajaxmenu.js | 4 +++ module/custom/model.php | 12 ++++++++- module/doc/control.php | 48 +++++++++++++++++++++++++++++++++ module/doc/lang/zh-cn.php | 2 ++ module/doc/view/browse.html.php | 3 ++- 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/module/custom/js/ajaxmenu.js b/module/custom/js/ajaxmenu.js index 04e5a5a9d8..d87a69e4df 100644 --- a/module/custom/js/ajaxmenu.js +++ b/module/custom/js/ajaxmenu.js @@ -106,8 +106,12 @@ $(function() { return $.map(items, function(item) { + link = ''; + if(item.link) link = item.text + '|' + item.link.module + '|' + item.link.method; + if(typeof(item.link.vars) != 'undefined') link = link + '|' + item.link.vars; var data = {name: item.name, order: parseInt(item.order)}; if(item.hidden) data.hidden = true; + if(link) data.link = link; return data; }); }; diff --git a/module/custom/model.php b/module/custom/model.php index 93fae85e94..9067ef5c69 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -190,6 +190,12 @@ class customModel extends model } } + /* Merge fileMenu and customMenu. */ + foreach($customMenuMap as $name => $item) + { + if(!isset($allMenu->$name))$allMenu->$name = $item; + } + foreach($allMenu as $name => $item) { $label = ''; @@ -198,7 +204,11 @@ class customModel extends model $float = ''; $fixed = ''; - $link = is_array($item) ? $item['link'] : $item; + $link = (is_array($item) and isset($item['link'])) ? $item['link'] : $item; + $link = (is_object($item) and isset($item->link)) ? $item->link : $link; + /* The variable of item has not link and is not link then ignore it. */ + if(!is_string($link)) continue; + $label = $link; $hasPriv = true; if(strpos($link, '|') !== false) diff --git a/module/doc/control.php b/module/doc/control.php index b62d736075..ff7f5a9bb6 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -115,6 +115,12 @@ class doc extends control $actionURL = $this->createLink('doc', 'browse', "lib=$libID&browseType=bySearch&queryID=myQueryID"); $this->doc->buildSearchForm($libID, $this->libs, $queryID, $actionURL, $type); + $this->view->fixedMenu = false; + foreach(customModel::getModuleMenu('doc') as $item) + { + if($item->name == "custom$libID" and empty($item->hidden)) $this->view->fixedMenu = true; + } + $this->view->libID = $libID; $this->view->libName = $this->libs[$libID]; $this->view->moduleID = $moduleID; @@ -504,6 +510,48 @@ class doc extends control die(html::select('module', $moduleOptionMenu, 0, "class='form-control'")); } + /** + * Ajax fixed menu. + * + * @param int $libID + * @param string $type + * @access public + * @return void + */ + public function ajaxFixedMenu($libID, $type = 'fixed') + { + $customMenus = $this->loadModel('setting')->getItem("owner={$this->app->user->account}&module=common§ion=customMenu&key=doc"); + if($customMenus) $customMenus = json_decode($customMenus); + if(empty($customMenus)) + { + if($type == 'remove') die(js::reload('parent')); + $i = 0; + foreach($this->lang->doc->menu as $name => $item) + { + if($name == 'list') continue; + $customMenu = new stdclass(); + $customMenu->name = $name; + $customMenu->order = $i; + $customMenus[] = $customMenu; + $i++; + } + } + + foreach($customMenus as $i => $customMenu) + { + if(isset($customMenu->link) and strpos($customMenu->link, "|libID=$libID") !== false) unset($customMenus[$i]); + } + + $lib = $this->doc->getLibByID($libID); + $customMenu = new stdclass(); + $customMenu->name = "custom{$libID}"; + $customMenu->link = "$lib->name|doc|browse|libID=$libID"; + $customMenu->order = count($customMenus); + if($type == 'fixed') $customMenus[] = $customMenu; + $this->setting->setItem("{$this->app->user->account}.common.customMenu.doc", json_encode($customMenus)); + die(js::reload('parent')); + } + /** * Show all libs by type. * diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index 4ec0523518..ef8a577d6a 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -56,6 +56,8 @@ $lang->doc->custom = '自定义文档库'; $lang->doc->createLib = '创建文档库'; $lang->doc->editLib = '编辑文档库'; $lang->doc->deleteLib = '删除文档库'; +$lang->doc->fixedMenu = '固定到菜单栏'; +$lang->doc->removeMenu = '从菜单栏移除'; /* 查询条件列表 */ $lang->doc->allProduct = '所有' . $lang->productCommon; diff --git a/module/doc/view/browse.html.php b/module/doc/view/browse.html.php index ce71f1efd2..69e6fe5c18 100644 --- a/module/doc/view/browse.html.php +++ b/module/doc/view/browse.html.php @@ -13,9 +13,9 @@ doc->confirmDelete)?> +;