Modified the filtering behavior; A filter specified as 'Table.field' results in the obvious split (Table, field); 'Table' results in (Table, id); 'field' results in (ModelTable, field). Fixed a bug in the app controller which was allowing 'fields' to leak into the top level of 'link'

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@430 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-30 19:45:19 +00:00
parent 07232c77d5
commit 63de30d392
12 changed files with 33 additions and 26 deletions

View File

@@ -309,20 +309,26 @@ class AppController extends Controller {
foreach ($params['post']['filter'] AS $filter => $value) {
$split = $this->gridDataFilterSplit($params, $model, $filter);
/* pr(array('AppController::gridDataFilterTable' => */
/* array('checkpoint' => "Filter split") */
/* + compact('split'))); */
$table = $this->gridDataFilterTablesTable($params, $model, $split['table']);
if (!$table)
continue;
$config = $this->gridDataFilterTablesConfig($params, $model, $split['table']);
/* pr(array('pre-filter-table-config' => */
/* array('query[link]' => $query[$link], */
/* 'config' => $config))); */
/* pr(array('AppController::gridDataFilterTable' => */
/* array('checkpoint' => "Add filter config to query") */
/* + array('query[link]' => $query[$link]) */
/* + compact('config'))); */
// If the table is already part of the query, append to it
if ($table == $model->alias) {
$query[$link] =
array_merge_recursive($config, $query[$link]);
array_merge_recursive(array_diff_key($config, array('fields'=>1)),
$query[$link]);
}
elseif (isset($query[$link][$table])) {
$query[$link][$table] =
@@ -413,13 +419,14 @@ class AppController extends Controller {
if (preg_match("/\./", $filter)) {
list($table, $field) = explode(".", $filter);
}
elseif (preg_match('/^(.*)_(id)$/', $filter, $matches)) {
list($table, $field) = array_slice($matches, 1);
}
else {
elseif (preg_match('/^[A-Z]/', $filter)) {
$table = $filter;
$field = null;
}
else {
$table = $model->alias;
$field = $filter;
}
return array('table' => $table, 'field' => $field);
}