mirror of
https://github.com/e107inc/e107.git
synced 2025-08-10 00:27:45 +02:00
Admin UI improvements and fixes; introducing 'lanlist' field type; 'multiple' dropdown option possible now but incomplete (batch, filter related work required)
This commit is contained in:
@@ -2350,6 +2350,12 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
return e107::getRegistry('core/adminUI/currentListModel');
|
return e107::getRegistry('core/adminUI/currentListModel');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setListModel($model)
|
||||||
|
{
|
||||||
|
e107::setRegistry('core/adminUI/currentListModel', $model);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User defined tree model setter
|
* User defined tree model setter
|
||||||
* @return e_admin_controller_ui
|
* @return e_admin_controller_ui
|
||||||
@@ -2607,6 +2613,17 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
$value = trim($value) ? e107::getInstance()->ipEncode($value) : '';
|
$value = trim($value) ? e107::getInstance()->ipEncode($value) : '';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'dropdown': // TODO - ask Steve if this check is required
|
||||||
|
case 'lanlist':
|
||||||
|
if(is_array($value))
|
||||||
|
{
|
||||||
|
// no sanitize here - data is added to model posted stack
|
||||||
|
// and validated & sanitized before sent to db
|
||||||
|
//$value = array_map(array(e107::getParser(), 'toDB'), $value);
|
||||||
|
$value = implode(',', $value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(vartrue($attributes['dataPath']))
|
if(vartrue($attributes['dataPath']))
|
||||||
{
|
{
|
||||||
@@ -2729,6 +2746,7 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
*/
|
*/
|
||||||
protected function parseAliases()
|
protected function parseAliases()
|
||||||
{
|
{
|
||||||
|
if($this->_alias_parsed) return $this; // already parsed!!!
|
||||||
if($this->getJoinData())
|
if($this->getJoinData())
|
||||||
{
|
{
|
||||||
foreach ($this->getJoinData() as $table => $att)
|
foreach ($this->getJoinData() as $table => $att)
|
||||||
@@ -2803,7 +2821,7 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
|
$this->_alias_parsed = true;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2923,7 +2941,7 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
|
|
||||||
if($raw)
|
if($raw)
|
||||||
{
|
{
|
||||||
$rawData = array('joinWhere' => $jwhere, 'filter' => $filter, 'filterFrom' => $filterFrom, 'search' => $searchQry, 'tableFrom' => $tableFrom);
|
$rawData = array('joinWhere' => $jwhere, 'filter' => $filter, 'filterFrom' => $filterFrom, 'search' => $searchQry, 'tableFromName' => $tableFrom);
|
||||||
$rawData['tableFrom'] = $tableSFieldsArr;
|
$rawData['tableFrom'] = $tableSFieldsArr;
|
||||||
$rawData['joinsFrom'] = $tableSJoinArr;
|
$rawData['joinsFrom'] = $tableSJoinArr;
|
||||||
$rawData['joins'] = $joins;
|
$rawData['joins'] = $joins;
|
||||||
@@ -4084,6 +4102,13 @@ class e_admin_form_ui extends e_form
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'dropdown': // use the array $parm;
|
case 'dropdown': // use the array $parm;
|
||||||
|
if(!is_array(varset($parms['__options']))) parse_str($parms['__options'], $parms['__options']);
|
||||||
|
$opts = $parms['__options'];
|
||||||
|
if(vartrue($opts['multiple']))
|
||||||
|
{
|
||||||
|
// no batch support for multiple, should have some for filters soon
|
||||||
|
continue;
|
||||||
|
}
|
||||||
unset($parms['__options']); //remove element options if any
|
unset($parms['__options']); //remove element options if any
|
||||||
foreach($parms as $k => $name)
|
foreach($parms as $k => $name)
|
||||||
{
|
{
|
||||||
@@ -4091,6 +4116,21 @@ class e_admin_form_ui extends e_form
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'lanlist': // use the array $parm;
|
||||||
|
if(!is_array(varset($parms['__options']))) parse_str($parms['__options'], $parms['__options']);
|
||||||
|
$opts = $parms['__options'];
|
||||||
|
if(vartrue($opts['multiple']))
|
||||||
|
{
|
||||||
|
// no batch support for multiple, should have some for filters soon
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$options = e107::getLanguage()->getLanSelectArray();
|
||||||
|
foreach($options as $code => $name)
|
||||||
|
{
|
||||||
|
$option[$key.'__'.$code] = $name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'datestamp': // use $parm to determine unix-style or YYYY-MM-DD
|
case 'datestamp': // use $parm to determine unix-style or YYYY-MM-DD
|
||||||
//TODO last hour, today, yesterday, this-month, last-month etc.
|
//TODO last hour, today, yesterday, this-month, last-month etc.
|
||||||
/* foreach($val['parm'] as $k=>$name)
|
/* foreach($val['parm'] as $k=>$name)
|
||||||
|
@@ -557,11 +557,16 @@ class e_form
|
|||||||
{
|
{
|
||||||
$option_array = array(1 => LAN_YES, 0 => LAN_NO);
|
$option_array = array(1 => LAN_YES, 0 => LAN_NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($options['multiple'] && strpos($name, '[') === false)
|
||||||
|
{
|
||||||
|
$name = $name.'[]';
|
||||||
|
}
|
||||||
$text = $this->select_open($name, $options)."\n";
|
$text = $this->select_open($name, $options)."\n";
|
||||||
|
|
||||||
if(isset($options['default']))
|
if(isset($options['default']))
|
||||||
{
|
{
|
||||||
$text .= $this->option($options['default'], '');
|
$text .= $this->option($options['default'], varset($options['defaultValue']));
|
||||||
}
|
}
|
||||||
elseif($defaultBlank)
|
elseif($defaultBlank)
|
||||||
{
|
{
|
||||||
@@ -612,7 +617,7 @@ class e_form
|
|||||||
if(false === $value) $value = '';
|
if(false === $value) $value = '';
|
||||||
$options = $this->format_options('option', '', $options);
|
$options = $this->format_options('option', '', $options);
|
||||||
$options['selected'] = $selected; //comes as separate argument just for convenience
|
$options['selected'] = $selected; //comes as separate argument just for convenience
|
||||||
return "<option value='{$value}'".$this->get_attributes($options).">{$option_title}</option>";
|
return "<option value='{$value}'".$this->get_attributes($options).">".defset($option_title, $option_title)."</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function option_multi($option_array, $selected = false, $options = array())
|
function option_multi($option_array, $selected = false, $options = array())
|
||||||
@@ -627,13 +632,13 @@ class e_form
|
|||||||
$text .= $this->optgroup_open($value);
|
$text .= $this->optgroup_open($value);
|
||||||
foreach($label as $val => $lab)
|
foreach($label as $val => $lab)
|
||||||
{
|
{
|
||||||
$text .= $this->option($lab, $val, ($selected == $val), $options)."\n";
|
$text .= $this->option($lab, $val, (is_array($selected) ? in_array($val, $selected) : $selected == $val), $options)."\n";
|
||||||
}
|
}
|
||||||
$text .= $this->optgroup_close();
|
$text .= $this->optgroup_close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$text .= $this->option($label, $value, $selected == $value, $options)."\n";
|
$text .= $this->option($label, $value, (is_array($selected) ? in_array($value, $selected) : $selected == $value), $options)."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,6 +778,10 @@ class e_form
|
|||||||
if($optval) $ret .= " readonly='readonly'";
|
if($optval) $ret .= " readonly='readonly'";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'multiple':
|
||||||
|
if($optval) $ret .= " multiple='multiple'";
|
||||||
|
break;
|
||||||
|
|
||||||
case 'selected':
|
case 'selected':
|
||||||
if($optval) $ret .= " selected='selected'";
|
if($optval) $ret .= " selected='selected'";
|
||||||
break;
|
break;
|
||||||
@@ -868,6 +877,7 @@ class e_form
|
|||||||
'selected' => false,
|
'selected' => false,
|
||||||
'checked' => false,
|
'checked' => false,
|
||||||
'disabled' => false,
|
'disabled' => false,
|
||||||
|
// 'multiple' => false, - see case 'select'
|
||||||
'tabindex' => 0,
|
'tabindex' => 0,
|
||||||
'label' => '',
|
'label' => '',
|
||||||
'other' => ''
|
'other' => ''
|
||||||
@@ -895,7 +905,8 @@ class e_form
|
|||||||
|
|
||||||
case 'select':
|
case 'select':
|
||||||
$def_options['class'] = 'tbox select';
|
$def_options['class'] = 'tbox select';
|
||||||
unset($def_options['checked'], $def_options['checked']);
|
$def_options['multiple'] = false;
|
||||||
|
unset($def_options['checked']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'option':
|
case 'option':
|
||||||
@@ -1173,7 +1184,7 @@ class e_form
|
|||||||
$parms = array();
|
$parms = array();
|
||||||
if(isset($attributes['readParms']))
|
if(isset($attributes['readParms']))
|
||||||
{
|
{
|
||||||
if(is_string($attributes['readParms'])) parse_str($attributes['readParms'], $attributes['readParms']);
|
if(!is_array($attributes['readParms'])) parse_str($attributes['readParms'], $attributes['readParms']);
|
||||||
$parms = $attributes['readParms'];
|
$parms = $attributes['readParms'];
|
||||||
}
|
}
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -1257,10 +1268,39 @@ class e_form
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
|
// XXX - should we use readParams at all here? see writeParms check below
|
||||||
if($parms && is_array($parms)) // FIXME - add support for multi-level arrays (option groups)
|
if($parms && is_array($parms)) // FIXME - add support for multi-level arrays (option groups)
|
||||||
{
|
{
|
||||||
$value = vartrue($parms['pre']).vartrue($parms[$value]).vartrue($parms['post']);
|
$value = vartrue($parms['pre']).vartrue($parms[$value]).vartrue($parms['post']);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NEW - multiple (array values) support
|
||||||
|
// FIXME - add support for multi-level arrays (option groups)
|
||||||
|
if(!is_array($attributes['writeParms'])) parse_str($attributes['writeParms'], $attributes['writeParms']);
|
||||||
|
$wparms = $attributes['writeParms'];
|
||||||
|
if(!is_array(varset($wparms['__options']))) parse_str($wparms['__options'], $wparms['__options']);
|
||||||
|
|
||||||
|
$opts = $wparms['__options'];
|
||||||
|
unset($wparms['__options']);
|
||||||
|
|
||||||
|
if($opts['multiple'])
|
||||||
|
{
|
||||||
|
$ret = array();
|
||||||
|
$value = is_array($value) ? $value : explode(',', $value);
|
||||||
|
foreach ($value as $v)
|
||||||
|
{
|
||||||
|
if(isset($wparms[$v])) $ret[] = $wparms[$v];
|
||||||
|
}
|
||||||
|
$value = implode(', ', $ret);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret = '';
|
||||||
|
if(isset($wparms[$value])) $ret = $wparms[$value];
|
||||||
|
$value = $ret;
|
||||||
|
}
|
||||||
|
$value = ($value ? vartrue($parms['pre']).defset($value, $value).vartrue($parms['post']) : '');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'text':
|
case 'text':
|
||||||
@@ -1441,6 +1481,39 @@ class e_form
|
|||||||
return (vartrue($parms['show']) ? ($value ? $value : vartrue($parms['empty'])) : '');
|
return (vartrue($parms['show']) ? ($value ? $value : vartrue($parms['empty'])) : '');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'lanlist':
|
||||||
|
$options = e107::getLanguage()->getLanSelectArray();
|
||||||
|
|
||||||
|
if($options) // FIXME - add support for multi-level arrays (option groups)
|
||||||
|
{
|
||||||
|
if(!is_array($attributes['writeParms'])) parse_str($attributes['writeParms'], $attributes['writeParms']);
|
||||||
|
$wparms = $attributes['writeParms'];
|
||||||
|
if(!is_array(varset($wparms['__options']))) parse_str($wparms['__options'], $wparms['__options']);
|
||||||
|
$opts = $wparms['__options'];
|
||||||
|
if($opts['multiple'])
|
||||||
|
{
|
||||||
|
$ret = array();
|
||||||
|
$value = is_array($value) ? $value : explode(',', $value);
|
||||||
|
foreach ($value as $v)
|
||||||
|
{
|
||||||
|
if(isset($options[$v])) $ret[] = $options[$v];
|
||||||
|
}
|
||||||
|
$value = implode(', ', $ret);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret = '';
|
||||||
|
if(isset($options[$value])) $ret = $options[$value];
|
||||||
|
$value = $ret;
|
||||||
|
}
|
||||||
|
$value = ($value ? vartrue($parms['pre']).$value.vartrue($parms['post']) : '');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value = '';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
//TODO - order
|
//TODO - order
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1594,8 +1667,9 @@ class e_form
|
|||||||
|
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
$eloptions = vartrue($parms['__options'], array());
|
$eloptions = vartrue($parms['__options'], array());
|
||||||
if(is_string($eloptions)) parse_str($eloptions);
|
if(is_string($eloptions)) parse_str($eloptions, $eloptions);
|
||||||
unset($parms['__options']);
|
unset($parms['__options']);
|
||||||
|
if(vartrue($eloptions['multiple']) && !is_array($value)) $value = explode(',', $value);
|
||||||
return vartrue($eloptions['pre']).$this->selectbox($key, $parms, $value, $eloptions).vartrue($eloptions['post']);
|
return vartrue($eloptions['pre']).$this->selectbox($key, $parms, $value, $eloptions).vartrue($eloptions['post']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1663,6 +1737,16 @@ class e_form
|
|||||||
return $ret.$this->hidden($key, $value);
|
return $ret.$this->hidden($key, $value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'lanlist':
|
||||||
|
$options = e107::getLanguage()->getLanSelectArray();
|
||||||
|
|
||||||
|
$eloptions = vartrue($parms['__options'], array());
|
||||||
|
if(!is_array($eloptions)) parse_str($eloptions, $eloptions);
|
||||||
|
unset($parms['__options']);
|
||||||
|
if(vartrue($eloptions['multiple']) && !is_array($value)) $value = explode(',', $value);
|
||||||
|
return vartrue($eloptions['pre']).$this->selectbox($key, $options, $value, $eloptions).vartrue($eloptions['post']);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $value;
|
return $value;
|
||||||
break;
|
break;
|
||||||
|
@@ -536,5 +536,17 @@ class language{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLanSelectArray($force = false)
|
||||||
|
{
|
||||||
|
if($force ||null === $this->_select_array)
|
||||||
|
{
|
||||||
|
$lanlist = explode(',', e_LANLIST);
|
||||||
|
$this->_select_array = array();
|
||||||
|
foreach ($lanlist as $lan)
|
||||||
|
{
|
||||||
|
$this->_select_array[$this->convert($lan)] = $this->toNative($lan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->_select_array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user