Add number of collected tabs and hook/trigger

Add number of collected tabs 
Add trigger based on tabs name
add hook at end of tabs and at the footer of page
This commit is contained in:
BENKE Charlie 2015-08-05 15:19:00 +02:00
parent 1dac1932a9
commit 4709a51c84

View File

@ -702,8 +702,9 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto
*/ */
function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0) function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0)
{ {
global $conf,$langs; global $conf,$langs, $hookmanager;;
$tabsname=str_replace ("@","",$picto);
$out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n"; $out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n";
// Show title // Show title
@ -731,6 +732,7 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
// if =0 we don't use the feature // if =0 we don't use the feature
$limittoshow=(empty($conf->global->MAIN_MAXTABS_IN_CARD)?99:$conf->global->MAIN_MAXTABS_IN_CARD); $limittoshow=(empty($conf->global->MAIN_MAXTABS_IN_CARD)?99:$conf->global->MAIN_MAXTABS_IN_CARD);
$displaytab=0; $displaytab=0;
$nbintab=0;
for ($i = 0 ; $i <= $maxkey ; $i++) for ($i = 0 ; $i <= $maxkey ; $i++)
{ {
@ -746,6 +748,8 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
if ($i <= $limittoshow || $isactive ) if ($i <= $limittoshow || $isactive )
{ {
if ($isactive) $hookmanager->initHooks(array($tabsname."-".$links[$i][2]. '-tabs'));
$out.='<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'"><!-- id tab = '.(empty($links[$i][2])?'':$links[$i][2]).' -->'; $out.='<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'"><!-- id tab = '.(empty($links[$i][2])?'':$links[$i][2]).' -->';
if (isset($links[$i][2]) && $links[$i][2] == 'image') if (isset($links[$i][2]) && $links[$i][2] == 'image')
{ {
@ -787,6 +791,7 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
$outmore.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; $outmore.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
$outmore.='</div>'; $outmore.='</div>';
$nbintab++;
} }
$displaytab=$i; $displaytab=$i;
} }
@ -795,7 +800,7 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
{ {
$tabsname=str_replace("@", "", $picto); $tabsname=str_replace("@", "", $picto);
$out.='<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">'; $out.='<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">';
$out.='<a href="" data-role="button" style="background-color: #f0f0f0;" class="tab inline-block">'.$langs->trans("More").'...</a>'; $out.='<a href="" data-role="button" style="background-color: #f0f0f0;" class="tab inline-block">'.$langs->trans("More").' <span class="badge">'.$nbintab.'.'</span></a>';
$out.='<div id="moretabsList'.$tabsname.'" style="position: absolute; left: -999em;text-align: left;margin:0px;padding:2px">'.$outmore.'</div>'; $out.='<div id="moretabsList'.$tabsname.'" style="position: absolute; left: -999em;text-align: left;margin:0px;padding:2px">'.$outmore.'</div>';
$out.="</div>\n"; $out.="</div>\n";
@ -809,6 +814,9 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
if (! $notab) $out.="\n".'<div class="tabBar">'."\n"; if (! $notab) $out.="\n".'<div class="tabBar">'."\n";
$parameters=array();
$reshook=$hookmanager->executeHooks('printTabsHead',$parameters); // Note that $action and $object may have been modified by some hooks
return $out; return $out;
} }
@ -4898,7 +4906,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
*/ */
function printCommonFooter($zone='private') function printCommonFooter($zone='private')
{ {
global $conf; global $conf, $hookmanager;
global $micro_start_time; global $micro_start_time;
if ($zone == 'private') print "\n".'<!-- Common footer for private page -->'."\n"; if ($zone == 'private') print "\n".'<!-- Common footer for private page -->'."\n";
@ -4976,6 +4984,9 @@ function printCommonFooter($zone='private')
print "End of log output -->\n"; print "End of log output -->\n";
} }
$parameters=array();
$reshook=$hookmanager->executeHooks('printCommonFooter',$parameters); // Note that $action and $object may have been modified by some hooks
} }
/** /**