1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-27 01:40:22 +02:00

Quick fix for handling array data and converting to comma separated data including filtering list results. (Admin-UI)

This commit is contained in:
CaMer0n
2012-08-02 02:09:58 +00:00
parent 9937a9c0e2
commit b44f0a2085
3 changed files with 45 additions and 13 deletions

View File

@@ -2891,6 +2891,14 @@ class e_admin_controller_ui extends e_admin_controller
break; break;
} }
if($attributes['data'] == 'comma')
{
$value = implode(',', $value);
$model->setData($attributes['data'], 'str');
}
if(vartrue($attributes['dataPath'])) if(vartrue($attributes['dataPath']))
{ {
$model->setData($attributes['dataPath'], $value); $model->setData($attributes['dataPath'], $value);
@@ -3117,7 +3125,8 @@ class e_admin_controller_ui extends e_admin_controller
{ {
// $fields[$field]['__tableField'] = $this->getJoinData($fields[$field]['table'], '__tablePath').$field; // $fields[$field]['__tableField'] = $this->getJoinData($fields[$field]['table'], '__tablePath').$field;
} }
/*if($fields[$field]['table']) /*
if($fields[$field]['table'])
{ {
if($fields[$field]['table'] == $this->getIfTableAlias(false)) if($fields[$field]['table'] == $this->getIfTableAlias(false))
{ {
@@ -3132,7 +3141,8 @@ class e_admin_controller_ui extends e_admin_controller
else else
{ {
$fields[$field]['__tableField'] = '`'.$this->getTableName(false, true).'`.'.$field; $fields[$field]['__tableField'] = '`'.$this->getTableName(false, true).'`.'.$field;
}*/ }
*/
} }
@@ -3149,8 +3159,6 @@ class e_admin_controller_ui extends e_admin_controller
*/ */
protected function joinAlias() protected function joinAlias()
{ {
//TODO - editQry
// TODO - auto-detect fields that belong to other tables. eg. u.user_id,u.user_name and adjust query to suit.
if($this->listQry) if($this->listQry)
{ {
preg_match_all("/`?#([\w-]+)`?\s*(as|AS)\s*([\w-])/im",$this->listQry,$matches); preg_match_all("/`?#([\w-]+)`?\s*(as|AS)\s*([\w-])/im",$this->listQry,$matches);
@@ -3172,7 +3180,6 @@ class e_admin_controller_ui extends e_admin_controller
{ {
$this->joinField[$m] = $match[0][$k]; $this->joinField[$m] = $match[0][$k];
} }
} }
} }
@@ -3202,15 +3209,25 @@ class e_admin_controller_ui extends e_admin_controller
if($searchFilter && is_array($searchFilter)) if($searchFilter && is_array($searchFilter))
{ {
list($filterField, $filterValue) = $searchFilter; list($filterField, $filterValue) = $searchFilter;
if($filterField && $filterValue !== '' && isset($this->fields[$filterField])) if($filterField && $filterValue !== '' && isset($this->fields[$filterField]))
{
if($this->fields[$filterField]['data'] == 'comma')
{
$searchQry[] = "FIND_IN_SET('".$tp->toDB($filterValue)."',".$this->fields[$filterField]['__tableField'].")";
}
else
{ {
$searchQry[] = $this->fields[$filterField]['__tableField']." = '".$tp->toDB($filterValue)."'"; $searchQry[] = $this->fields[$filterField]['__tableField']." = '".$tp->toDB($filterValue)."'";
} }
}
} }
elseif($searchFilter && is_string($searchFilter)) elseif($searchFilter && is_string($searchFilter))
{ {
// filter callbacks could add to WHERE clause // filter callbacks could add to WHERE clause
$searchQry[] = $searchFilter; $searchQry[] = $searchFilter;
} }
@@ -4138,6 +4155,11 @@ class e_admin_ui extends e_admin_controller_ui
{ {
$this->dataFields[$key] = vartrue($att['data'], 'str'); $this->dataFields[$key] = vartrue($att['data'], 'str');
} }
if($att['data'] == 'comma') //XXX quick fix so it can be stored.
{
$this->dataFields[$key] = 'str';
}
} }
} }
// TODO - do it in one loop, or better - separate method(s) -> convertFields(validate), convertFields(data),... // TODO - do it in one loop, or better - separate method(s) -> convertFields(validate), convertFields(data),...
@@ -4736,3 +4758,5 @@ include_once(e107::coreTemplatePath('admin_icons'));
* 16. tabs support (create/edit view) * 16. tabs support (create/edit view)
* 17. tree list view (should handle cases like Site Links admin page) * 17. tree list view (should handle cases like Site Links admin page)
*/ */
?>

View File

@@ -917,9 +917,10 @@ 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) if($options['multiple'])
{ {
$name = $name.'[]'; $name = (strpos($name, '[') === false) ? $name.'[]' : $name;
$selected = explode(",",$selected);
} }
$text = $this->select_open($name, $options)."\n"; $text = $this->select_open($name, $options)."\n";

View File

@@ -2397,7 +2397,13 @@ class e_front_model extends e_model
{ {
$qry['_FIELD_TYPES'][$key] = $type; //_FIELD_TYPES much more optional now... $qry['_FIELD_TYPES'][$key] = $type; //_FIELD_TYPES much more optional now...
} }
if($qry['_FIELD_TYPES'][$key] == 'comma') //XXX quick fix.
{
$qry['_FIELD_TYPES'][$key] = 'str';
}
$qry['data'][$key] = $this->getData($key); $qry['data'][$key] = $this->getData($key);
} }
switch($action) switch($action)
@@ -2417,6 +2423,7 @@ class e_front_model extends e_model
break; break;
} }
$this->addMessageDebug('SQL Qry: '.print_a($qry,true), $session_messages);
return $qry; return $qry;
} }