CLOSE #4368 #4369 Add hook completeTabsHead for rewrite heads tabs menu

This commit is contained in:
Laurent Destailleur
2016-11-12 14:36:52 +01:00
parent f0eceefe48
commit 4bcc7dc8a0
2 changed files with 25 additions and 6 deletions

View File

@@ -165,6 +165,7 @@ class HookManager
'paymentsupplierinvoices', 'paymentsupplierinvoices',
'printAddress', 'printAddress',
'printSearchForm', 'printSearchForm',
'printTabsHead',
'formatEvent', 'formatEvent',
'addCalendarChoice', 'addCalendarChoice',
'printObjectLine', 'printObjectLine',

View File

@@ -772,7 +772,7 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto
*/ */
function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0) function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0)
{ {
global $conf,$langs, $hookmanager; global $conf, $langs, $hookmanager;
$out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n"; $out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n";
@@ -897,8 +897,12 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
if (! $notab) $out.="\n".'<div class="tabBar">'."\n"; if (! $notab) $out.="\n".'<div class="tabBar">'."\n";
$parameters=array('tabname' => $active); $parameters=array('tabname' => $active, 'out' => $out);
$reshook=$hookmanager->executeHooks('printTabsHead',$parameters); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('printTabsHead',$parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
if ($reshook > 0)
{
$out = $hookmanager->resPrint;
}
return $out; return $out;
} }
@@ -5335,8 +5339,9 @@ function picto_from_langcode($codelang)
} }
/** /**
* Complete or removed entries into a head array (used to build tabs) with value added by external modules. * Complete or removed entries into a head array (used to build tabs).
* Such values are declared into $conf->modules_parts['tab']. * For example, with value added by external modules. Such values are declared into $conf->modules_parts['tab'].
* Or by change using hook completeTabsHead
* *
* @param Conf $conf Object conf * @param Conf $conf Object conf
* @param Translate $langs Object langs * @param Translate $langs Object langs
@@ -5363,6 +5368,8 @@ function picto_from_langcode($codelang)
*/ */
function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add') function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add')
{ {
global $hookmanager;
if (isset($conf->modules_parts['tabs'][$type]) && is_array($conf->modules_parts['tabs'][$type])) if (isset($conf->modules_parts['tabs'][$type]) && is_array($conf->modules_parts['tabs'][$type]))
{ {
foreach ($conf->modules_parts['tabs'][$type] as $value) foreach ($conf->modules_parts['tabs'][$type] as $value)
@@ -5428,6 +5435,17 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
} }
} }
} }
// No need to make a return $head. Var is modified as a reference
if (! empty($hookmanaer))
{
$parameters=array('object' => $object, 'mode' => $mode, 'head'=>$head);
$reshook=$hookmanager->executeHooks('completeTabsHead',$parameters);
if ($reshook > 0)
{
$head = $hookmanager->resArray;
}
}
} }
/** /**