Perf: Optimize class loading. Need 1 MB less of memory to load home
page.
This commit is contained in:
parent
c748f3d834
commit
9012c49299
@ -27,8 +27,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
|
||||||
|
|
||||||
@ -1138,6 +1136,8 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php';
|
||||||
|
|
||||||
$sql = "SELECT c.rowid, c.fk_adherent, c.cotisation, c.note, c.fk_bank,";
|
$sql = "SELECT c.rowid, c.fk_adherent, c.cotisation, c.note, c.fk_bank,";
|
||||||
$sql.= " c.tms as datem,";
|
$sql.= " c.tms as datem,";
|
||||||
$sql.= " c.datec as datec,";
|
$sql.= " c.datec as datec,";
|
||||||
@ -1207,6 +1207,8 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf,$langs,$user;
|
global $conf,$langs,$user;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php';
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
@ -1890,4 +1892,4 @@ class Adherent extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -27,6 +27,7 @@
|
|||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php';
|
||||||
|
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
$langs->load("members");
|
$langs->load("members");
|
||||||
|
|||||||
@ -577,14 +577,14 @@ if ($action == 'create')
|
|||||||
// Project
|
// Project
|
||||||
if (! empty($conf->projet->enabled))
|
if (! empty($conf->projet->enabled))
|
||||||
{
|
{
|
||||||
|
|
||||||
$formproject=new FormProjets($db);
|
$formproject=new FormProjets($db);
|
||||||
|
|
||||||
// Projet associe
|
// Projet associe
|
||||||
$langs->load("project");
|
$langs->load("project");
|
||||||
|
|
||||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
|
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
|
||||||
|
|
||||||
$numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:0),GETPOST("projectid")?GETPOST("projectid"):'','projectid');
|
$numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:0),GETPOST("projectid")?GETPOST("projectid"):'','projectid');
|
||||||
if ($numproject==0)
|
if ($numproject==0)
|
||||||
{
|
{
|
||||||
@ -808,9 +808,9 @@ if ($id > 0)
|
|||||||
// Project
|
// Project
|
||||||
if (! empty($conf->projet->enabled))
|
if (! empty($conf->projet->enabled))
|
||||||
{
|
{
|
||||||
|
|
||||||
$formproject=new FormProjets($db);
|
$formproject=new FormProjets($db);
|
||||||
|
|
||||||
// Projet associe
|
// Projet associe
|
||||||
$langs->load("project");
|
$langs->load("project");
|
||||||
|
|
||||||
@ -831,8 +831,9 @@ if ($id > 0)
|
|||||||
// Object linked
|
// Object linked
|
||||||
if (! empty($act->fk_element) && ! empty($act->elementtype))
|
if (! empty($act->fk_element) && ! empty($act->elementtype))
|
||||||
{
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
print '<tr><td>'.$langs->trans("LinkedObject").'</td>';
|
print '<tr><td>'.$langs->trans("LinkedObject").'</td>';
|
||||||
print '<td colspan="3">'.$act->getElementUrl($act->fk_element,$act->elementtype,1).'</td></tr>';
|
print '<td colspan="3">'.dolGetElementUrl($act->fk_element,$act->elementtype,1).'</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
@ -1015,8 +1016,9 @@ if ($id > 0)
|
|||||||
// Object linked
|
// Object linked
|
||||||
if (! empty($act->fk_element) && ! empty($act->elementtype))
|
if (! empty($act->fk_element) && ! empty($act->elementtype))
|
||||||
{
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
print '<tr><td>'.$langs->trans("LinkedObject").'</td>';
|
print '<tr><td>'.$langs->trans("LinkedObject").'</td>';
|
||||||
print '<td colspan="3">'.$act->getElementUrl($act->fk_element,$act->elementtype,1).'</td></tr>';
|
print '<td colspan="3">'.dolGetElementUrl($act->fk_element,$act->elementtype,1).'</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
|
|||||||
@ -2461,87 +2461,6 @@ abstract class CommonObject
|
|||||||
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions
|
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions
|
||||||
// --------------------
|
// --------------------
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List urls of element
|
|
||||||
*
|
|
||||||
* @param int $objectid Id of record
|
|
||||||
* @param string $objecttype Type of object
|
|
||||||
* @param int $withpicto Picto to show
|
|
||||||
* @param string $option More options
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function getElementUrl($objectid,$objecttype,$withpicto=0,$option='')
|
|
||||||
{
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
// Parse element/subelement (ex: project_task)
|
|
||||||
$module = $element = $subelement = $objecttype;
|
|
||||||
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
|
||||||
{
|
|
||||||
$module = $element = $regs[1];
|
|
||||||
$subelement = $regs[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
$classpath = $element.'/class';
|
|
||||||
|
|
||||||
// To work with non standard path
|
|
||||||
if ($objecttype == 'facture' || $objecttype == 'invoice') {
|
|
||||||
$classpath = 'compta/facture/class'; $module='facture'; $subelement='facture';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'commande' || $objecttype == 'order') {
|
|
||||||
$classpath = 'commande/class'; $module='commande'; $subelement='commande';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'propal') {
|
|
||||||
$classpath = 'comm/propal/class';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'shipping') {
|
|
||||||
$classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'delivery') {
|
|
||||||
$classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'invoice_supplier') {
|
|
||||||
$classpath = 'fourn/class';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'order_supplier') {
|
|
||||||
$classpath = 'fourn/class';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'contract') {
|
|
||||||
$classpath = 'contrat/class'; $module='contrat'; $subelement='contrat';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'member') {
|
|
||||||
$classpath = 'adherents/class'; $module='adherent'; $subelement='adherent';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'cabinetmed_cons') {
|
|
||||||
$classpath = 'cabinetmed/class'; $module='cabinetmed'; $subelement='cabinetmedcons';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'fichinter') {
|
|
||||||
$classpath = 'fichinter/class'; $module='ficheinter'; $subelement='fichinter';
|
|
||||||
}
|
|
||||||
|
|
||||||
//print "objecttype=".$objecttype." module=".$module." subelement=".$subelement;
|
|
||||||
|
|
||||||
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
|
||||||
if ($objecttype == 'invoice_supplier') {
|
|
||||||
$classfile = 'fournisseur.facture'; $classname='FactureFournisseur';
|
|
||||||
}
|
|
||||||
if ($objecttype == 'order_supplier') {
|
|
||||||
$classfile = 'fournisseur.commande'; $classname='CommandeFournisseur';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! empty($conf->$module->enabled))
|
|
||||||
{
|
|
||||||
$res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
|
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
$object = new $classname($this->db);
|
|
||||||
$ret=$object->fetch($objectid);
|
|
||||||
if ($ret > 0) return $object->getNomUrl($withpicto,$option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is to show linked object block */
|
/* This is to show linked object block */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -24,6 +24,10 @@
|
|||||||
* This file contains all rare functions.
|
* This file contains all rare functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Enable this line to trace path when function is called.
|
||||||
|
//print xdebug_print_function_stack('Functions2.lib was called');exit;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same function than javascript unescape() function but in PHP.
|
* Same function than javascript unescape() function but in PHP.
|
||||||
*
|
*
|
||||||
@ -1418,3 +1422,88 @@ function getSoapParams()
|
|||||||
}
|
}
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List urls of element
|
||||||
|
*
|
||||||
|
* @param int $objectid Id of record
|
||||||
|
* @param string $objecttype Type of object ('invoice', 'order', 'expedition_bon', ...)
|
||||||
|
* @param int $withpicto Picto to show
|
||||||
|
* @param string $option More options
|
||||||
|
* @return string URL of link to object id/type
|
||||||
|
*/
|
||||||
|
function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='')
|
||||||
|
{
|
||||||
|
global $db,$conf;
|
||||||
|
|
||||||
|
$ret='';
|
||||||
|
|
||||||
|
// Parse element/subelement (ex: project_task)
|
||||||
|
$module = $element = $subelement = $objecttype;
|
||||||
|
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
||||||
|
{
|
||||||
|
$module = $element = $regs[1];
|
||||||
|
$subelement = $regs[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
$classpath = $element.'/class';
|
||||||
|
|
||||||
|
// To work with non standard path
|
||||||
|
if ($objecttype == 'facture' || $objecttype == 'invoice') {
|
||||||
|
$classpath = 'compta/facture/class'; $module='facture'; $subelement='facture';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'commande' || $objecttype == 'order') {
|
||||||
|
$classpath = 'commande/class'; $module='commande'; $subelement='commande';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'propal') {
|
||||||
|
$classpath = 'comm/propal/class';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'shipping') {
|
||||||
|
$classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'delivery') {
|
||||||
|
$classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'invoice_supplier') {
|
||||||
|
$classpath = 'fourn/class';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'order_supplier') {
|
||||||
|
$classpath = 'fourn/class';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'contract') {
|
||||||
|
$classpath = 'contrat/class'; $module='contrat'; $subelement='contrat';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'member') {
|
||||||
|
$classpath = 'adherents/class'; $module='adherent'; $subelement='adherent';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'cabinetmed_cons') {
|
||||||
|
$classpath = 'cabinetmed/class'; $module='cabinetmed'; $subelement='cabinetmedcons';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'fichinter') {
|
||||||
|
$classpath = 'fichinter/class'; $module='ficheinter'; $subelement='fichinter';
|
||||||
|
}
|
||||||
|
|
||||||
|
//print "objecttype=".$objecttype." module=".$module." subelement=".$subelement;
|
||||||
|
|
||||||
|
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
||||||
|
if ($objecttype == 'invoice_supplier') {
|
||||||
|
$classfile = 'fournisseur.facture'; $classname='FactureFournisseur';
|
||||||
|
}
|
||||||
|
if ($objecttype == 'order_supplier') {
|
||||||
|
$classfile = 'fournisseur.commande'; $classname='CommandeFournisseur';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($conf->$module->enabled))
|
||||||
|
{
|
||||||
|
$res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
|
||||||
|
if ($res)
|
||||||
|
{
|
||||||
|
$object = new $classname($db);
|
||||||
|
$res=$object->fetch($objectid);
|
||||||
|
if ($res > 0) $ret=$object->getNomUrl($withpicto,$option);
|
||||||
|
unset($object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user