forked from extern/egroupware
cleaned op logic
added action support for result_sets still some layout stuff to do
This commit is contained in:
parent
fba9f65ae3
commit
10ff4dd436
@ -65,16 +65,23 @@
|
|||||||
*/
|
*/
|
||||||
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
||||||
{
|
{
|
||||||
|
$value = is_array($extension_data) ? $extension_data : $value;
|
||||||
|
|
||||||
$tpl =& new etemplate;
|
$tpl =& new etemplate;
|
||||||
$tpl->init('*** generated advanced search widget','','',0,'',0,0); // make an empty template
|
$tpl->init('*** generated advanced search widget','','',0,'',0,0); // make an empty template
|
||||||
$tpl->add_child($tpl,$search_header = $tpl->empty_cell('label','Advanced search',array(
|
$tpl->add_child($tpl,$search_header = $tpl->empty_cell('label',$cell['label'],array(
|
||||||
'no_lang' => 0,
|
'no_lang' => 0,
|
||||||
'label' => 'Advanced search',
|
'label' => 'Advanced search',
|
||||||
'row' => array( 0 => array('#' => '800px')),
|
'span' =>',heading1',
|
||||||
)));
|
)));
|
||||||
|
if($value['msg'])
|
||||||
|
{
|
||||||
|
$tpl->add_child($tpl,$msg = $tpl->empty_cell('label','msg',array(
|
||||||
|
'no_lang' => true,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($value['result_nm']))
|
||||||
if (isset($extension_data['result']))
|
|
||||||
{
|
{
|
||||||
$GLOBALS['egw']->session->appsession('result','etemplate',$extension_data['result']);
|
$GLOBALS['egw']->session->appsession('result','etemplate',$extension_data['result']);
|
||||||
$tpl->add_child($tpl, $result_nm = $tpl->empty_cell('nextmatch','result_nm',array(
|
$tpl->add_child($tpl, $result_nm = $tpl->empty_cell('nextmatch','result_nm',array(
|
||||||
@ -84,13 +91,13 @@
|
|||||||
$result_rows_tpl =& new etemplate;
|
$result_rows_tpl =& new etemplate;
|
||||||
$result_rows_tpl->init('*** generated rows template for advanced search results','','',0,'',0,0);
|
$result_rows_tpl->init('*** generated rows template for advanced search results','','',0,'',0,0);
|
||||||
$grid =& $result_rows_tpl->children[0];
|
$grid =& $result_rows_tpl->children[0];
|
||||||
|
|
||||||
foreach((array)$extension_data['colums_to_present'] as $field => $label)
|
foreach((array)$extension_data['colums_to_present'] as $field => $label)
|
||||||
{
|
{
|
||||||
if($label == '') continue;
|
if($label == '') continue;
|
||||||
$result_rows_tpl->add_child($grid,$result_nm_header = $result_rows_tpl->empty_cell('nextmatch-sortheader',$field,array(
|
$result_rows_tpl->add_child($grid,$result_nm_header = $result_rows_tpl->empty_cell('nextmatch-sortheader',$field,array(
|
||||||
'label' => $label,
|
'label' => $label,
|
||||||
'no_lang' => true,
|
'no_lang' => true,
|
||||||
|
'span' => ',nmh',
|
||||||
)));
|
)));
|
||||||
unset($result_nm_header);
|
unset($result_nm_header);
|
||||||
}
|
}
|
||||||
@ -106,31 +113,46 @@
|
|||||||
unset($result_nm_rows);
|
unset($result_nm_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
$value['result_nm'] = array(
|
$value['result_nm'] = array_merge(
|
||||||
|
$value['result_nm'],
|
||||||
|
array(
|
||||||
'no_filter' => true,
|
'no_filter' => true,
|
||||||
'no_filter2' => true,
|
'no_filter2' => true,
|
||||||
'no_cat' => true,
|
'no_cat' => true,
|
||||||
'template' => $result_rows_tpl,
|
'no_search' => true,
|
||||||
'get_rows' => 'etemplate.advancedsearch_widget.get_rows',
|
'get_rows' => 'etemplate.advancedsearch_widget.get_rows',
|
||||||
);
|
'search_method' => $value['search_method'],
|
||||||
|
'colums_to_present' => $value['colums_to_present'],
|
||||||
|
'template' => $result_rows_tpl,
|
||||||
|
));
|
||||||
|
|
||||||
$tpl->add_child($tpl, $result_button = $tpl->empty_cell('button','button[action]',array(
|
$tpl->add_child($tpl, $action_buttons = $tpl->empty_cell('hbox','action_buttons'));
|
||||||
'label' => 'dump',
|
foreach ($value['actions'] as $action => $options)
|
||||||
'no_lang' => true,
|
{
|
||||||
)));
|
$tpl->add_child($action_buttons, $result_button = $tpl->empty_cell($options['type'],'action['.$action.']',$options['options']));
|
||||||
|
unset($result_button);
|
||||||
//unset($extension_data['result']);
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$GLOBALS['egw_info']['etemplate']['advanced_search'] = true;
|
||||||
$extension_data = $value;
|
$extension_data = $value;
|
||||||
|
|
||||||
$tpl->add_child($tpl, $search_template = $tpl->empty_cell('template',$value['input_template']));
|
$tpl->add_child($tpl, $search_template = $tpl->empty_cell('template',$value['input_template']));
|
||||||
$tpl->add_child($tpl, $search_button = $tpl->empty_cell('button','button[search]',array(
|
$tpl->add_child($tpl, $button_box = $tpl->empty_cell('hbox','button_box'));
|
||||||
|
$tpl->add_child($button_box, $op_select = $tpl->empty_cell('select','opt_select',array(
|
||||||
|
'sel_options' => array(
|
||||||
|
'OR' => 'OR',
|
||||||
|
'AND' => 'AND'
|
||||||
|
),
|
||||||
|
'label' => 'Operator',
|
||||||
|
'no_lang' => true,
|
||||||
|
)));
|
||||||
|
$tpl->add_child($button_box, $search_button = $tpl->empty_cell('button','button[search]',array(
|
||||||
'label' => 'Search',
|
'label' => 'Search',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
;
|
||||||
$cell['size'] = $cell['name'];
|
$cell['size'] = $cell['name'];
|
||||||
$cell['type'] = 'template';
|
$cell['type'] = 'template';
|
||||||
$cell['name'] = $tpl->name;
|
$cell['name'] = $tpl->name;
|
||||||
@ -145,6 +167,7 @@
|
|||||||
}
|
}
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* postprocessing method, called after the submission of the form
|
* postprocessing method, called after the submission of the form
|
||||||
*
|
*
|
||||||
@ -161,32 +184,39 @@
|
|||||||
* @return boolean true if $value has valid content, on false no content will be returned!
|
* @return boolean true if $value has valid content, on false no content will be returned!
|
||||||
*/
|
*/
|
||||||
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
|
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
|
||||||
|
{
|
||||||
|
//echo 'advancedsearch_widget::post_process->value'; _debug_array($value);
|
||||||
|
//echo 'advancedsearch_widget::post_process->extension_data'; _debug_array($extension_data);
|
||||||
|
if(!isset($extension_data['result_nm']['search_values']))
|
||||||
{
|
{
|
||||||
foreach($value as $haystack => $needle)
|
foreach($value as $haystack => $needle)
|
||||||
{
|
{
|
||||||
if($needle == '') unset($value[$haystack]);
|
if($needle == '') unset($value[$haystack]);
|
||||||
}
|
}
|
||||||
// _debug_array($value);
|
$extension_data['result_nm']['search_values'] = $value;
|
||||||
if($value['button']['search'])
|
}
|
||||||
|
elseif(isset($value['action']))
|
||||||
{
|
{
|
||||||
$extension_data['result'] = ExecMethod($extension_data['search_method'],array(
|
$result = $GLOBALS['egw']->session->appsession('advanced_search_result','etemplate');
|
||||||
0 => $value, // citeria
|
_debug_array($result);
|
||||||
1 => implode(',',array_flip($extension_data['colums_to_present'])), // only_keys
|
$extension_data['msg'] = ExecMethod2($extension_data['actions'][key($value['action'])]['method'],$result);
|
||||||
2 => '', // order_by
|
}
|
||||||
3 => '', // extra_cols
|
else
|
||||||
4 => '', // wildcard
|
{
|
||||||
5 => '', // empty
|
$extension_data['result_nm'] = array_merge($extension_data['result_nm'],$value['result_nm']);
|
||||||
6 => 'OR', // operaror
|
|
||||||
'multivalue' => true,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_rows($query,&$rows,&$readonlys)
|
function get_rows($query,&$rows,&$readonlys)
|
||||||
{
|
{
|
||||||
$rows = $GLOBALS['egw']->session->appsession('result','etemplate');
|
$order_by = $query['order'] ? $query['order'].' '.$query['sort'] : '';
|
||||||
// _debug_array($data);
|
$only_keys = implode(',',array_flip($query['colums_to_present']));
|
||||||
return count($rows);
|
$rows = ExecMethod2($query['search_method'],$query['search_values'],$only_keys,
|
||||||
|
$order_by,'','','',$query['search_values']['opt_select'],$query['start']);
|
||||||
|
$result = ExecMethod2($query['search_method'],$query['search_values'],$only_keys,'','','','',$query['search_values']['opt_select'],false,'','',false);
|
||||||
|
// We store the result in session so actions can fetch them here:
|
||||||
|
$GLOBALS['egw']->session->appsession('advanced_search_result','etemplate',$result);
|
||||||
|
return count($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user