Fix: Overwritting code is not role of a template but of a module.

Code is now working as a module change. Also it is faster (no need to
make a failed include when module is not installed) and support
alternative directory.
This commit is contained in:
Laurent Destailleur 2012-04-29 11:00:28 +02:00
parent 5c46c3bcbb
commit 96a90e2e7a

View File

@ -2352,7 +2352,13 @@ abstract class CommonObject
global $linkedObjectBlock; global $linkedObjectBlock;
$linkedObjectBlock = $objects; $linkedObjectBlock = $objects;
dol_include_once('/'.$tplpath.'/tpl/linkedobjectblock.tpl.php'); // Output template part (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include(dol_buildpath($reldir.'/linkedobjectblock.tpl.php'));
if ($res) break;
}
} }
return $num; return $num;
@ -2378,14 +2384,13 @@ abstract class CommonObject
global $conf,$langs,$object; global $conf,$langs,$object;
global $form,$bcnd,$var; global $form,$bcnd,$var;
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_create.tpl.php")) $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{ {
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_create.tpl.php"); $res=@include(dol_buildpath($reldir.'/predefinedproductline_create.tpl.php'));
} if ($res) break;
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php');
} }
} }
@ -2405,14 +2410,13 @@ abstract class CommonObject
global $conf,$langs,$object; global $conf,$langs,$object;
global $form,$bcnd,$var; global $form,$bcnd,$var;
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_create.tpl.php")) $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{ {
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_create.tpl.php"); $res=@include(dol_buildpath($reldir.'/freeproductline_create.tpl.php'));
} if ($res) break;
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php');
} }
} }
@ -2551,26 +2555,24 @@ abstract class CommonObject
$text.= ' - '.$label; $text.= ' - '.$label;
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description));
// Use global variables + $seller and $buyer // Output template part (modules that overwrite templates must declare this into descriptor)
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_view.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_view.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_view.tpl.php');
}
}
else
{
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_view.tpl.php")) $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{ {
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_view.tpl.php"); $res=@include(dol_buildpath($reldir.'/predefinedproductline_view.tpl.php'));
if ($res) break;
}
} }
else else
{ {
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_view.tpl.php'); // Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include(dol_buildpath($reldir.'/freeproductline_view.tpl.php'));
if ($res) break;
} }
} }
} }
@ -2580,26 +2582,24 @@ abstract class CommonObject
{ {
if ($line->fk_product > 0) if ($line->fk_product > 0)
{ {
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_edit.tpl.php")) $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{ {
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_edit.tpl.php"); $res=@include(dol_buildpath($reldir.'/predefinedproductline_edit.tpl.php'));
} if ($res) break;
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_edit.tpl.php');
} }
} }
else else
{ {
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_edit.tpl.php")) $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{ {
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_edit.tpl.php"); $res=@include(dol_buildpath($reldir.'/freeproductline_edit.tpl.php'));
} if ($res) break;
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_edit.tpl.php');
} }
} }
} }
@ -2740,13 +2740,13 @@ abstract class CommonObject
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' ';
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' ';
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/originproductline.tpl.php")) // Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{ {
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/originproductline.tpl.php"); $res=@include(dol_buildpath($reldir.'/originproductline.tpl.php'));
} if ($res) break;
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/originproductline.tpl.php');
} }
} }
} }