* improve tutorial UI.
This commit is contained in:
+45
-9
@@ -298,7 +298,7 @@ class commonModel extends model
|
||||
if($app->company->website) echo html::a($app->company->website, $lang->company->website, '_blank');
|
||||
if($app->company->backyard) echo html::a($app->company->backyard, $lang->company->backyard, '_blank');
|
||||
|
||||
echo html::a(helper::createLink('tutorial', 'start'), $lang->tutorial, '', "class='iframe' data-width='800' data-headerless='true'");
|
||||
if(!commonModel::isTutorialMode()) echo html::a(helper::createLink('tutorial', 'start'), $lang->tutorial, '', "class='iframe' data-width='800' data-headerless='true'");
|
||||
echo html::a(helper::createLink('misc', 'feature'), $lang->feature, '', "class='iframe' data-width='1200' data-headerless='true'");
|
||||
echo html::a('javascript:;', $lang->help, '', "class='open-help-tab'");
|
||||
echo html::a(helper::createLink('misc', 'about'), $lang->aboutZenTao, '', "class='about iframe' data-width='900' data-headerless='true' data-class='modal-about'");
|
||||
@@ -372,6 +372,32 @@ class commonModel extends model
|
||||
$this->lang->menu = $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create menu item link
|
||||
*
|
||||
* @param object $menuItemLink
|
||||
* @param boolean $isTutorialMode
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function createMenuLink($menuItem)
|
||||
{
|
||||
$link = $menuItem->link;
|
||||
if(is_array($menuItem->link))
|
||||
{
|
||||
$vars = isset($menuItem->link['vars']) ? $menuItem->link['vars'] : '';
|
||||
if(isset($menuItem->tutorial) && $menuItem->tutorial)
|
||||
{
|
||||
$link = helper::createLink('tutorial', 'wizard', "module={$menuItem->link['module']}&method={$menuItem->link['method']}¶ms=$vars");
|
||||
}
|
||||
else
|
||||
{
|
||||
$link = helper::createLink($menuItem->link['module'], $menuItem->link['method'], $vars);
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the main menu.
|
||||
*
|
||||
@@ -397,19 +423,19 @@ class commonModel extends model
|
||||
}
|
||||
|
||||
/* Print all main menus. */
|
||||
$menu = customModel::getMainMenu();
|
||||
$activeName = $app->getViewType() == 'mhtml' ? 'ui-btn-active' : 'active';
|
||||
$menu = customModel::getMainMenu();
|
||||
$activeName = $app->getViewType() == 'mhtml' ? 'ui-btn-active' : 'active';
|
||||
|
||||
echo "<ul class='nav'>\n";
|
||||
foreach($menu as $menuItem)
|
||||
{
|
||||
if(isset($menuItem->hidden) && $menuItem->hidden) continue;
|
||||
$active = $menuItem->name == $mainMenu ? "class='$activeName'" : '';
|
||||
$link = is_array($menuItem->link) ? helper::createLink($menuItem->link['module'], $menuItem->link['method'], isset($menuItem->link['vars']) ? $menuItem->link['vars'] : null) : $menuItem->link;
|
||||
$link = commonModel::createMenuLink($menuItem);
|
||||
echo "<li $active data-id='$menuItem->name'><a href='$link' $active>$menuItem->text</a></li>\n";
|
||||
}
|
||||
$customLink = helper::createLink('custom', 'menu', "module={$app->getModuleName()}&method={$app->getMethodName()}", '', true);
|
||||
echo "<li class='custom-item'><a href='$customLink' data-toggle='modal' data-type='iframe' title='$lang->customMenu' data-icon='cog' data-width='80%'><i class='icon icon-cog'></i></a></li>";
|
||||
if(!commonModel::isTutorialMode()) echo "<li class='custom-item'><a href='$customLink' data-toggle='modal' data-type='iframe' title='$lang->customMenu' data-icon='cog' data-width='80%'><i class='icon icon-cog'></i></a></li>";
|
||||
echo "</ul>\n";
|
||||
}
|
||||
|
||||
@@ -475,9 +501,9 @@ class commonModel extends model
|
||||
}
|
||||
|
||||
/* get current module and method. */
|
||||
$currentModule = $app->getModuleName();
|
||||
$currentMethod = $app->getMethodName();
|
||||
$menu = customModel::getModuleMenu($moduleName);
|
||||
$currentModule = $app->getModuleName();
|
||||
$currentMethod = $app->getMethodName();
|
||||
$menu = customModel::getModuleMenu($moduleName);
|
||||
|
||||
/* The beginning of the menu. */
|
||||
echo "<ul class='nav'>\n";
|
||||
@@ -496,7 +522,7 @@ class commonModel extends model
|
||||
$target = '';
|
||||
$module = '';
|
||||
$method = '';
|
||||
$link = is_array($menuItem->link) ? helper::createLink($menuItem->link['module'], $menuItem->link['method'], isset($menuItem->link['vars']) ? $menuItem->link['vars'] : '') : $menuItem->link;
|
||||
$link = commonModel::createMenuLink($menuItem);
|
||||
if(is_array($menuItem->link))
|
||||
{
|
||||
if(isset($menuItem->link['subModule']))
|
||||
@@ -1298,6 +1324,16 @@ class commonModel extends model
|
||||
global $config;
|
||||
return (isset($config->global->novice) and $config->global->novice == 'true');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether view type is tutorial
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isTutorialMode()
|
||||
{
|
||||
return $_SESSION['tutorialMode'];
|
||||
}
|
||||
}
|
||||
|
||||
class common extends commonModel
|
||||
|
||||
@@ -7,7 +7,3 @@ $config->custom->canAdd['testcase'] = 'priList,typeList,stageList';
|
||||
$config->custom->canAdd['testtask'] = 'priList';
|
||||
$config->custom->canAdd['todo'] = 'priList,typeList';
|
||||
$config->custom->canAdd['user'] = 'roleList';
|
||||
|
||||
$config->menu = new stdclass();
|
||||
$config->menu->main = array();
|
||||
$config->menu->main['novice'] = 'my,company,product,project,qa,doc,report,admin';
|
||||
|
||||
+22
-9
@@ -134,9 +134,10 @@ class customModel extends model
|
||||
{
|
||||
global $app, $lang, $config;
|
||||
$isSetMenuConfig = isset($menuConfig);
|
||||
$menu = array();
|
||||
$order = 1;
|
||||
$menuConfigMap = array();
|
||||
$menu = array();
|
||||
$order = 1;
|
||||
$menuConfigMap = array();
|
||||
$isTutorialMode = commonModel::isTutorialMode();
|
||||
|
||||
if($isSetMenuConfig)
|
||||
{
|
||||
@@ -151,6 +152,17 @@ class customModel extends model
|
||||
$item->hidden = false;
|
||||
$menuConfigMap[$item->name] = $item;
|
||||
}
|
||||
foreach($allMenu as $name => $item)
|
||||
{
|
||||
if(!isset($menuConfigMap[$name]))
|
||||
{
|
||||
$item = new stdclass();
|
||||
$item->name = $name;
|
||||
$item->hidden = true;
|
||||
$item->order = $order++;
|
||||
$menuConfigMap[$name] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(is_array($menuConfig))
|
||||
{
|
||||
@@ -185,7 +197,8 @@ class customModel extends model
|
||||
$label = $link;
|
||||
}
|
||||
|
||||
if(commonModel::hasPriv($module, $method))
|
||||
$hasPriv = commonModel::hasPriv($module, $method);
|
||||
if($isTutorialMode || $hasPriv)
|
||||
{
|
||||
$itemLink = '';
|
||||
if($module && $method)
|
||||
@@ -217,6 +230,7 @@ class customModel extends model
|
||||
if($float) $menuItem->float = $float;
|
||||
if($fixed) $menuItem->fixed = $fixed;
|
||||
if($hidden) $menuItem->hidden = $hidden;
|
||||
if($isTutorialMode) $menuItem->tutorial = true;
|
||||
|
||||
while(isset($menu[$menuItem->order])) { $menuItem->order++; }
|
||||
$menu[$menuItem->order] = $menuItem;
|
||||
@@ -242,9 +256,8 @@ class customModel extends model
|
||||
if(empty($app->customMenu)) $app->customMenu = array();
|
||||
if(!$rebuild && !empty($app->customMenu[$module])) return $app->customMenu[$module];
|
||||
|
||||
$menuConfig = isset($config->menucustom->$module) ? $config->menucustom->$module : array();
|
||||
if(!empty($menuConfig)) $menuConfig = json_decode($menuConfig);
|
||||
if(!isset($menuConfig) && common::inNoviceMode()) $menuConfig = $config->menu->$module['novice'];
|
||||
$menuConfig = commonModel::isTutorialMode() && $module === 'main' ? 'my,product,project,qa,company' : (isset($config->menucustom->$module) ? $config->menucustom->$module : array());
|
||||
if(!empty($menuConfig) && is_string($menuConfig) && substr($menuConfig, 0, 1) === '[') $menuConfig = json_decode($menuConfig);
|
||||
|
||||
$allMenu = $module == 'main' ? $lang->menu : (isset($lang->$module->menu) ? $lang->$module->menu : $lang->my->menu);
|
||||
if($module == 'product' and isset($allMenu->branch)) $allMenu->branch = str_replace('@branch@', $lang->custom->branch, $allMenu->branch);
|
||||
@@ -280,8 +293,8 @@ class customModel extends model
|
||||
$configKey = 'feature_' . $module . '_' . $method;
|
||||
$allMenu = isset($lang->$module->featurebar[$method]) ? $lang->$module->featurebar[$method] : null;
|
||||
$menuConfig = '';
|
||||
if(isset($config->menucustom->$configKey)) $menuConfig = $config->menucustom->$configKey;
|
||||
if(!empty($menuConfig)) $menuConfig = json_decode($menuConfig);
|
||||
if(!commonModel::isTutorialMode() && isset($config->menucustom->$configKey)) $menuConfig = $config->menucustom->$configKey;
|
||||
if(!empty($menuConfig) && is_string($menuConfig)) $menuConfig = json_decode($menuConfig);
|
||||
return $allMenu ? self::buildMenuConfig($allMenu, $menuConfig) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ class tutorial extends control
|
||||
die(json_encode(array('result' => isset($setting) ? 'success' : 'fail', 'setting' => $setting), JSON_HEX_QUOT | JSON_HEX_APOS));
|
||||
}
|
||||
|
||||
$this->session->set('tutorialMode', true);
|
||||
|
||||
$this->view->title = $this->lang->tutorial->common;
|
||||
$this->view->current = $task;
|
||||
$this->view->setting = $setting;
|
||||
@@ -51,6 +53,22 @@ class tutorial extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit tuturial mode
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function quit($referer = '')
|
||||
{
|
||||
$this->session->set('tutorialMode', false);
|
||||
|
||||
if(!empty($referer))
|
||||
{
|
||||
die(js::locate(base64_decode($referer), 'parent'));
|
||||
}
|
||||
die(json_encode(array('result' => 'success')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wizard.
|
||||
*
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<div class='start-icon'><i class='icon icon-certificate icon-back'></i><i class='icon icon-flag icon-front'></i></div>
|
||||
<h2><?php echo $lang->tutorial->common ?></h2>
|
||||
<div class='actions'>
|
||||
<a data-toggle='tooltip' data-placement='left' title='<?php echo $lang->tutorial->exit ?>' href='<?php echo helper::createLink('my', 'index') ?>' class='btn btn-sm'><i class="icon icon-signout"></i></a>
|
||||
<a href='<?php echo helper::createLink('tutorial', 'quit', 'referer=' . base64_encode($referer)) ?>' class='btn btn-sm'><i class="icon icon-signout"></i> <?php echo $lang->tutorial->exit ?></a>
|
||||
</div>
|
||||
</header>
|
||||
<section id='current'>
|
||||
|
||||
Reference in New Issue
Block a user