mirror of
https://github.com/e107inc/e107.git
synced 2025-03-14 17:39:46 +01: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:
parent
640aa6b4a3
commit
808283fc11
e107_handlers
@ -2350,6 +2350,12 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
return e107::getRegistry('core/adminUI/currentListModel');
|
||||
}
|
||||
|
||||
public function setListModel($model)
|
||||
{
|
||||
e107::setRegistry('core/adminUI/currentListModel', $model);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* User defined tree model setter
|
||||
* @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) : '';
|
||||
}
|
||||
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']))
|
||||
{
|
||||
@ -2729,6 +2746,7 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
*/
|
||||
protected function parseAliases()
|
||||
{
|
||||
if($this->_alias_parsed) return $this; // already parsed!!!
|
||||
if($this->getJoinData())
|
||||
{
|
||||
foreach ($this->getJoinData() as $table => $att)
|
||||
@ -2803,7 +2821,7 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
}*/
|
||||
}
|
||||
$this->fields = $fields;
|
||||
|
||||
$this->_alias_parsed = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -2923,7 +2941,7 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
|
||||
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['joinsFrom'] = $tableSJoinArr;
|
||||
$rawData['joins'] = $joins;
|
||||
@ -4084,6 +4102,13 @@ class e_admin_form_ui extends e_form
|
||||
break;
|
||||
|
||||
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
|
||||
foreach($parms as $k => $name)
|
||||
{
|
||||
@ -4091,6 +4116,21 @@ class e_admin_form_ui extends e_form
|
||||
}
|
||||
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
|
||||
//TODO last hour, today, yesterday, this-month, last-month etc.
|
||||
/* foreach($val['parm'] as $k=>$name)
|
||||
|
@ -557,11 +557,16 @@ class e_form
|
||||
{
|
||||
$option_array = array(1 => LAN_YES, 0 => LAN_NO);
|
||||
}
|
||||
|
||||
if($options['multiple'] && strpos($name, '[') === false)
|
||||
{
|
||||
$name = $name.'[]';
|
||||
}
|
||||
$text = $this->select_open($name, $options)."\n";
|
||||
|
||||
if(isset($options['default']))
|
||||
{
|
||||
$text .= $this->option($options['default'], '');
|
||||
$text .= $this->option($options['default'], varset($options['defaultValue']));
|
||||
}
|
||||
elseif($defaultBlank)
|
||||
{
|
||||
@ -612,7 +617,7 @@ class e_form
|
||||
if(false === $value) $value = '';
|
||||
$options = $this->format_options('option', '', $options);
|
||||
$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())
|
||||
@ -627,13 +632,13 @@ class e_form
|
||||
$text .= $this->optgroup_open($value);
|
||||
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();
|
||||
}
|
||||
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'";
|
||||
break;
|
||||
|
||||
case 'multiple':
|
||||
if($optval) $ret .= " multiple='multiple'";
|
||||
break;
|
||||
|
||||
case 'selected':
|
||||
if($optval) $ret .= " selected='selected'";
|
||||
break;
|
||||
@ -868,6 +877,7 @@ class e_form
|
||||
'selected' => false,
|
||||
'checked' => false,
|
||||
'disabled' => false,
|
||||
// 'multiple' => false, - see case 'select'
|
||||
'tabindex' => 0,
|
||||
'label' => '',
|
||||
'other' => ''
|
||||
@ -895,7 +905,8 @@ class e_form
|
||||
|
||||
case 'select':
|
||||
$def_options['class'] = 'tbox select';
|
||||
unset($def_options['checked'], $def_options['checked']);
|
||||
$def_options['multiple'] = false;
|
||||
unset($def_options['checked']);
|
||||
break;
|
||||
|
||||
case 'option':
|
||||
@ -1173,7 +1184,7 @@ class e_form
|
||||
$parms = array();
|
||||
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'];
|
||||
}
|
||||
$tp = e107::getParser();
|
||||
@ -1257,10 +1268,39 @@ class e_form
|
||||
break;
|
||||
|
||||
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)
|
||||
{
|
||||
$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;
|
||||
|
||||
case 'text':
|
||||
@ -1441,6 +1481,39 @@ class e_form
|
||||
return (vartrue($parms['show']) ? ($value ? $value : vartrue($parms['empty'])) : '');
|
||||
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
|
||||
|
||||
default:
|
||||
@ -1594,8 +1667,9 @@ class e_form
|
||||
|
||||
case 'dropdown':
|
||||
$eloptions = vartrue($parms['__options'], array());
|
||||
if(is_string($eloptions)) parse_str($eloptions);
|
||||
if(is_string($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, $parms, $value, $eloptions).vartrue($eloptions['post']);
|
||||
break;
|
||||
|
||||
@ -1663,6 +1737,16 @@ class e_form
|
||||
return $ret.$this->hidden($key, $value);
|
||||
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:
|
||||
return $value;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user