changed interface for extensions to:

pre_process(&$cell,&$value,&$extension_data,&$readonlys)
post_process(&$cell,&$value,&$extension_data,&$loop)
This commit is contained in:
Ralf Becker 2002-09-24 21:57:15 +00:00
parent 19eef3f976
commit 7bd87b1180
5 changed files with 30 additions and 28 deletions

View File

@ -44,7 +44,7 @@
return 0;
}
function pre_process(&$cell,&$value,&$templ)
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
{
if ($cell['size'] != '')
{
@ -74,7 +74,7 @@
return $this->$func($cell,$form_name,$value,$readonly);
}
function post_process(&$cell,&$value,&$templ)
function post_process(&$cell,&$value,&$extension_data,&$loop)
{
if (!isset($value))
{

View File

@ -30,7 +30,7 @@
{
}
function pre_process(&$cell,&$value,&$templ)
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
{
if ($cell['size'] != '')
{
@ -69,7 +69,7 @@
return True; // extra Label is ok
}
function post_process(&$cell,&$value,&$templ)
function post_process(&$cell,&$value,&$extension_data,&$loop)
{
if (!isset($value))
{

View File

@ -31,11 +31,11 @@
{
}
function pre_process(&$cell,&$value,&$templ,&$readonlys)
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
{
//echo "<p>nextmatch_widget.pre_process: value = "; _debug_array($value);
// save values in persistent extension_data to be able use it in post_process
$GLOBALS['phpgw_info']['etemplate']['extension_data']['nextmatch_widget'][$cell['name']] = $value;
$extension_data = $value;
list($app,$class,$method) = explode('.',$value['get_rows']);
$obj = CreateObject($app.'.'.$class);
@ -45,7 +45,7 @@
$value['start'] = 0;
$total = $obj->$method($value,$value['rows'],$readonlys['rows']);
}
$GLOBALS['phpgw_info']['etemplate']['extension_data']['nextmatch_widget'][$cell['name']]['total'] = $total;
$extension_data['total'] = $total;
if ($cell['size'])
{
@ -81,11 +81,11 @@
return False; // NO extra Label
}
function post_process(&$cell,&$value,&$templ)
function post_process(&$cell,&$value,&$extension_data,&$loop)
{
//echo "<p>nextmatch_widget.post_process: value = "; _debug_array($value);
$old_value = $GLOBALS['phpgw_info']['etemplate']['extension_data']['nextmatch_widget'][$cell['name']];
$old_value = $extension_data;
list($value['cat_id']) = $value['cat_id'];
list($value['filter']) = $value['filter'];
@ -93,7 +93,7 @@
$value['start'] = $old_value['start']; // need to be set, to be reported back
$max = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
$templ->loop = False;
$loop = False;
if ($value['start_search'] || $value['cat_id'] != $old_value['cat_id'] ||
$old_value['filter'] != '' && $value['filter'] != $old_value['filter'] ||
$old_value['filter2'] != '' && $value['filter2'] != $old_value['filter2'])
@ -101,27 +101,27 @@
//echo "<p>search='$old_value[search]'->'$value[search]', filter='$old_value[filter]'->'$value[filter]', filter2='$old_value[filter2]'->'$value[filter2]'<br>";
//echo "new filter --> loop</p>";
//_debug_array($old_value);
$templ->loop = True;
$loop = True;
}
elseif ($value['first'])
{
$value['start'] = 0;
$templ->loop = True;
$loop = True;
}
elseif ($value['left'])
{
$value['start'] = $old_value['start'] - $max;
$templ->loop = True;
$loop = True;
}
elseif ($value['right'])
{
$value['start'] = $old_value['start'] + $max;
$templ->loop = True;
$loop = True;
}
elseif ($value['last'])
{
$value['start'] = (int) (($old_value['total']-2) / $max) * $max;
$templ->loop = True;
$loop = True;
}
return True;
}

View File

@ -31,7 +31,7 @@
{
}
function pre_process(&$cell,&$value,&$templ)
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
{
$labels = explode('|',$cell['label']);
$helps = explode('|',$cell['help']);
@ -50,7 +50,7 @@
if (is_array($value['_tab_widget']) && $value['_tab_widget'][$name][0])
{
// save selected tab in persistent extension_data to use it in post_process
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']] = $selected_tab = $name;
$extension_data = $selected_tab = $name;
$tcell['name'] = $tab_active;
}
else
@ -74,7 +74,7 @@
if (!isset($selected_tab))
{
$tab_row['A']['name'] = $tab_active;
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']] = $selected_tab = $names[0];
$extension_data = $selected_tab = $names[0];
}
$tabs->data[1] = $tab_row;
$tabs->rows = 1;
@ -92,13 +92,13 @@
return False; // NO extra Label
}
function post_process(&$cell,&$value,&$templ)
function post_process(&$cell,&$value,&$extension_data,&$loop)
{
$old_value = array(
'_tab_widget' => array(
$GLOBALS['phpgw_info']['etemplate']['extension_data']['tab_widget'][$cell['name']] => array(True)
$extension_data => array(True)
));
$this->pre_process($cell,$old_value,$templ);
$this->pre_process($cell,$old_value,$extension_data,$dummy);
if (is_array($value['_tab_widget']))
{
@ -106,12 +106,10 @@
{
if (is_array($val) && $val[0])
{
$templ->loop = True;
$loop = True;
}
}
}
//$templ->loop = is_array($value['_tab_widget']);
return True;
}
}

View File

@ -101,6 +101,7 @@
$id = $this->appsession_id();
$GLOBALS['phpgw_info']['etemplate']['loop'] = False;
$GLOBALS['phpgw_info']['etemplate']['form_options'] = ''; // might be set in show
$html .= $this->html->nextMatchStyles($this->style)."\n\n". // so they get included once
$this->html->form($this->include_java_script() .
@ -165,7 +166,7 @@
$content = $this->complete_array_merge($session_data['changes'],$content);
//echo "process_exec($this->name) merge(changes,content) ="; _debug_array($content);
if ($this->loop)
if ($GLOBALS['phpgw_info']['etemplate']['loop'])
{
//echo "<p>process_exec($this->name): <font color=red>loop is set</font>, content=</p>\n"; _debug_array($content);
$this->exec($session_data['method'],$session_data['content'],$session_data['sel_options'],
@ -364,7 +365,8 @@
if (!$this->types[$cell['type']] &&
(isset($this->extension[$cell['type']]) || $this->loadExtension($cell['type'],$this)))
{
$extra_label = $this->extension[$cell['type']]->pre_process($cell,$value,$this,$readonlys[$name]);
$extra_label = $this->extension[$cell['type']]->pre_process($cell,$value,
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$cell['type']][$cell['name']],$readonlys[$name]);
if (strstr($name,'|'))
{
$content = $this->complete_array_merge($content,$value);
@ -457,7 +459,7 @@
if ($this->java_script() && $cell['onchange'])
{
$html .= $this->html->input_hidden($form_name,'',False) . "\n";
$html .= '<a href="" onClick="set_element(document.eTemplate,\''.$form_name.'\',\'pressed\'); document.eTemplate.submit(); return false;">' .
$html .= '<a href="" onClick="set_element(document.eTemplate,\''.$form_name.'\',\'pressed\'); document.eTemplate.submit(); return false;" '.$options.'>' .
(strlen($label) <= 1 || $cell['no_lang'] ? $label : lang($label)) . '</a>';
}
else
@ -754,7 +756,9 @@
{
echo "<p>value for $cell[type]::post_process: "; _debug_array($value);
}
$this->extension[$cell['type']]->post_process($cell,$value,$this);
$this->extension[$cell['type']]->post_process($cell,$value,
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$cell['type']][$cell['name']],
$GLOBALS['phpgw_info']['etemplate']['loop']);
if ($this->debug > 1 || $this->debug && $this->debug == $this->name)
{