diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 8c0c4f7274..0f80b6d6b5 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -156,7 +156,7 @@ $lang->index->menu->project = "浏览{$lang->projectCommon}|project|browse"; $lang->my = new stdclass(); $lang->my->menu = new stdclass(); -$lang->my->menu->account = ' %s' . $lang->arrow . ''; +$lang->my->menu->account = array('link' => ' %s' . $lang->arrow . '', 'fixed' => true); $lang->my->menu->index = '首页|my|index'; $lang->my->menu->todo = array('link' => '待办|my|todo|', 'subModule' => 'todo'); $lang->my->menu->task = array('link' => '任务|my|task|', 'subModule' => 'task'); @@ -176,7 +176,7 @@ $lang->todo->menu = $lang->my->menu; $lang->product = new stdclass(); $lang->product->menu = new stdclass(); -$lang->product->menu->list = '%s'; +$lang->product->menu->list = array('link' => '%s', 'fixed' => true); $lang->product->menu->index = '首页|product|index|locate=no'; $lang->product->menu->story = array('link' => '需求|product|browse|productID=%s', 'alias' => 'batchedit', 'subModule' => 'story'); $lang->product->menu->dynamic = '动态|product|dynamic|productID=%s'; diff --git a/module/common/model.php b/module/common/model.php index 7325dffc1e..41e974627b 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -483,7 +483,7 @@ class commonModel extends model /* Cycling to print every sub menus. */ foreach($menu as $menuItem) { - + if($menuItem->hidden) continue; /* Init the these vars. */ if($menuItem->link) { diff --git a/module/custom/control.php b/module/custom/control.php index 5b66b4daee..7d8f98adf4 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -193,18 +193,27 @@ class custom extends control if($_POST) { $account = $this->app->user->account; - $menu = $_POST['menu']; + $menus = $_POST['menus']; + + if(empty($menus)) $this->send(array('result' => 'fail', 'message' => $this->lang->custom->saveFail)); - if(empty($method)) + if(is_array($menus)) { - $this->loadModel('setting')->setItem("$account.menucustom.$module", $menu); + foreach ($menus as $menu) + { + $menu = json_decode($menu); + $this->custom->saveCustomMenu($menu->value, $menu->module, $menu->method); + } } else { - $configKey = 'menucustom' . $module; - $this->loadModel('setting')->setItem("$account.$configKey.$method", $menu); + if(!empty($_POST['module'])) $module = $_POST['module']; + if(!empty($_POST['method'])) $method = $_POST['method']; + + $this->custom->saveCustomMenu($menus, $module, $method); } - $this->send(array('result' => 'success', 'menu' => $menu)); + + $this->send(array('result' => 'success')); } if($this->viewType === 'json') @@ -225,7 +234,7 @@ class custom extends control { $menu = !empty($method) ? customModel::getFeatureMenu($module, $method) : customModel::getModuleMenu($module, true); } - $this->send(array('result' => $menu ? 'success' : 'fail', 'menu' => $menu)); + die(json_encode(array('result' => $menu ? 'success' : 'fail', 'menu' => $menu), JSON_HEX_QUOT | JSON_HEX_APOS)); } else { diff --git a/module/custom/js/menu.js b/module/custom/js/menu.js index 9efc9e6f2c..23aceb80c7 100644 --- a/module/custom/js/menu.js +++ b/module/custom/js/menu.js @@ -13,8 +13,29 @@ $(function() 'feature': {} }; - var updateMenu = function($menu, items) + var updateConfig = function($menu) { + var moduleName = $menu.data('module'), methodName = $menu.data('method'); + var menu = []; + $menu.children('.nav').children('li:not(.drag-shadow)').each(function() + { + var $e = $(this); + var item = $e.children('a').data('menu'); + item.order = $e.attr('data-order'); + menu.push(item); + }); + if(moduleName === 'main') menuConfig.main = menu; + else if(methodName) menuConfig['feature'][moduleName][methodName] = menu; + else menuConfig['module'][moduleName] = menu; + } + + var updateMenu = function(moduleName, methodName, items) + { + var $menu = moduleName === 'main' ? $mainMenu : (methodName ? $featureMenu : $moduleMenu); + var items = items || (moduleName === 'main' ? menuConfig.main : (methodName ? menuConfig['feature'][moduleName][methodName] : menuConfig['module'][moduleName])); + + $menu.data({'module': moduleName, 'method': methodName}); + if(items) { var $nav = $('