New: Work on men management rewrite
This commit is contained in:
parent
006050b6cd
commit
8f331adff6
@ -30,12 +30,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $atarget Target
|
||||
* @param int $type_user 0=Internal,1=External,2=All
|
||||
* @param int $type_user 0=Menu for backoffice, 1=Menu for front office
|
||||
* @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
|
||||
* @param array &$menu Object Menu to return back list of menu entries
|
||||
* @param int $noout Disable output (Initialise &$menu only).
|
||||
* @return void
|
||||
*/
|
||||
function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu)
|
||||
function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0)
|
||||
{
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name;
|
||||
|
||||
@ -45,11 +46,11 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu)
|
||||
$id='mainmenu';
|
||||
$listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
|
||||
|
||||
//$tabMenu=array();
|
||||
// Show personalized menus
|
||||
$menuArbo = new Menubase($db,'auguria');
|
||||
$newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria',$tabMenu);
|
||||
|
||||
print_start_menu_array_auguria();
|
||||
if (empty($noout)) print_start_menu_array_auguria();
|
||||
|
||||
$num = count($newTabMenu);
|
||||
for($i = 0; $i < $num; $i++)
|
||||
@ -59,24 +60,23 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu)
|
||||
$showmode=dol_auguria_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal);
|
||||
if ($showmode == 1)
|
||||
{
|
||||
// Define url
|
||||
if (preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
|
||||
$url = $shorturl = $newTabMenu[$i]['url'];
|
||||
if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
|
||||
{
|
||||
$url = $newTabMenu[$i]['url'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url=dol_buildpath($newTabMenu[$i]['url'],1);
|
||||
$param='';
|
||||
if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url))
|
||||
{
|
||||
if (! preg_match('/\?/',$url)) $url.='?';
|
||||
else $url.='&';
|
||||
$url.='mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
|
||||
if (! preg_match('/\?/',$url)) $param.='?';
|
||||
else $param.='&';
|
||||
$param.='mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu=';
|
||||
}
|
||||
//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad
|
||||
$url=dol_buildpath($url,1).$param;
|
||||
$shorturl = $newTabMenu[$i]['url'].$param;
|
||||
}
|
||||
$url=preg_replace('/__LOGIN__/',$user->login,$url);
|
||||
|
||||
$shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl);
|
||||
|
||||
// Define the class (top menu selected or not)
|
||||
if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"';
|
||||
else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname='class="tmenusel"';
|
||||
@ -84,12 +84,13 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu)
|
||||
}
|
||||
else if ($showmode == 2) $classname='class="tmenu"';
|
||||
|
||||
print_start_menu_entry_auguria($idsel,$classname,$showmode);
|
||||
print_text_menu_entry_auguria($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget));
|
||||
print_end_menu_entry_auguria($showmode);
|
||||
if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode);
|
||||
if (empty($noout)) print_text_menu_entry_auguria($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget));
|
||||
if (empty($noout)) print_end_menu_entry_auguria($showmode);
|
||||
$menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), '');
|
||||
}
|
||||
|
||||
print_end_menu_array_auguria();
|
||||
if (empty($noout)) print_end_menu_array_auguria();
|
||||
|
||||
print "\n";
|
||||
}
|
||||
@ -127,7 +128,7 @@ function print_start_menu_entry_auguria($idsel,$classname,$showmode)
|
||||
* Output menu entry
|
||||
*
|
||||
* @param string $text Text
|
||||
* @param int $showmode 1 = allowed or 2 = not allowed
|
||||
* @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed
|
||||
* @param string $url Url
|
||||
* @param string $id Id
|
||||
* @param string $idsel Id sel
|
||||
@ -142,7 +143,7 @@ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $cla
|
||||
if ($showmode == 1)
|
||||
{
|
||||
print '<a class="tmenuimage" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>';
|
||||
print '<div class="'.$id.' '.$idsel.'"><span class="mainmenu_'.$idsel.' '.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
|
||||
print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
|
||||
print '</a>';
|
||||
print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget?' target="'.$atarget.'"':'').'>';
|
||||
print '<span class="mainmenuaspan">';
|
||||
@ -152,7 +153,7 @@ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $cla
|
||||
}
|
||||
if ($showmode == 2)
|
||||
{
|
||||
print '<div class="'.$id.' '.$idsel.'"><span class="mainmenu_'.$idsel.' '.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
|
||||
print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
|
||||
print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
|
||||
print '<span class="mainmenuaspan">';
|
||||
print $text;
|
||||
@ -172,8 +173,8 @@ function print_end_menu_entry_auguria($showmode)
|
||||
if ($showmode)
|
||||
{
|
||||
print '</div></li>';
|
||||
print "\n";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,20 +199,22 @@ function print_end_menu_array_auguria()
|
||||
* @param array $menu_array_after Table of menu entries to show after entries of menu handler
|
||||
* @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
|
||||
* @param array &$menu Object Menu to return back list of menu entries
|
||||
* @param int $noout Disable output (Initialise &$menu only).
|
||||
* @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x'
|
||||
* @param string $forceleftmenu 'all'=Force leftmenu to '' (= all)
|
||||
* @return void
|
||||
*/
|
||||
function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabMenu,&$menu)
|
||||
function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabMenu,&$menu,$noout=0,$forcemainmenu='',$forceleftmenu='')
|
||||
{
|
||||
global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc;
|
||||
|
||||
$overwritemenufor = array();
|
||||
$newmenu = $menu;
|
||||
|
||||
$mainmenu=$_SESSION["mainmenu"];
|
||||
$leftmenu=$_SESSION["leftmenu"];
|
||||
$mainmenu=($forcemainmenu?$forcemainmenu:$_SESSION["mainmenu"]);
|
||||
$leftmenu=($forceleftmenu?'':(empty($_SESSION["leftmenu"])?'none':$_SESSION["leftmenu"]));
|
||||
|
||||
// Show logo company
|
||||
if (! empty($conf->global->MAIN_SHOW_LOGO))
|
||||
if (empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO))
|
||||
{
|
||||
$mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
|
||||
if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
|
||||
@ -245,23 +248,21 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
|
||||
if (! is_array($menu_array)) return 0;
|
||||
|
||||
// Show menu
|
||||
if (empty($noout))
|
||||
{
|
||||
$alt=0;
|
||||
$num=count($menu_array);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$showmenu=true;
|
||||
if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu=false;
|
||||
|
||||
$alt++;
|
||||
if (empty($menu_array[$i]['level']))
|
||||
if (empty($menu_array[$i]['level']) && $showmenu)
|
||||
{
|
||||
if (($alt%2==0))
|
||||
{
|
||||
if ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_MENU_USE_JQUERY_ACCORDION))
|
||||
{
|
||||
print '<div class="blockvmenupair">'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="blockvmenuimpair">'."\n";
|
||||
}
|
||||
print '<div class="blockvmenuimpair">'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -290,7 +291,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
|
||||
$url.='mainmenu='.$mainmenu;
|
||||
}
|
||||
|
||||
print '<!-- Add menu entry with mainmenu='.$menu_array[$i]['mainmenu'].', leftmenu='.$menu_array[$i]['leftmenu'].', level='.$menu_array[$i]['mainmenu'].' -->'."\n";
|
||||
print '<!-- Add menu entry with mainmenu='.$menu_array[$i]['mainmenu'].', leftmenu='.$menu_array[$i]['leftmenu'].', level='.$menu_array[$i]['level'].' -->'."\n";
|
||||
|
||||
// Menu niveau 0
|
||||
if ($menu_array[$i]['level'] == 0)
|
||||
@ -299,35 +300,42 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
|
||||
{
|
||||
print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'.$menu_array[$i]['titre'].'</a></div>';
|
||||
}
|
||||
else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
|
||||
else if ($showmenu)
|
||||
{
|
||||
print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$menu_array[$i]['titre'].'</font></div>';
|
||||
print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$menu_array[$i]['titre'].'</font></div>'."\n";
|
||||
}
|
||||
print "\n".'<div id="section_content_'.$i.'">'."\n";
|
||||
print '<div class="menu_top"></div>'."\n";
|
||||
if ($showmenu)
|
||||
print '<div class="menu_top"></div>'."\n";
|
||||
}
|
||||
// Menu niveau > 0
|
||||
if ($menu_array[$i]['level'] > 0)
|
||||
{
|
||||
if ($menu_array[$i]['enabled'])
|
||||
{
|
||||
print '<div class="menu_contenu">'.$tabstring.'<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>'.$menu_array[$i]['titre'].'</a></div>';
|
||||
print '<div class="menu_contenu">'.$tabstring;
|
||||
if ($menu_array[$i]['url']) print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target']?' target="'.$menu_array[$i]['target'].'"':'').'>';
|
||||
print $menu_array[$i]['titre'];
|
||||
if ($menu_array[$i]['url']) print '</a>';
|
||||
// If title is not pure text and contains a table, no carriage return added
|
||||
if (! strstr($menu_array[$i]['titre'],'<table')) print '<br>';
|
||||
print '</div>'."\n";
|
||||
}
|
||||
else if (empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
|
||||
else if ($showmenu)
|
||||
{
|
||||
print '<div class="menu_contenu">'.$tabstring.'<font class="vsmenudisabled">'.$menu_array[$i]['titre'].'</font></div>';
|
||||
print '<div class="menu_contenu">'.$tabstring.'<font class="vsmenudisabled">'.$menu_array[$i]['titre'].'</font><br></div>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// If next is a new block or end
|
||||
if (empty($menu_array[$i+1]['level']))
|
||||
{
|
||||
print '<div class="menu_end"></div>'."\n";
|
||||
print "</div><!-- end section content -->\n";
|
||||
print "</div><!-- end blockvmenu pair/impair -->\n";
|
||||
if ($showmenu)
|
||||
print '<div class="menu_end"></div>'."\n";
|
||||
print "</div>\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return count($menu_array);
|
||||
}
|
||||
|
||||
|
||||
@ -151,12 +151,12 @@ class MenuManager
|
||||
/**
|
||||
* Show menu
|
||||
*
|
||||
* @param string $mode 'top' or 'left'
|
||||
* @param string $mode 'top', 'left', 'jmobile'
|
||||
* @return int Number of menu entries shown
|
||||
*/
|
||||
function showmenu($mode)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php';
|
||||
|
||||
@ -173,7 +173,53 @@ class MenuManager
|
||||
|
||||
if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu);
|
||||
if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu);
|
||||
|
||||
if ($mode == 'jmobile')
|
||||
{
|
||||
$res=print_auguria_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1);
|
||||
|
||||
foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
|
||||
{
|
||||
print '<ul data-role="listview" data-inset="true">';
|
||||
print '<li data-role="list-divider">';
|
||||
if ($val['enabled'] == 1)
|
||||
{
|
||||
$relurl=dol_buildpath($val['url'],1);
|
||||
|
||||
print '<a href="#">'.$val['titre'].'</a>'."\n";
|
||||
// Search submenu fot this entry
|
||||
$tmpmainmenu=$val['mainmenu'];
|
||||
$tmpleftmenu='all';
|
||||
$submenu=new Menu();
|
||||
$res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu);
|
||||
$nexturl=dol_buildpath($submenu->liste[0]['url'],1);
|
||||
$canonrelurl=preg_replace('/\?.*$/','',$relurl);
|
||||
$canonnexturl=preg_replace('/\?.*$/','',$nexturl);
|
||||
//var_dump($canonrelurl);
|
||||
//var_dump($canonnexturl);
|
||||
print '<ul>';
|
||||
if ($canonrelurl != $canonnexturl && $val['mainmenu'] != 'home')
|
||||
{
|
||||
// We add sub entry
|
||||
print '<li data-role="list-divider"><a href="'.$relurl.'">'.$langs->trans("MainArea").'-'.$val['titre'].'</a></li>'."\n";
|
||||
}
|
||||
foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
|
||||
{
|
||||
$relurl2=dol_buildpath($val2['url'],1);
|
||||
//var_dump($val2);
|
||||
print '<li'.($val2['level']==0?' data-role="list-divider"':'').'><a href="'.$relurl2.'">'.$val2['titre'].'</a></li>'."\n";
|
||||
}
|
||||
//var_dump($submenu);
|
||||
print '</ul>';
|
||||
}
|
||||
if ($val['enabled'] == 2)
|
||||
{
|
||||
print '<font class="vsmenudisabled">'.$val['titre'].'</font>';
|
||||
}
|
||||
print '</li>';
|
||||
print '</ul>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->menu);
|
||||
|
||||
return $res;
|
||||
|
||||
@ -264,10 +264,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0)
|
||||
$showmode=dol_eldy_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal);
|
||||
if ($showmode == 1)
|
||||
{
|
||||
$url = $newTabMenu[$i]['url'];
|
||||
$url = $shorturl = $newTabMenu[$i]['url'];
|
||||
if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url']))
|
||||
{
|
||||
$url = $newTabMenu[$i]['url'];
|
||||
$param='';
|
||||
if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url))
|
||||
{
|
||||
@ -436,8 +435,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
}
|
||||
|
||||
/**
|
||||
* On definit newmenu en fonction de mainmenu et leftmenu
|
||||
* ------------------------------------------------------
|
||||
* We update newmenu with entries found into database
|
||||
* --------------------------------------------------
|
||||
*/
|
||||
if ($mainmenu)
|
||||
{
|
||||
|
||||
@ -140,7 +140,7 @@ class MenuManager
|
||||
if ($val['enabled'] == 1)
|
||||
{
|
||||
$relurl=dol_buildpath($val['url'],1);
|
||||
|
||||
|
||||
print '<a href="#">'.$val['titre'].'</a>'."\n";
|
||||
// Search submenu fot this entry
|
||||
$tmpmainmenu=$val['mainmenu'];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user