From 7d836e4c53e377c5653eb3918a3bc53acbf52fed Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 22 Feb 2003 12:29:04 +0000 Subject: [PATCH] some docu updates and cleaned up some debug-code --- etemplate/inc/class.link_widget.inc.php | 51 +++++++++++++++++-------- etemplate/inc/class.uietemplate.inc.php | 13 ++++--- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/etemplate/inc/class.link_widget.inc.php b/etemplate/inc/class.link_widget.inc.php index 718f38589f..f91e1c337e 100644 --- a/etemplate/inc/class.link_widget.inc.php +++ b/etemplate/inc/class.link_widget.inc.php @@ -30,6 +30,7 @@ 'link-to' => 'LinkTo', 'link-list' => 'LinkList' ); + var $debug = False; function link_widget($ui) { @@ -45,7 +46,11 @@ 'to_app' => $GLOBALS['phpgw_info']['flags']['currentapp'] ); } - //echo "

start: $cell[type]::pre_process: value ="; _debug_array($value); + if ($this->debug) + { + echo "

start: $cell[type][$name]::pre_process: value ="; _debug_array($value); + echo "extension_data[$cell[type]][$name] ="; _debug_array($extension_data); + } switch ($type = $cell['type']) { case 'link-to': @@ -82,9 +87,11 @@ case 'link-list': $app = $value['to_app']; - $id = $value['to_id']; - //echo "

link-list-widget.preprocess: value="; _debug_array($value); - + $id = isset($extension_data['to_id']) ? $extension_data['to_id'] : $value['to_id']; + if ($this->debug) + { + echo "

link-list-widget[$name].preprocess: value="; _debug_array($value); + } if (!isset($value['title'])) { $value['title'] = $this->link->title($app,$id); @@ -114,16 +121,19 @@ $cell['name'] = $tpl->name; $cell['obj'] = &$tpl; - //echo "

end: $type::pre_process: value ="; _debug_array($value); + if ($this->debug) + { + echo "

end: $type"."[$name]::pre_process: value ="; _debug_array($value); + } return True; // extra Label is ok } function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in) { $buttons = array('search','create','new','upload','attach'); - while (!$button && list(,$name) = each($buttons)) + while (!$button && list(,$bname) = each($buttons)) { - $button = $value[$name] ? $name : ''; + $button = $value[$bname] ? $bname : ''; } if (is_array($value['unlink'])) { @@ -133,10 +143,10 @@ unset($value[$button]); $value = array_merge($extension_data,$value); - + if ($button && $this->debug) { - echo "

start: link_widget::post_process: button='$button', unlink='$unlink', value ="; _debug_array($value); + echo "

start: link_widget[$name]::post_process: button='$button', unlink='$unlink', value ="; _debug_array($value); } switch ($button) { @@ -145,7 +155,7 @@ { $link_id = $this->link->link($value['to_app'],$value['to_id'], $value['app'],$value['id'],$value['remark']); - + if (isset($value['primary']) && !$value['anz_links'] ) { $value['primary'] = $link_id; @@ -162,16 +172,16 @@ if (is_array($value['file']) && $value['to_app']) { $link_id = $this->link->link($value['to_app'],$value['to_id'], - 'vfs',$value['file'],$value['remark']); + $this->link->vfs_appname,$value['file'],$value['remark']); unlink($value['file']['tmp_name']); - unset($value['file']); + unset($value['file']); } $extension_data = $value; $loop = True; break; case 'upload': // need to rename file, as php deletes it otherwise - if (is_array($value['file']) && !empty($value['file']['tmp_name']) && + if (is_array($value['file']) && !empty($value['file']['tmp_name']) && $value['file']['tmp_name'] != 'none') { move_uploaded_file($value['file']['tmp_name'],$value['file']['tmp_name'].'+'); @@ -187,13 +197,24 @@ break; case 'unlink': + if ($this->debug) + { + echo "

unlink(link-id=$unlink,$value[to_app],$value[to_id])

\n"; + if (is_array($value['to_id'])) _debug_array($value['to_id']); + } $this->link->unlink($unlink,$value['to_app'],&$value['to_id']); - //echo "

unlink(link-id=$unlink,$value[to_app],$value[to_id])

\n"; + if (is_array($value['to_id'])) + { + $extension_data['to_id'] = $value['to_id']; // else changes from unlink get lost + } $loop = True; break; } $value['button'] = $button; - //echo "

end: link_widget::post_process: value ="; _debug_array($value); + if ($this->debug) + { + echo "

end: link_widget[$name]::post_process: value ="; _debug_array($value); + } return True; } } diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index 93b2855ce6..92310d823d 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -67,7 +67,7 @@ function location($vars='') { Header('Location: ' . $this->html->link(is_array($vars) ? '/index.php' : $vars, - is_array($vars) ? $vars : '')); + is_array($vars) ? $vars : '')); $GLOBALS['phpgw']->common->phpgw_exit(); } @@ -276,7 +276,7 @@ { $readonlys = array(); } - if ($this->debug >= 1 || $this->debug == $this->name && $this->name) + if (is_int($this->debug) && $this->debug >= 1 || $this->debug == $this->name && $this->name) { echo "

etemplate.show($this->name): $cname =\n"; _debug_array($content); } @@ -414,7 +414,7 @@ */ function show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span) { - if ($this->debug >= 3 || $this->debug == $cell['type']) + if (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type']) { echo "

etemplate.show_cell($this->name,name='${cell['name']}',type='${cell['type']}',cname='$cname')

\n"; } @@ -625,7 +625,7 @@ $cell['obj'] = new etemplate(/*** TESTWEISE ***$cell['name']*/$name,$this->as_array()); } } - if ($this->debug >= 3 || $this->debug == $cell['type']) + if (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type']) { echo "

show_cell::template(tpl=$this->name,name=$cell[name]): $obj_read

\n"; } @@ -818,6 +818,7 @@ @abstract makes necessary adjustments on HTTP_POST_VARS after a eTemplate / form gots submitted @discussion This is only an internal function, dont call it direct use only exec @discussion Process_show uses a list of input-fields/widgets generated by show. + @syntax process_show(&$content,$to_process,$cname='') @param $content HTTP_POST_VARS[$cname] @param $to_process list of widgets/form-fields to process @param $cname basename of our returnt content (same as in call to show) @@ -829,7 +830,7 @@ { return; } - if ($this->debug >= 1 || $this->debug == $this->name && $this->name) + if (is_int($this->debug) && $this->debug >= 1 || $this->debug == $this->name && $this->name) { echo "

process_show($this->name) start: content ="; _debug_array($content); } @@ -911,7 +912,7 @@ { $content = $content[$cname]; } - if ($this->debug >= 2 || $this->debug == $this->name && $this->name) + if (is_int($this->debug) && $this->debug >= 2 || $this->debug == $this->name && $this->name) { echo "

process_show($this->name) end: content ="; _debug_array($content); }