mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
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:
parent
a862b5d5c3
commit
ff06360071
|
|
@ -73,12 +73,13 @@ class modMyModule extends DolibarrModules
|
|||
// for specific path of parts (eg: /mymodule/core/modules/barcode)
|
||||
// for specific css file (eg: /mymodule/css/mymodule.css.php)
|
||||
//$this->module_parts = array(
|
||||
// 'triggers' => 0, // Set this to 1 if module has its own trigger directory
|
||||
// 'login' => 0, // Set this to 1 if module has its own login method directory
|
||||
// 'substitutions' => 0, // Set this to 1 if module has its own substitution function file
|
||||
// 'menus' => 0, // Set this to 1 if module has its own menus handler directory
|
||||
// 'barcode' => 0, // Set this to 1 if module has its own barcode directory
|
||||
// 'models' => 0, // Set this to 1 if module has its own models directory
|
||||
// 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
|
||||
// 'login' => 0, // Set this to 1 if module has its own login method directory (core/login)
|
||||
// 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions)
|
||||
// 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
|
||||
// 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
|
||||
// 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
|
||||
// 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
|
||||
// 'css' => '/mymodule/css/mymodule.css.php', // Set this to relative path of css if module has its own css file
|
||||
// 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module
|
||||
// 'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) // Set here all workflow context managed by module
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ $barcodelist=array();
|
|||
clearstatcache();
|
||||
|
||||
|
||||
// Check if there is external substitution to do asked by plugins
|
||||
$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->barcode_modules);
|
||||
// Scan list of all barcode included provided by external modules
|
||||
$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->modules_parts['barcode']);
|
||||
|
||||
foreach($dirbarcode as $reldir)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref))
|
|||
if (is_null($object->client)) $object->fetch_thirdparty();
|
||||
print "<tr><td>".$langs->trans("Company")."</td>";
|
||||
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
|
||||
|
||||
|
||||
// Delivery address
|
||||
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
|
||||
{
|
||||
|
|
@ -182,11 +182,11 @@ if ($id > 0 || ! empty($ref))
|
|||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
|
||||
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&socid='.$object->socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
|
||||
|
||||
if ($action == 'editdelivery_address')
|
||||
{
|
||||
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id);
|
||||
|
|
@ -201,19 +201,17 @@ if ($id > 0 || ! empty($ref))
|
|||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Contacts lines
|
||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"))
|
||||
|
||||
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
|
||||
foreach($dirtpls as $reldir)
|
||||
{
|
||||
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php");
|
||||
$res=@include(dol_buildpath($reldir.'/contacts.tpl.php'));
|
||||
if ($res) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -221,6 +219,7 @@ if ($id > 0 || ! empty($ref))
|
|||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
?>
|
||||
|
|
@ -137,7 +137,7 @@ dol_htmloutput_mesg($mesg);
|
|||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$langs->trans("OrderCard");
|
||||
|
||||
|
||||
if ($object->fetch($id, $ref) > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
|
|
@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref))
|
|||
|
||||
print "<tr><td>".$langs->trans("Company")."</td>";
|
||||
print '<td colspan="3">'.$object->client->getNomUrl(1).'</td></tr>';
|
||||
|
||||
|
||||
// Delivery address
|
||||
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
|
||||
{
|
||||
|
|
@ -182,11 +182,11 @@ if ($id > 0 || ! empty($ref))
|
|||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
|
||||
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&socid='.$object->socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
|
||||
|
||||
if ($action == 'editdelivery_address')
|
||||
{
|
||||
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id);
|
||||
|
|
@ -197,23 +197,20 @@ if ($id > 0 || ! empty($ref))
|
|||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Select template for Contacts lines
|
||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"))
|
||||
{
|
||||
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
|
||||
}
|
||||
|
||||
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
|
||||
foreach($dirtpls as $reldir)
|
||||
{
|
||||
$res=@include(dol_buildpath($reldir.'/contacts.tpl.php'));
|
||||
if ($res) break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
|||
$langs->load("bills");
|
||||
$langs->load("companies");
|
||||
|
||||
$id = (GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
|
||||
$id = (GETPOST('id')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
|
||||
$ref = GETPOST('ref','alpha');
|
||||
$lineid = GETPOST('lineid','int');
|
||||
$socid = GETPOST('socid','int');
|
||||
|
|
@ -57,7 +57,7 @@ if ($action == 'addcontact' && $user->rights->facture->creer)
|
|||
|
||||
if ($result > 0 && $id > 0)
|
||||
{
|
||||
$contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
|
||||
$contactid = (GETPOST('userid') ? GETPOST('userid','int') : GETPOST('contactid','int'));
|
||||
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
|
||||
}
|
||||
|
||||
|
|
@ -169,15 +169,13 @@ if ($id > 0 || ! empty($ref))
|
|||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Contacts lines
|
||||
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"))
|
||||
|
||||
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
|
||||
foreach($dirtpls as $reldir)
|
||||
{
|
||||
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
|
||||
$res=@include(dol_buildpath($reldir.'/contacts.tpl.php'));
|
||||
if ($res) break;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,18 +52,18 @@ class Conf
|
|||
public $smart_menu;
|
||||
|
||||
public $modules = array(); // List of activated modules
|
||||
public $modules_parts = array(); // List of modules parts
|
||||
public $modules_parts = array('triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array()); // List of modules parts
|
||||
|
||||
// TODO Remove all thoose tabs with one generic
|
||||
public $triggers_modules = array();
|
||||
public $login_modules = array();
|
||||
public $substitutions_modules = array();
|
||||
public $menus_modules = array();
|
||||
public $barcode_modules = array();
|
||||
public $sms_engine_modules = array();
|
||||
public $css_modules = array();
|
||||
public $tabs_modules = array();
|
||||
public $triggers_modules = array();
|
||||
public $menus_modules = array();
|
||||
public $hooks_modules = array();
|
||||
public $login_modules = array();
|
||||
public $barcode_modules = array();
|
||||
public $substitutions_modules = array();
|
||||
public $societe_modules = array();
|
||||
|
||||
var $logbuffer = array();
|
||||
|
|
@ -188,7 +188,7 @@ class Conf
|
|||
if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); }
|
||||
$arrValue = json_decode($value,true);
|
||||
if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue;
|
||||
else if (in_array($partname,array('login','menus','substitutions','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/';
|
||||
else if (in_array($partname,array('login','menus','substitutions','triggers','tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/';
|
||||
else if (in_array($partname,array('models'))) $value = '/'.$modulename.'/';
|
||||
else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/';
|
||||
$this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class Interfaces
|
|||
$orders = array();
|
||||
$i=0;
|
||||
|
||||
$dirtriggers=array_merge(array('/core/triggers'),$conf->triggers_modules);
|
||||
$dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']);
|
||||
foreach($dirtriggers as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
|
|
@ -203,7 +203,7 @@ class Interfaces
|
|||
$orders = array();
|
||||
$i = 0;
|
||||
|
||||
$dirtriggers=array_merge(array('/core/triggers/'),$conf->triggers_modules);
|
||||
$dirtriggers=array_merge(array('/core/triggers/'),$conf->modules_parts['triggers']);
|
||||
foreach($dirtriggers as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
|
|
|
|||
|
|
@ -591,7 +591,7 @@ class Translate
|
|||
|
||||
$newnumber=$number;
|
||||
|
||||
$dirsubstitutions=array_merge(array(),$conf->substitutions_modules);
|
||||
$dirsubstitutions=array_merge(array(),$conf->modules_parts['substitutions']);
|
||||
foreach($dirsubstitutions as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
|
|
|
|||
|
|
@ -3361,7 +3361,7 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='
|
|||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
|
||||
// Check if there is external substitution to do asked by plugins
|
||||
$dirsubstitutions=array_merge(array(),$conf->substitutions_modules);
|
||||
$dirsubstitutions=array_merge(array(),$conf->modules_parts['substitutions']);
|
||||
|
||||
foreach($dirsubstitutions as $reldir)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ if (! defined('NOREQUIRETRAN'))
|
|||
if ($conf->global->MAIN_USE_TEMPLATE_ENGINE && ! defined('NOTEMPLATEENGINE'))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT.'/includes/savant/Savant3.php');
|
||||
|
||||
|
||||
$tpl = new Savant3();
|
||||
}
|
||||
|
||||
|
|
@ -1181,7 +1181,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
|||
if (! class_exists('MenuTop'))
|
||||
{
|
||||
$menufound=0;
|
||||
$dirmenus=array_merge(array("/core/menus/"),$conf->menus_modules);
|
||||
$dirmenus=array_merge(array("/core/menus/"),$conf->modules_parts['menus']);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$menufound=dol_include_once($dirmenu."standard/".$top_menu);
|
||||
|
|
@ -1387,7 +1387,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
|||
if (! class_exists('MenuLeft'))
|
||||
{
|
||||
$menufound=0;
|
||||
$dirmenus=array_merge(array("/core/menus/"),$conf->menus_modules);
|
||||
$dirmenus=array_merge(array("/core/menus/"),$conf->modules_parts['menus']);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$menufound=dol_include_once($dirmenu."standard/".$left_menu);
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ if ($modulepart == 'barcode')
|
|||
$encoding=$_GET["encoding"];
|
||||
$readable=$_GET["readable"]?$_GET["readable"]:"Y";
|
||||
|
||||
$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->barcode_modules);
|
||||
$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->modules_parts['barcode']);
|
||||
|
||||
$result=0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user