* Modify menu tree data.

This commit is contained in:
caoyanyi
2023-02-20 15:44:08 +08:00
parent e1ca736379
commit 51855da582
3 changed files with 28 additions and 43 deletions

View File

@@ -92,13 +92,21 @@ class dev extends control
* @access public
* @return void
*/
public function langItem($type = 'common', $module = '', $method = '', $language = 'zh_cn')
public function langItem($type = 'common', $module = 'my', $method = '', $language = 'zh_cn')
{
$language = str_replace('_', '-', $language);
$moduleName = $module;
if($type == 'common') $moduleName = 'common';
if($type == 'second') $moduleName = $module . 'Menu';
if($type == 'third') $moduleName = $module . 'SubMenu';
if($type == 'third')
{
if(empty($method)) $method = 'work';
$moduleName = $module . 'SubMenu';
}
if($type == 'feature' and empty($method)) $method = 'todo';
if($this->server->request_method == 'POST')
{
@@ -128,11 +136,8 @@ class dev extends control
return $this->send(array('result' => 'success', 'locate' => 'reload', 'message' => $this->lang->saveSuccess));
}
$this->dev->loadDefaultLang();
$this->view->title = $this->lang->langItem;
$this->view->type = $type;
$this->view->featureBar = $this->lang->dev->featureBar['langItem'];
$this->view->originalLangs = $this->dev->getOriginalLang($type, $module, $method, $language);
$this->view->customedLangs = $this->dev->getCustomedLang($type, $module, $method, $language);
$this->view->menuTree = $this->dev->getMenuTree($type, $module, $method);

View File

@@ -304,23 +304,6 @@ class devModel extends model
*/
public function getOriginalLang($type, $module = '', $method = '', $language = 'zh-cn')
{
// Defalut value set, remove when left tree display.
if($type == 'feature')
{
$module = 'product';
$method = 'browse';
}
elseif($type == 'second')
{
$module = 'scrum';
}
elseif($type == 'third')
{
$module = 'kanbanProject';
$method = 'settings';
}
// Defalut value set end.
$originalLangs = array();
$clientLang = $this->app->getClientLang();
$defaultLang = $this->loadDefaultLang();
@@ -398,7 +381,7 @@ class devModel extends model
elseif($type == 'third')
{
$langKey = "{$method}_";
$lang = $defaultLang->$module->menu->$method['subMenu'];
$lang = $defaultLang->$module->menu->{$method}['subMenu'];
}
$menus = $this->getLinkTitle($lang);
@@ -427,23 +410,6 @@ class devModel extends model
$customedLangs = array();
$clientLang = $this->app->getClientLang();
// Defalut value set, remove when left tree display.
if($type == 'feature')
{
$module = 'product';
$method = 'browse';
}
elseif($type == 'second')
{
$module = 'scrum';
}
elseif($type == 'third')
{
$module = 'kanbanProject';
$method = 'settings';
}
// Defalut value set end.
$langKey = '';
$customeds = array();
if($type == 'common')
@@ -593,7 +559,7 @@ class devModel extends model
$menusPinYin = common::convert2Pinyin($menuLang);
foreach($menuLang as $menuKey => $menuName)
{
if(!isset($this->lang->$menu->menu->$menuKey['subMenu'])) continue;
if(!isset($this->lang->$menu->menu->{$menuKey}['subMenu']) or !get_object_vars($this->lang->$menu->menu->{$menuKey}['subMenu'])) continue;
$subMenu = new stdClass();
$subMenu->title = $menuName;
@@ -656,7 +622,21 @@ class devModel extends model
$menuTree = array();
if(!in_array($type, $this->config->dev->navTypes)) return $menuTree;
$mainNav = $this->getLinkTitle($this->lang->mainNav);
$mainNav = $type == 'second' ? $this->lang->mainNav : array();
if($type != 'second')
{
foreach($this->lang->mainNav as $menuKey => $menu)
{
if($menuKey == 'project')
{
foreach($this->config->dev->projectMenus as $subMenuKey) $mainNav[$subMenuKey] = $this->lang->dev->projectMenu[$subMenuKey];
}
$mainNav[$menuKey] = $menu;
}
}
$mainNav = $this->getLinkTitle($mainNav);
$maimNavPinYin = common::convert2Pinyin($mainNav);
if(empty($module)) $module = 'my';

View File

@@ -16,7 +16,7 @@
<?php include 'header.html.php';?>
<div id='mainMenu' class='clearfix menu-secondary'>
<div class="btn-toolBar pull-left">
<?php foreach($featureBar as $key => $label):?>
<?php foreach($lang->dev->featureBar['langItem'] as $key => $label):?>
<?php $active = $type == $key ? 'btn-active-text' : '';?>
<?php $label = "<span class='text'>$label</span>";?>
<?php echo html::a(inlink('langItem', "type=$key"), $label, '', "class='btn btn-link $active'");?>