From ffad80eef6b3a5e15dd7967405a061e9f5671423 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 13 Sep 2018 09:45:07 +0200 Subject: [PATCH 1/5] Standardize and update code --- .../mod_commande_fournisseur_orchidee.php | 4 ++-- .../doc/doc_generic_supplier_proposal_odt.modules.php | 10 +++++----- htdocs/core/modules/ticket/mod_ticket_universal.php | 4 ++-- .../modules/user/doc/doc_generic_user_odt.modules.php | 10 +++++----- .../doc/doc_generic_usergroup_odt.modules.php | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 4639a94279c..fb800d1d63d 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -46,8 +46,8 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders { global $conf,$langs; - $langs->load("bills"); - $langs->load("admin"); + // Load translation files required by the page + $langs->loadLangs(array("bills","admin")); $form = new Form($this->db); diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index da3eb6ef734..a7c2db68a26 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -37,10 +37,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal { - var $emetteur; // Objet societe qui emet + public $emetteur; // Objet societe qui emet - var $phpmin = array(5,2,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; + public $phpmin = array(5,4,0); // Minimum version of PHP required by module + public $version = 'dolibarr'; /** @@ -52,8 +52,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal { global $conf,$langs,$mysoc; - $langs->load("main"); - $langs->load("companies"); + // Load translation files required by the page + $langs->loadLangs(array("main","companies")); $this->db = $db; $this->name = "ODT templates"; diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index 3371a071c8a..c3dad0aa482 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -43,8 +43,8 @@ class mod_ticket_universal extends ModeleNumRefTicket { global $conf, $langs; - $langs->load("ticket"); - $langs->load("admin"); + // Load translation files required by the page + $langs->loadLangs(array("ticket","admin")); $form = new Form($this->db); diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 5318220beb8..041157f20a2 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -35,10 +35,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_user_odt extends ModelePDFUser { - var $emetteur; // Objet societe qui emet + public $emetteur; // Objet societe qui emet - var $phpmin = array(5,2,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; + public $phpmin = array(5,4,0); // Minimum version of PHP required by module + public $version = 'dolibarr'; /** @@ -50,8 +50,8 @@ class doc_generic_user_odt extends ModelePDFUser { global $conf,$langs,$mysoc; - $langs->load("main"); - $langs->load("companies"); + // Load translation files required by the page + $langs->loadLangs(array("main","companies")); $this->db = $db; $this->name = "ODT templates"; diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 887a4cda084..708482f3793 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -37,10 +37,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; */ class doc_generic_usergroup_odt extends ModelePDFUserGroup { - var $emetteur; // Objet societe qui emet + public $emetteur; // Objet societe qui emet - var $phpmin = array(5,2,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; + public $phpmin = array(5,4,0); // Minimum version of PHP required by module + public $version = 'dolibarr'; /** @@ -52,8 +52,8 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup { global $conf,$langs,$mysoc; - $langs->load("main"); - $langs->load("companies"); + // Load translation files required by the page + $langs->loadLangs(array("main","companies")); $this->db = $db; $this->name = "ODT templates"; From be3468241f5f72bd3da8df3c8a2f933184cdd5d3 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 13 Sep 2018 10:55:05 +0200 Subject: [PATCH 2/5] Standardize and update code --- ...terface_50_modAgenda_ActionsAuto.class.php | 311 +++++++----------- 1 file changed, 128 insertions(+), 183 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 6994aa6f3e6..679801692d2 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -82,9 +82,8 @@ class InterfaceActionsAuto extends DolibarrTriggers // Actions if ($action == 'COMPANY_CREATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("companies"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","companies")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name); $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name); @@ -95,9 +94,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'COMPANY_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); @@ -106,9 +104,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'CONTRACT_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("contracts"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","contracts")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -117,9 +114,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'CONTRACT_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("contract"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","contracts")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -132,9 +128,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPAL_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -143,9 +138,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPAL_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -158,9 +152,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPAL_CLOSE_SIGNED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); @@ -169,9 +162,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPAL_CLASSIFY_BILLED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref); @@ -180,9 +172,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPAL_CLOSE_REFUSED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); @@ -191,8 +182,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_VALIDATE') { - $langs->load("agenda"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -201,9 +192,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_CLOSE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref); @@ -212,9 +202,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_CLASSIFY_BILLED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref); @@ -223,9 +212,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_CANCEL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref); @@ -234,9 +222,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -249,9 +236,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -260,9 +246,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_UNVALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills"));; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); @@ -271,9 +256,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -286,9 +270,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_PAYED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills")); // Values for this action can't be defined by caller. $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); @@ -298,9 +281,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_CANCEL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); @@ -309,9 +291,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'FICHINTER_CREATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("interventions"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","interventions")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref); @@ -322,9 +303,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'FICHINTER_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("interventions"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","interventions")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -335,9 +315,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'FICHINTER_MODIFY') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("interventions"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","interventions")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref); @@ -348,9 +327,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'FICHINTER_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("interventions"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","interventions")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -363,9 +341,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'FICHINTER_CLASSIFY_BILLED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("interventions"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","interventions")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref); @@ -374,9 +351,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("interventions"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","interventions")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref); @@ -385,9 +361,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'FICHINTER_DELETE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("interventions"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","interventions")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref); @@ -398,9 +373,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'SHIPPING_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("sendings"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","sendings")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref)); if (empty($object->actionmsg)) @@ -413,9 +387,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'SHIPPING_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("sendings"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","sendings")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -428,9 +401,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -439,9 +411,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -454,9 +425,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); @@ -465,9 +435,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("propal"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","propal")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); @@ -476,9 +445,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SUPPLIER_CREATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -487,9 +455,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -498,9 +465,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SUPPLIER_APPROVE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref); @@ -509,9 +475,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SUPPLIER_REFUSE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref); @@ -520,9 +485,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -531,9 +495,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SUPPLIER_RECEIVE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -542,10 +505,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -558,10 +519,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref); if (empty($object->actionmsg)) @@ -573,9 +532,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills"));; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -584,9 +542,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); @@ -595,10 +552,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); - $langs->load("orders"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills","orders")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref); if (empty($object->actionmsg)) @@ -611,9 +566,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_SUPPLIER_PAYED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); @@ -622,9 +576,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'BILL_SUPPLIER_CANCELED') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("bills"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","bills")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); @@ -635,9 +588,8 @@ class InterfaceActionsAuto extends DolibarrTriggers // Members elseif ($action == 'MEMBER_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("members"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","members")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs)); $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs)); @@ -648,9 +600,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'MEMBER_MODIFY') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("members"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","members")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs)); $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs)); @@ -661,9 +612,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("members"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","members")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs)); $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs)); @@ -677,9 +627,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("members"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","members")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs)); $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs)); @@ -693,9 +642,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("members"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","members")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs)); $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs)); @@ -709,9 +657,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'MEMBER_RESILIATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("members"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","members")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs)); $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs)); @@ -722,9 +669,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } elseif ($action == 'MEMBER_DELETE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("members"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","members")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs)); $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs)); @@ -737,9 +683,8 @@ class InterfaceActionsAuto extends DolibarrTriggers // Projects elseif ($action == 'PROJECT_CREATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("projects"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","projects")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); @@ -747,10 +692,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } - elseif($action == 'PROJECT_VALIDATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("projects"); + elseif($action == 'PROJECT_VALIDATE') + { + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","projects")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref); @@ -758,10 +703,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } - elseif($action == 'PROJECT_MODIFY') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("projects"); + elseif($action == 'PROJECT_MODIFY') + { + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","projects")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref); @@ -771,10 +716,10 @@ class InterfaceActionsAuto extends DolibarrTriggers } // Project tasks - elseif($action == 'TASK_CREATE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("projects"); + elseif($action == 'TASK_CREATE') + { + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","projects")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref); @@ -783,10 +728,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } - elseif($action == 'TASK_MODIFY') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("projects"); + elseif($action == 'TASK_MODIFY') + { + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","projects")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref); @@ -795,10 +740,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } - elseif($action == 'TASK_DELETE') { - $langs->load("agenda"); - $langs->load("other"); - $langs->load("projects"); + elseif($action == 'TASK_DELETE') + { + // Load translation files required by the page + $langs->loadLangs(array("agenda","other","projects")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref); @@ -809,8 +754,8 @@ class InterfaceActionsAuto extends DolibarrTriggers // TODO Merge all previous cases into this generic one else { // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) - $langs->load("agenda"); - $langs->load("other"); + // Load translation files required by the page + $langs->loadLangs(array("agenda","other")); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); if (empty($object->actionmsg)) $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); From 3da762a59da9ee90d6841f2e7578b4264342a1ff Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 13 Sep 2018 15:06:06 +0200 Subject: [PATCH 3/5] Standardize and update code --- htdocs/core/class/html.formsms.class.php | 8 +++----- htdocs/core/datepicker.php | 4 ++-- htdocs/core/photos_resize.php | 4 ++-- htdocs/core/tools.php | 4 ++-- .../core/triggers/interface_80_modStripe_Stripe.class.php | 7 +++---- htdocs/don/document.php | 5 ++--- htdocs/don/list.php | 4 ++-- htdocs/don/note.php | 5 ++--- htdocs/don/stats/index.php | 5 ++--- 9 files changed, 20 insertions(+), 26 deletions(-) diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index a549485ac4c..80e9a5a3de7 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -88,7 +88,6 @@ class FormSms return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Show the form to input an sms. * @@ -96,16 +95,15 @@ class FormSms * @param int $showform Show form tags and submit button (recommanded is to use with value 0) * @return void */ + // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function show_form($morecss='titlefield', $showform=1) { - // phpcs:enable global $conf, $langs, $user, $form; if (! is_object($form)) $form=new Form($this->db); - $langs->load("other"); - $langs->load("mails"); - $langs->load("sms"); + // Load translation files required by the page + $langs->loadLangs(array('other', 'mails', 'sms')); $soc=new Societe($this->db); if (!empty($this->withtosocid) && $this->withtosocid > 0) diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index 074760e88ca..2a7d73dea63 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -41,8 +41,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php -$langs->load("main"); -$langs->load("agenda"); +// Load translation files required by the page +$langs->loadLangs(array("main","agenda")); $right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); $left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 3f266e700cc..f4f178031de 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -28,8 +28,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -$langs->load("products"); -$langs->load("other"); +// Load translation files required by the page +$langs->loadLangs(array("products","other")); $id=GETPOST('id','int'); $action=GETPOST('action','alpha'); diff --git a/htdocs/core/tools.php b/htdocs/core/tools.php index 25e2eb3f903..3ceaaf17d33 100644 --- a/htdocs/core/tools.php +++ b/htdocs/core/tools.php @@ -24,8 +24,8 @@ require '../main.inc.php'; -$langs->load("companies"); -$langs->load("other"); +// Load translation files required by the page +$langs->loadLangs(array("companies","other")); // Security check $socid=0; diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 00a58667f43..246826106f7 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -117,10 +117,9 @@ class InterfaceStripe // Put here code you want to execute when a Dolibarr business events occurs. // Data and type of action are stored into $object and $action global $langs, $db, $conf; - $langs->load("members"); - $langs->load("users"); - $langs->load("mails"); - $langs->load('other'); + + // Load translation files required by the page + $langs->loadLangs(array("members","other","users","mails")); require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); diff --git a/htdocs/don/document.php b/htdocs/don/document.php index 7459bf82453..177b2b82d8b 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -40,9 +40,8 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } -$langs->load("other"); -$langs->load("donations"); -$langs->load("companies"); +// Load translation files required by the page +$langs->loadLangs(array("companies","other","donations")); $id = GETPOST('id','int'); $ref = GETPOST('ref', 'alpha'); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 1e7d93302d8..782a3afba75 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -28,8 +28,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -$langs->load("companies"); -$langs->load("donations"); +// Load translation files required by the page +$langs->loadLangs(array("companies","donations")); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); diff --git a/htdocs/don/note.php b/htdocs/don/note.php index d78aa2c7ea5..3a5c55f7c6d 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -35,9 +35,8 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } -$langs->load("companies"); -$langs->load("bills"); -$langs->load("donations"); +// Load translation files required by the page +$langs->loadLangs(array("companies","bills","donations")); $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility $ref=GETPOST('ref','alpha'); diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index cb574da939a..224e674e9da 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -47,9 +47,8 @@ $year = GETPOST('year')>0?GETPOST('year'):$nowyear; $startyear=$year-1; $endyear=$year; -$langs->load("sendings"); -$langs->load("other"); -$langs->load("companies"); +// Load translation files required by the page +$langs->loadLangs(array("companies","other","sendings")); /* From 51ba970eaf9d0e2c1f8e86a2361044bf8cfad441 Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Fri, 14 Sep 2018 09:33:16 +0200 Subject: [PATCH 4/5] Update html.formsms.class.php --- htdocs/core/class/html.formsms.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 80e9a5a3de7..b7a8c3fb6c4 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -60,9 +60,9 @@ class FormSms var $param=array(); /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; /** From 1d82825afaf3665dadbff8f41a3a249bcfcbd281 Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Sat, 15 Sep 2018 21:34:55 +0200 Subject: [PATCH 5/5] Update html.formsms.class.php --- htdocs/core/class/html.formsms.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index b7a8c3fb6c4..dca795f5419 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -88,16 +88,17 @@ class FormSms return 1; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Show the form to input an sms. * - * @param string $morecss Class on first column td - * @param int $showform Show form tags and submit button (recommanded is to use with value 0) + * @param string $morecss Class on first column td + * @param int $showform Show form tags and submit button (recommanded is to use with value 0) * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function show_form($morecss='titlefield', $showform=1) { + // phpcs:enable global $conf, $langs, $user, $form; if (! is_object($form)) $form=new Form($this->db);