Perf: Avoid to isntantiate object 'form' into 'subform' classes when

already available.
Qual: Better information into xdebug page.
This commit is contained in:
Laurent Destailleur 2014-05-01 16:26:57 +02:00
parent ee6cac8294
commit b56f59b313
11 changed files with 59 additions and 44 deletions

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2009-2014 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -53,13 +53,27 @@ if (function_exists('socket_create'))
$port = ini_get('xdebug.remote_port')?ini_get('xdebug.remote_port'):9000;
print "<strong>Current xdebug setup:</strong><br>\n";
print "* Remote debug setup:<br>\n";
print 'xdebug.remote_enable = '.ini_get('xdebug.remote_enable')."<br>\n";
print 'xdebug.remote_host = '.$address."<br>\n";
print 'xdebug.remote_port = '.$port."<br>\n";
print 'xdebug.profiler_output_dir = '.ini_get('xdebug.profiler_output_dir')."<br>\n";
print "* Profiler setup ";
if (function_exists('xdebug_get_profiler_filename')) print xdebug_get_profiler_filename()?"(currently on into file ".xdebug_get_profiler_filename().")":"(currently off)";
else print "(currenlty not available)";
print ":<br>\n";
print 'xdebug.profiler_enable = '.ini_get('xdebug.profiler_enable')."<br>\n";
print 'xdebug.profiler_enable_trigger = '.ini_get('xdebug.profiler_enable_trigger')."<br>\n";
print 'xdebug.profiler_output_dir = '.ini_get('xdebug.profiler_output_dir')."<br>\n";
print 'xdebug.profiler_output_name = '.ini_get('xdebug.profiler_output_name')."<br>\n";
print 'xdebug.profiler_append = '.ini_get('xdebug.profiler_append')."<br>\n";
print "<br>\n";
echo "To run a debug session, add parameter<br>";
echo "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.<br>\n";
echo "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter<br>\n";
echo "* XDEBUG_PROFILE=aname on each URL.<br>";
print "<br>";
print "<strong>Test debugger server (Eclipse for example):</strong><br>\n";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (empty($socket)) die('Unable to prepare a socket');
@ -94,7 +108,6 @@ xdebug.auto_trace=0
XDebug with same port than in php.ini<br>
Allow Remote debug=yes or prompt<br>'."\n";
print "<br>\n";
echo "Then, to run a debug session (when xdebug.profiler_enable_trigger=1), add parameter XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.\n";
}
else
{

View File

@ -195,11 +195,10 @@ $langs->load("cashdesk");
<tr>
<td>
<input class="bouton_mode_reglement" type="submit" name="btnModeReglement" value="<?php echo $langs->trans("Reported"); ?>" onclick="javascript: verifClic('DIF');" />
<?php echo $langs->trans("DateEcheance"); ?> :
<?php
$form=new Form($db);
print $form->select_date(-1,'txtDatePaiement');
?>
<?php
echo $langs->trans("DateEcheance").' :';
print $form->select_date(-1,'txtDatePaiement');
?>
<!-- <input class="texte2" type="text" id="txtDatePaiement" name="txtDatePaiement" value="" />
<input class="bouton_cal" type="image" src="img/calendrier.png" id="btnCalendrier" value="..." title="<?php echo $langs->trans("CalTip"); ?>" />
-->

View File

@ -14,7 +14,6 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
$langs->load("main");
@ -105,7 +104,6 @@ $langs->load("main");
<p class="note_label">
<?php
echo $langs->trans("BankToPay"). "<br>";
$form = new Form($db);
$form->select_comptes($selected,'cashdeskbank',0,$filtre);
?>
</p>

View File

@ -27,6 +27,7 @@
* \brief File of class to manage extra fields
*/
/**
* Class to manage standard extra fields
*/
@ -581,7 +582,7 @@ class ExtraFields
*/
function showInputField($key,$value,$moreparam='',$keyprefix='')
{
global $conf,$langs,$db;
global $conf,$langs;
$label=$this->attribute_label[$key];
$type =$this->attribute_type[$key];
@ -612,17 +613,18 @@ class ExtraFields
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
if(!class_exists('Form'))
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$formstat = new Form($db);
$showtime = in_array($type,array('datetime')) ? 1 : 0;
// Do not show current date when field not required (see select_date() method)
if(!$required && $value == '')
$value = '-1';
$out = $formstat->select_date($value, 'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
// TODO Missing to add $moreparam
// Do not show current date when field not required (see select_date() method)
if (!$required && $value == '') $value = '-1';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
global $form;
if (! is_object($form)) $form=new Form($this->db);
// TODO Must also support $moreparam
$out = $form->select_date($value, 'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
}
elseif (in_array($type,array('int')))
{

View File

@ -3783,7 +3783,7 @@ class Form
/**
* Show a select form from an array
* Return a HTML select string, built from an array of key+value.
*
* @param string $htmlname Name of html select area
* @param array $array Array with key+value
@ -3799,7 +3799,7 @@ class Form
* @param string $morecss Add more class to css styles
* @return string HTML select string
*/
function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='')
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='')
{
global $langs;

View File

@ -144,7 +144,7 @@ class FormActions
global $bc;
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement);
if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions');
@ -217,12 +217,13 @@ class FormActions
*/
function select_type_actions($selected='',$htmlname='actioncode',$excludetype='',$onlyautoornot=0)
{
global $langs,$user;
global $langs,$user,$form;
if (! is_object($form)) $form=new Form($db);
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$caction=new CActionComm($this->db);
$form=new Form($this->db);
// Suggest a list with manual events or all auto events
$arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot);
@ -231,7 +232,7 @@ class FormActions
if ($selected == 'manual') $selected='AC_OTH';
if ($selected == 'auto') $selected='AC_OTH_AUTO';
print $form->selectarray($htmlname, $arraylist, $selected);
if ($user->admin && empty($onlyautoornot)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}

View File

@ -257,8 +257,10 @@ class FormFile
*/
function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='')
{
global $langs,$conf,$hookmanager,$user,$bc;
global $langs,$conf,$hookmanager,$user,$form,$bc;
if (! is_object($form)) $form=new Form($this->db);
// filedir = $conf->...->dir_ouput."/".get_exdir(id)
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -446,7 +448,6 @@ class FormFile
$headershown=1;
$form = new Form($this->db);
$buttonlabeltoshow=$buttonlabel;
if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate');

View File

@ -219,8 +219,10 @@ class FormMail
*/
function get_form($addfileaction='addfile',$removefileaction='removefile')
{
global $conf, $langs, $user, $hookmanager;
global $conf, $langs, $user, $hookmanager, $form;
if (! is_object($form)) $form=new Form($this->db);
$langs->load("other");
$langs->load("mails");
@ -248,8 +250,6 @@ class FormMail
if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
$form=new Form($this->db);
$out.= "\n<!-- Debut form mail -->\n";
if ($this->withform == 1)
{

View File

@ -97,7 +97,7 @@ class FormOrder
/**
* Return list of input method (mode used to receive order, like order received by email, fax, online)
* List found into table c_input_method
* List found into table c_input_method.
*
* @param string $selected Id of preselected input method
* @param string $htmlname Name of HTML select list
@ -106,12 +106,12 @@ class FormOrder
*/
function selectInputMethod($selected='',$htmlname='source_id',$addempty=0)
{
global $conf,$langs;
$listofmethods=array();
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$form=new Form($this->db);
global $conf,$langs,$form;
if (! is_object($form)) $form=new Form($this->db);
$listofmethods=array();
$sql = "SELECT rowid, code, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_input_method";
$sql.= " WHERE active = 1";

View File

@ -900,7 +900,8 @@ class FormOther
/**
* Show a HTML Tab with boxes of a particular area including personalized choices of user
* Show a HTML Tab with boxes of a particular area including personalized choices of user.
* Class 'Form' must be known.
*
* @param User $user Object User
* @param String $areacode Code of area for pages (0=value for Home page)
@ -933,9 +934,8 @@ class FormOther
if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')';
$arrayboxtoactivatelabel[$box->id]=$label; // We keep only boxes not shown for user, to show into combo list
}
$form=new Form($db);
$selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel,'',1);
// Class Form must have been already loaded
$selectboxlist=Form::selectarray('boxcombo', $arrayboxtoactivatelabel,'',1);
}
// Javascript code for dynamic actions

View File

@ -24,7 +24,7 @@
require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
/**
/**
* Classe permettant la generation du formulaire d'envoi de Sms
* Usage: $formsms = new FormSms($db)
* $formsms->proprietes=1 ou chaine ou tableau de valeurs
@ -83,20 +83,21 @@ class FormSms
}
/**
* Show the form to input an sms
* Show the form to input an sms.
*
* @param string $width Width of form
* @return void
*/
function show_form($width='180px')
{
global $conf, $langs, $user;
global $conf, $langs, $user, $form;
if (! is_object($form)) $form=new Form($this->db);
$langs->load("other");
$langs->load("mails");
$langs->load("sms");
$form=new Form($this->db);
$soc=new Societe($this->db);
if (!empty($this->withtosocid) && $this->withtosocid > 0)
{