Minor update to support the 'IN' search type, avoid wrapping floating point in CDATA, and to support the grid request for multiple pages.
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@991 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -645,15 +645,12 @@ class AppController extends Controller {
|
||||
// Grouping (which would not be typical)
|
||||
$query['group'] = $this->gridDataCountGroup($params, $model);
|
||||
|
||||
if ($params['debug'])
|
||||
$params['count_query'] = $query;
|
||||
|
||||
// Get the number of records prior to pagination
|
||||
return $this->gridDataCountExecute($params, $model, $query);
|
||||
}
|
||||
|
||||
function gridDataCountExecute(&$params, &$model, $query) {
|
||||
return $model->find('count', $query);
|
||||
return $this->gridDataFind($params, $model, 'count', $query);
|
||||
}
|
||||
|
||||
function gridDataCountTables(&$params, &$model) {
|
||||
@@ -871,6 +868,9 @@ class AppController extends Controller {
|
||||
$page = ($params['page'] <= 1) ? 1 : (($params['page'] > $total) ? $total : $params['page']);
|
||||
$start = $limit * ($page - 1);
|
||||
|
||||
// Adjust the limit upward, if multiple pages were requested.
|
||||
$limit *= empty($params['npage']) ? 1 : $params['npage'];
|
||||
|
||||
return compact('record_count', 'limit', 'page', 'start', 'total');
|
||||
}
|
||||
|
||||
@@ -902,14 +902,11 @@ class AppController extends Controller {
|
||||
isset($params['sidx']) ? $params['sidx'] : null,
|
||||
isset($params['sord']) ? $params['sord'] : null);
|
||||
|
||||
if ($params['debug'])
|
||||
$params['query'] = $query;
|
||||
|
||||
return $this->gridDataRecordsExecute($params, $model, $query);
|
||||
}
|
||||
|
||||
function gridDataRecordsExecute(&$params, &$model, $query) {
|
||||
return $model->find('all', $query);
|
||||
return $this->gridDataFind($params, $model, 'all', $query);
|
||||
}
|
||||
|
||||
function gridDataTables(&$params, &$model) {
|
||||
@@ -957,6 +954,7 @@ class AppController extends Controller {
|
||||
'le' => array('op' => '<=', 'pre' => '', 'post' => ''),
|
||||
'gt' => array('op' => '>', 'pre' => '', 'post' => ''),
|
||||
'ge' => array('op' => '>=', 'pre' => '', 'post' => ''),
|
||||
'in' => array('op' => 'IN', 'pre' => '(', 'post' => ')'),
|
||||
'bw' => array('op' => 'LIKE', 'pre' => '', 'post' => '%'),
|
||||
'ew' => array('op' => 'LIKE', 'pre' => '%', 'post' => ''),
|
||||
'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'),
|
||||
@@ -1006,6 +1004,13 @@ class AppController extends Controller {
|
||||
return $start . ', ' . $limit;
|
||||
}
|
||||
|
||||
function gridDataFind(&$params, &$model, $type, $query) {
|
||||
if ($params['debug'])
|
||||
$params['queries'][] = compact('type', 'query');
|
||||
|
||||
return $model->find($type, $query);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -1152,6 +1157,7 @@ class AppController extends Controller {
|
||||
}
|
||||
|
||||
function gridDataOutputSummary(&$params, &$model, $pagination) {
|
||||
if ($params['debug'])
|
||||
echo " <params><![CDATA[\n" . print_r($params, true) . "\n]]></params>\n";
|
||||
echo " <page>{$pagination['page']}</page>\n";
|
||||
echo " <total>{$pagination['total']}</total>\n";
|
||||
@@ -1193,7 +1199,7 @@ class AppController extends Controller {
|
||||
|
||||
function gridDataOutputRecordCell(&$params, &$model, &$record, $field, $data) {
|
||||
// be sure to put text data in CDATA
|
||||
if (preg_match("/^\d*$/", $data))
|
||||
if (preg_match("/^[\d.]*$/", $data))
|
||||
echo " <cell>$data</cell>\n";
|
||||
else
|
||||
echo " <cell><![CDATA[$data]]></cell>\n";
|
||||
|
||||
Reference in New Issue
Block a user