NEW Converted Form::selectyesno, Form::showrefnav, Form::select_date, Form::showbarcode, Form::showfilterAndCheckAddButtons, Form::editfieldkey, Form::editfieldnav, Form::editInPlace, Form::selectMassActions to static functions

This commit is contained in:
Marcos García de La Fuente 2016-03-20 14:02:38 +01:00
parent 5a9e686bf9
commit 5bdc3b9a1e

View File

@ -64,7 +64,7 @@ class Form
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
public function __construct(DoliDB $db)
{
$this->db = $db;
}
@ -81,7 +81,7 @@ class Form
* @param string $moreparam More param to add on a href URL
* @return string HTML edit field
*/
function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='')
public static function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='')
{
global $conf,$langs;
@ -129,7 +129,7 @@ class Form
* @param string $moreparam More param to add on a href URL
* @return string HTML edit field
*/
function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='')
public static function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='')
{
global $conf,$langs,$db;
@ -141,7 +141,7 @@ class Form
// When option to edit inline is activated
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;|datehourpicker/',$typeofdata)) // TODO add jquery timepicker
{
$ret.=$this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
$ret.= self::editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
}
else
{
@ -171,11 +171,11 @@ class Form
}
else if ($typeofdata == 'day' || $typeofdata == 'datepicker')
{
$ret.=$this->select_date($value,$htmlname,0,0,1,'form'.$htmlname,1,0,1);
$ret.=self::select_date($value,$htmlname,0,0,1,'form'.$htmlname,1,0,1);
}
else if ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker')
{
$ret.=$this->select_date($value,$htmlname,1,1,1,'form'.$htmlname,1,0,1);
$ret.=self::select_date($value,$htmlname,1,1,1,'form'.$htmlname,1,0,1);
}
else if (preg_match('/^select;/',$typeofdata))
{
@ -253,7 +253,7 @@ class Form
* @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
* @return string HTML edit in place
*/
private function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $editvalue=null, $extObject=null, $custommsg=null)
private static function editInPlace($object, $value, $htmlname, $condition, $inputType='textarea', $editvalue=null, $extObject=null, $custommsg=null)
{
global $conf;
@ -486,10 +486,10 @@ class Form
* Generate select HTML to choose massaction
*
* @param string $selected Selected value
* @param int $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action.
* @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action.
* @return string Select list
*/
function selectMassAction($selected, $arrayofaction)
public static function selectMassAction($selected, array $arrayofaction)
{
global $conf,$langs,$hookmanager;
@ -3285,7 +3285,7 @@ class Form
{
$more.='<tr><td>'.$input['label'].'</td>';
$more.='<td colspan="2" align="left">';
$more.=$this->select_date($input['value'],$input['name'],0,0,0,'',1,0,1);
$more.=self::select_date($input['value'],$input['name'],0,0,0,'',1,0,1);
$more.='</td></tr>'."\n";
$formquestion[] = array('name'=>$input['name'].'day');
$formquestion[] = array('name'=>$input['name'].'month');
@ -3637,7 +3637,7 @@ class Form
* @return void
* @see select_date
*/
function form_date($page, $selected, $htmlname, $displayhour=0, $displaymin=0, $nooutput=0)
public static function form_date($page, $selected, $htmlname, $displayhour=0, $displaymin=0, $nooutput=0)
{
global $langs;
@ -3650,7 +3650,7 @@ class Form
$ret.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$ret.='<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
$ret.='<tr><td>';
$ret.=$this->select_date($selected,$htmlname,$displayhour,$displaymin,1,'form'.$htmlname,1,0,1);
$ret.=self::select_date($selected,$htmlname,$displayhour,$displaymin,1,'form'.$htmlname,1,0,1);
$ret.='</td>';
$ret.='<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
$ret.='</tr></table></form>';
@ -4277,7 +4277,7 @@ class Form
* @return mixed Nothing or string if nooutput is 1
* @see form_date
*/
function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='')
public static function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='')
{
global $conf,$langs;
@ -5479,7 +5479,7 @@ class Form
* @param string $morehtmlright More html code to show before navigation arrows
* @return string Portion HTML avec ref + boutons nav
*/
function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlright='')
public static function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlright='')
{
global $langs,$conf;
@ -5545,11 +5545,11 @@ class Form
/**
* Return HTML code to output a barcode
*
* @param Object $object Object containing data to retrieve file name
* @param object $object Object containing data to retrieve file name
* @param int $width Width of photo
* @return string HTML code to output barcode
*/
function showbarcode(&$object,$width=100)
public static function showbarcode($object, $width = 100)
{
global $conf;
@ -5824,7 +5824,7 @@ class Form
* @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes
* @return string
*/
function showFilterAndCheckAddButtons($addcheckuncheckall=0, $cssclass='checkforaction', $calljsfunction=0)
public static function showFilterAndCheckAddButtons($addcheckuncheckall=0, $cssclass='checkforaction', $calljsfunction=0)
{
global $conf, $langs;