mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 22:27:34 +02:00
Added checkboxes form element.
This commit is contained in:
@@ -3188,6 +3188,7 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
case 'lanlist':
|
case 'lanlist':
|
||||||
case 'userclasses':
|
case 'userclasses':
|
||||||
case 'comma':
|
case 'comma':
|
||||||
|
case 'checkboxes':
|
||||||
if(is_array($value))
|
if(is_array($value))
|
||||||
{
|
{
|
||||||
// no sanitize here - data is added to model posted stack
|
// no sanitize here - data is added to model posted stack
|
||||||
@@ -3548,11 +3549,16 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
if($filterField && $filterValue !== '' && isset($this->fields[$filterField]))
|
if($filterField && $filterValue !== '' && isset($this->fields[$filterField]))
|
||||||
{
|
{
|
||||||
$_type = $this->fields[$filterField]['data'];
|
$_type = $this->fields[$filterField]['data'];
|
||||||
if($this->fields[$filterField]['type'] === 'comma') $_type = 'set';
|
|
||||||
|
if($this->fields[$filterField]['type'] === 'comma' || $this->fields[$filterField]['type'] === 'checkboxes')
|
||||||
|
{
|
||||||
|
$_type = 'set';
|
||||||
|
}
|
||||||
|
|
||||||
switch ($_type)
|
switch ($_type)
|
||||||
{
|
{
|
||||||
case 'set':
|
case 'set':
|
||||||
$searchQry[] = "FIND_IN_SET('".$tp->toDB($filterValue)."',".$this->fields[$filterField]['__tableField'].")";
|
$searchQry[] = "FIND_IN_SET('".$tp->toDB($filterValue)."', ".$this->fields[$filterField]['__tableField'].")";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'int':
|
case 'int':
|
||||||
@@ -3802,8 +3808,9 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug Filter Query.
|
// Debug Filter Query.
|
||||||
|
e107::getMessage()->addDebug('QRY='.$qry);
|
||||||
// echo $qry.'<br />';
|
// echo $qry.'<br />';
|
||||||
|
// print_a($this->fields);
|
||||||
// print_a($_GET);
|
// print_a($_GET);
|
||||||
|
|
||||||
return $qry;
|
return $qry;
|
||||||
@@ -5620,6 +5627,7 @@ class e_admin_form_ui extends e_form
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'checkboxes':
|
||||||
case 'comma':
|
case 'comma':
|
||||||
// TODO lan
|
// TODO lan
|
||||||
if(!isset($parms['__options'])) $parms['__options'] = array();
|
if(!isset($parms['__options'])) $parms['__options'] = array();
|
||||||
|
@@ -1268,6 +1268,32 @@ class e_form
|
|||||||
return $pre.$text.$post;
|
return $pre.$text.$post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an array of checkboxes.
|
||||||
|
* @param string $name
|
||||||
|
* @param array $option_array
|
||||||
|
* @param mixed $checked
|
||||||
|
* @param array $options [optional]
|
||||||
|
*/
|
||||||
|
function checkboxes($name, $option_array, $checked, $options=array())
|
||||||
|
{
|
||||||
|
$name = (strpos($name, '[') === false) ? $name.'[]' : $name;
|
||||||
|
if(!is_array($checked)) $checked = explode(",",$checked);
|
||||||
|
|
||||||
|
$text = "";
|
||||||
|
|
||||||
|
foreach($option_array as $k=>$label)
|
||||||
|
{
|
||||||
|
$c = in_array($k, $checked) ? true : false;
|
||||||
|
$text .= $this->checkbox($name, $k, $c, $label);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function checkbox_label($label_title, $name, $value, $checked = false, $options = array())
|
function checkbox_label($label_title, $name, $value, $checked = false, $options = array())
|
||||||
{
|
{
|
||||||
return $this->checkbox($name, $value, $checked, $options).$this->label($label_title, $name, $value);
|
return $this->checkbox($name, $value, $checked, $options).$this->label($label_title, $name, $value);
|
||||||
@@ -2739,6 +2765,11 @@ class e_form
|
|||||||
if(vartrue($attributes['inline'])) $parms['editable'] = true; // attribute alias
|
if(vartrue($attributes['inline'])) $parms['editable'] = true; // attribute alias
|
||||||
if(vartrue($attributes['sort'])) $parms['sort'] = true; // attribute alias
|
if(vartrue($attributes['sort'])) $parms['sort'] = true; // attribute alias
|
||||||
|
|
||||||
|
if(vartrue($parms['type'])) // Allow the use of a different type in readMode. eg. type=method.
|
||||||
|
{
|
||||||
|
$attributes['type'] = $parms['type'];
|
||||||
|
}
|
||||||
|
|
||||||
$this->renderValueTrigger($field, $value, $parms, $id);
|
$this->renderValueTrigger($field, $value, $parms, $id);
|
||||||
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -2882,6 +2913,7 @@ class e_form
|
|||||||
// $value = $pre.vartrue($tmp[$value]).$post; // FIXME "Fatal error: Only variables can be passed by reference" featurebox list page.
|
// $value = $pre.vartrue($tmp[$value]).$post; // FIXME "Fatal error: Only variables can be passed by reference" featurebox list page.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'checkboxes':
|
||||||
case 'comma':
|
case 'comma':
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
// XXX - should we use readParams at all here? see writeParms check below
|
// XXX - should we use readParams at all here? see writeParms check below
|
||||||
@@ -2904,7 +2936,12 @@ class e_form
|
|||||||
unset($wparms['__options']);
|
unset($wparms['__options']);
|
||||||
$_value = $value;
|
$_value = $value;
|
||||||
|
|
||||||
if(vartrue($opts['multiple']) || vartrue($attributes['type']) == 'comma')
|
if($attributes['type'] == 'checkboxes' || $attributes['type'] == 'comma')
|
||||||
|
{
|
||||||
|
$opts['multiple'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vartrue($opts['multiple']))
|
||||||
{
|
{
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$value = is_array($value) ? $value : explode(',', $value);
|
$value = is_array($value) ? $value : explode(',', $value);
|
||||||
@@ -3291,13 +3328,24 @@ class e_form
|
|||||||
$_value = $value;
|
$_value = $value;
|
||||||
$value = call_user_func_array(array($this, $method), array($value, 'read', $parms));
|
$value = call_user_func_array(array($this, $method), array($value, 'read', $parms));
|
||||||
|
|
||||||
|
// print_a($attributes);
|
||||||
// Inline Editing.
|
// Inline Editing.
|
||||||
if(!vartrue($attributes['noedit']) && vartrue($parms['editable'])) // avoid bad markup, better solution coming up
|
if(!vartrue($attributes['noedit']) && vartrue($parms['editable'])) // avoid bad markup, better solution coming up
|
||||||
{
|
{
|
||||||
|
|
||||||
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
|
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
|
||||||
$methodParms = call_user_func_array(array($this, $method), array($value, 'inline', $parms));
|
$methodParms = call_user_func_array(array($this, $method), array($value, 'inline', $parms));
|
||||||
$xtype = 'select';
|
|
||||||
|
if($attributes['inline'] === 'checklist')
|
||||||
|
{
|
||||||
|
$xtype = 'checklist';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$xtype = 'select';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$value = $this->renderInline($field, $id, $attributes['title'], $_value, $value, $xtype, $methodParms);
|
$value = $this->renderInline($field, $id, $attributes['title'], $_value, $value, $xtype, $methodParms);
|
||||||
|
|
||||||
@@ -3598,6 +3646,20 @@ class e_form
|
|||||||
$ret = (vartrue($parms['raw']) ? $templates : $this->selectbox($key, $templates, $value));
|
$ret = (vartrue($parms['raw']) ? $templates : $this->selectbox($key, $templates, $value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'checkboxes':
|
||||||
|
|
||||||
|
if(is_array($parms))
|
||||||
|
{
|
||||||
|
if(!is_array($value) && !empty($value))
|
||||||
|
{
|
||||||
|
$value = explode(",",$value);
|
||||||
|
}
|
||||||
|
$ret = vartrue($eloptions['pre']).$this->checkboxes($key, $parms, $value, $eloptions).vartrue($eloptions['post']);
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
case 'comma':
|
case 'comma':
|
||||||
$eloptions = vartrue($parms['__options'], array());
|
$eloptions = vartrue($parms['__options'], array());
|
||||||
|
Reference in New Issue
Block a user