Skip to content
Snippets Groups Projects
Commit 96a90e2e authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

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.
parent 5c46c3bc
No related branches found
No related tags found
No related merge requests found
......@@ -2352,7 +2352,13 @@ abstract class CommonObject
global $linkedObjectBlock;
$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;
......@@ -2378,14 +2384,13 @@ abstract class CommonObject
global $conf,$langs,$object;
global $form,$bcnd,$var;
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_create.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_create.tpl.php");
}
else
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php');
$res=@include(dol_buildpath($reldir.'/predefinedproductline_create.tpl.php'));
if ($res) break;
}
}
......@@ -2405,14 +2410,13 @@ abstract class CommonObject
global $conf,$langs,$object;
global $form,$bcnd,$var;
// Output template part (modules that overwrite templates must declare this into descriptor)
// 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");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php');
$res=@include(dol_buildpath($reldir.'/freeproductline_create.tpl.php'));
if ($res) break;
}
}
......@@ -2551,27 +2555,25 @@ abstract class CommonObject
$text.= ' - '.$label;
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description));
// Use global variables + $seller and $buyer
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');
}
// 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.'/predefinedproductline_view.tpl.php'));
if ($res) break;
}
}
else
{
// Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_view.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_view.tpl.php");
}
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,27 +2582,25 @@ abstract class CommonObject
{
if ($line->fk_product > 0)
{
// Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_edit.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_edit.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_edit.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.'/predefinedproductline_edit.tpl.php'));
if ($res) break;
}
}
else
{
// Use global variables + $dateSelector + $seller and $buyer
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_edit.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_edit.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_edit.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_edit.tpl.php'));
if ($res) break;
}
}
}
}
......@@ -2739,15 +2739,15 @@ abstract class CommonObject
$this->tpl['price'] = price($line->subprice);
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' ';
$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"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/originproductline.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/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)
{
$res=@include(dol_buildpath($reldir.'/originproductline.tpl.php'));
if ($res) break;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment