From 2d19624a149010c3c9cc53797109d490a4f1e5df Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 11 Nov 2011 11:15:36 +0100 Subject: [PATCH] Fix: reindenting and docgen --- htdocs/core/class/html.form.class.php | 560 +++++++++++++------------- 1 file changed, 280 insertions(+), 280 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3ad8972b97e..c31f23eeb4e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -41,154 +41,154 @@ */ class Form { - var $db; - var $error; - - // Cache arrays - var $cache_types_paiements=array(); - var $cache_conditions_paiements=array(); - var $cache_availability=array(); + var $db; + var $error; + + // Cache arrays + var $cache_types_paiements=array(); + var $cache_conditions_paiements=array(); + var $cache_availability=array(); var $cache_demand_reason=array(); var $cache_type_fees=array(); - - var $tva_taux_value; - var $tva_taux_libelle; - - - /** - * Constructor + + var $tva_taux_value; + var $tva_taux_libelle; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + /** + * Output key field for an editable field + * + * @param string $text Text of label or key to translate + * @param string $htmlname Name of select field + * @param string $preselected Name of Value to show/edit (not used in this function) + * @param object $object Object + * @param boolean $perm Permission to allow button to edit parameter + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) + * @return string HTML edit field + */ + function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string') + { + global $conf,$langs; + + $ret=''; + + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + { + if ($perm) + { + $tmp=explode(':',$typeofdata); + $ret.= '
'; + $ret.= $langs->trans($text); + $ret.= '
'."\n"; + } + else + { + $ret.= $langs->trans($text); + } + } + else + { + $ret.=''; + if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; + $ret.='
'; + $ret.=$langs->trans($text); + $ret.='id.'">'.img_edit($langs->trans('Edit'),1).'
'; + } + + return $ret; + } + + /** + * Output val field for an editable field + * + * @param string $text Text of label (not used in this function) + * @param string $htmlname Name of select field + * @param string $value Value to show/edit + * @param object $object Object + * @param boolean $perm Permission to allow button to edit parameter + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) + * @param string $editvalue When in edit mode, use this value as $value instead of value + * @param object $extObject External object + * @return string HTML edit field + */ + function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=false) + { + global $conf,$langs,$db; + + $ret=''; + + // When option to edit inline is activated + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + { + $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject); + } + else + { + if (GETPOST('action') == 'edit'.$htmlname) + { + $ret.="\n"; + $ret.='
'; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.=''; + $ret.=''; + if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; + $ret.='
'; + if (preg_match('/^(string|email|numeric)/',$typeofdata)) + { + $tmp=explode(':',$typeofdata); + $ret.=''; + } + else if ($typeofdata == 'text' || $typeofdata == 'textarea' || $typeofdata == 'note') + { + $ret.=''; + } + else if ($typeofdata == 'day' || $typeofdata == 'datepicker') + { + $ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname); + } + else if (preg_match('/^ckeditor/',$typeofdata)) + { + $tmp=explode(':',$typeofdata); + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true); + $ret.=$doleditor->Create(1); + } + $ret.='
'."\n"; + $ret.='
'."\n"; + } + else + { + if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); + elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); + elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); + else if (preg_match('/^ckeditor/',$typeofdata)) + { + $tmpcontent=dol_htmlentitiesbr($value); + $firstline=preg_replace('/
.*/','',$tmpcontent); + $firstline=preg_replace('/[\n\r].*/','',$firstline); + $ret.=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); + } + else $ret.=$value; + } + } + return $ret; + } + + /** + * Output edit in place form * - * @param DoliDB $DB Database handler - */ - public function __construct($db) - { - $this->db = $db; - } - - /** - * Output key field for an editable field - * - * @param string $text Text of label or key to translate - * @param string $htmlname Name of select field - * @param string $preselected Name of Value to show/edit (not used in this function) - * @param object $object Object - * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) - * @return string HTML edit field - */ - function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string') - { - global $conf,$langs; - - $ret=''; - - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) - { - if ($perm) - { - $tmp=explode(':',$typeofdata); - $ret.= '
'; - $ret.= $langs->trans($text); - $ret.= '
'."\n"; - } - else - { - $ret.= $langs->trans($text); - } - } - else - { - $ret.=''; - if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; - $ret.='
'; - $ret.=$langs->trans($text); - $ret.='id.'">'.img_edit($langs->trans('Edit'),1).'
'; - } - - return $ret; - } - - /** - * Output val field for an editable field - * - * @param string $text Text of label (not used in this function) - * @param string $htmlname Name of select field - * @param string $value Value to show/edit - * @param object $object Object - * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) - * @param string $editvalue When in edit mode, use this value as $value instead of value - * @param object $extObject External object - * @return string HTML edit field - */ - function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=false) - { - global $conf,$langs,$db; - $ret=''; - - // When option to edit inline is activated - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) - { - $ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $extObject); - } - else - { - if (GETPOST('action') == 'edit'.$htmlname) - { - $ret.="\n"; - $ret.='
'; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - $ret.=''; - if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=''; - $ret.='
'; - if (preg_match('/^(string|email|numeric)/',$typeofdata)) - { - $tmp=explode(':',$typeofdata); - $ret.=''; - } - else if ($typeofdata == 'text' || $typeofdata == 'textarea' || $typeofdata == 'note') - { - $ret.=''; - } - else if ($typeofdata == 'day' || $typeofdata == 'datepicker') - { - $ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname); - } - else if (preg_match('/^ckeditor/',$typeofdata)) - { - $tmp=explode(':',$typeofdata); - require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true); - $ret.=$doleditor->Create(1); - //$ret.=''; - } - $ret.='
'."\n"; - $ret.='
'."\n"; - } - else - { - if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); - elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); - elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); - else if (preg_match('/^ckeditor/',$typeofdata)) - { - $tmpcontent=dol_htmlentitiesbr($value); - $firstline=preg_replace('/
.*/','',$tmpcontent); - $firstline=preg_replace('/[\n\r].*/','',$firstline); - $ret.=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); - } - else $ret.=$value; - } - } - return $ret; - } - - /** - * Output edit in place form - * * @param object $object Object * @param string $value Value to show/edit * @param string $htmlname DIV ID (field name) @@ -197,139 +197,139 @@ class Form * @param object $extObject External object * @return string HTML edit in place */ - private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=false) - { - global $conf; - - $out=''; - - // Check parameters - if ($inputType == 'textarea') $value = dol_nl2br($value); - else if (preg_match('/^numeric/',$inputType)) $value = price($value); - else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); - - if ($condition) - { - $element = false; - $table_element = false; - $fk_element = false; - $loadmethod = false; - $savemethod = false; - $ext_element = false; - //$ext_table_element = false; - //$ext_fk_element = false; - - if (is_object($object)) - { - $element = $object->element; - $table_element = $object->table_element; - $fk_element = $object->id; - } - - if (is_object($extObject)) - { - $ext_element = $extObject->element; - //$ext_table_element = $extObject->table_element; - //$ext_fk_element = $extObject->id; - } - - if (preg_match('/^(string|email|numeric)/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; - } - if (preg_match('/^datepicker/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; - - $out.= ''."\n"; // Use for timestamp format - } - else if (preg_match('/^select/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $loadmethod=$tmp[1]; - if (! empty($tmp[2])) $savemethod=$tmp[2]; - } - else if (preg_match('/^ckeditor/',$inputType)) - { - $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $toolbar=$tmp[1]; - if (! empty($tmp[2])) $width=$tmp[2]; - if (! empty($tmp[3])) $heigth=$tmp[3]; - if (! empty($tmp[4])) $savemethod=$tmp[4]; - - if (! empty($conf->fckeditor->enabled)) - { - $out.= ''."\n"; - } - else - { - $inputType = 'textarea'; - } - } + private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $extObject=false) + { + global $conf; + + $out=''; + + // Check parameters + if ($inputType == 'textarea') $value = dol_nl2br($value); + else if (preg_match('/^numeric/',$inputType)) $value = price($value); + else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); + + if ($condition) + { + $element = false; + $table_element = false; + $fk_element = false; + $loadmethod = false; + $savemethod = false; + $ext_element = false; + //$ext_table_element = false; + //$ext_fk_element = false; + + if (is_object($object)) + { + $element = $object->element; + $table_element = $object->table_element; + $fk_element = $object->id; + } + + if (is_object($extObject)) + { + $ext_element = $extObject->element; + //$ext_table_element = $extObject->table_element; + //$ext_fk_element = $extObject->id; + } + + if (preg_match('/^(string|email|numeric)/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; + } + if (preg_match('/^datepicker/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $inputOption=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; + + $out.= ''."\n"; // Use for timestamp format + } + else if (preg_match('/^select/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $loadmethod=$tmp[1]; + if (! empty($tmp[2])) $savemethod=$tmp[2]; + } + else if (preg_match('/^ckeditor/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; $toolbar=$tmp[1]; + if (! empty($tmp[2])) $width=$tmp[2]; + if (! empty($tmp[3])) $heigth=$tmp[3]; + if (! empty($tmp[4])) $savemethod=$tmp[4]; + + if (! empty($conf->fckeditor->enabled)) + { + $out.= ''."\n"; + } + else + { + $inputType = 'textarea'; + } + } + + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + $out.= ''."\n"; + //$out.= ''."\n"; + //$out.= ''."\n"; + + $out.= '
'.$value.'
'."\n"; + } + else + { + $out = $value; + } + + return $out; + } - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - //$out.= ''."\n"; - //$out.= ''."\n"; - - $out.= '
'.$value.'
'."\n"; - } - else - { - $out = $value; - } - - return $out; - } - - /** - * Show a text and picto with tooltip on text or picto - * - * @param text Text to show - * @param htmltext Content html of tooltip. Must be HTML/UTF8 encoded. - * @param tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2 - * @param direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres - * @param img Code img du picto (use img_xxx() function to get it) - * @param extracss Add a CSS style to td tags - * @param notabs Do not include table and tr tags - * @param incbefore Include code before the text - * @param noencodehtmltext Do not encode into html entity the htmltext - * @return string Code html du tooltip (texte+picto) - * @see Use function textwithpicto if you can. - */ - function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0) - { - global $conf; - - if ($incbefore) $text = $incbefore.$text; - if (! $htmltext) return $text; - - // Sanitize tooltip - $htmltext=str_replace("\\","\\\\",$htmltext); - $htmltext=str_replace("\r","",$htmltext); - $htmltext=str_replace("\n","",$htmltext); - - $htmltext=str_replace('"',""",$htmltext); - if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip - else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag - if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip - else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag - - $s=""; - if (empty($notabs)) $s.=''; - if ($direction > 0) - { - if ($text != '') - { - $s.=''.$text; + /** + * Show a text and picto with tooltip on text or picto + * + * @param string $text Text to show + * @param string $htmltext Content html of tooltip. Must be HTML/UTF8 encoded. + * @param int $tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2 + * @param int $direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres + * @param string $img Code img du picto (use img_xxx() function to get it) + * @param string $extracss Add a CSS style to td tags + * @param int $notabs Do not include table and tr tags + * @param string $incbefore Include code before the text + * @param int $noencodehtmltext Do not encode into html entity the htmltext + * @return string Code html du tooltip (texte+picto) + * @see Use function textwithpicto if you can. + */ + function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0) + { + global $conf; + + if ($incbefore) $text = $incbefore.$text; + if (! $htmltext) return $text; + + // Sanitize tooltip + $htmltext=str_replace("\\","\\\\",$htmltext); + $htmltext=str_replace("\r","",$htmltext); + $htmltext=str_replace("\n","",$htmltext); + + $htmltext=str_replace('"',""",$htmltext); + if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip + else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag + if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip + else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag + + $s=""; + if (empty($notabs)) $s.='
'; + if ($direction > 0) + { + if ($text != '') + { + $s.=''.$text; if ($direction) $s.=' '; $s.=''; } @@ -346,9 +346,9 @@ class Form } } if (empty($notabs)) $s.='
'; - - return $s; - } + + return $s; + } /** * Show a text with a picto and a tooltip on picto