Some extra debug for et2

This commit is contained in:
Nathan Gray 2013-02-04 12:35:30 +00:00
parent 36f38bb956
commit 129601366e
4 changed files with 78 additions and 4 deletions

View File

@ -138,7 +138,7 @@ class etemplate_new extends etemplate_widget_template
// instanciate template to fill self::$request->sel_options for select-* widgets
// not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes
$template = etemplate_widget_template::instance($this->name, $this->template_set, $this->version, $this->laod_via);
$template->run('beforeSendToClient');
$template->run('beforeSendToClient', array('', array('cont'=>$content)));
$data = array(
'etemplate_exec_id' => self::$request->id(),

View File

@ -345,7 +345,7 @@ class etemplate_widget
// maintain $expand array name-expansion
$cname = $params[0];
$expand =& $params[1];
if ($expand['cname'] !== $cname)
if ($expand['cname'] && $expand['cname'] !== $cname)
{
$expand['cont'] =& self::get_array(self::$request->content, $cname);
$expand['cname'] = $cname;
@ -360,7 +360,23 @@ class etemplate_widget
}
if (method_exists($this, $method_name))
{
call_user_func_array(array($this, $method_name), $params);
// Some parameter checking to avoid fatal errors
$call = true;
$method = new ReflectionMethod($this, $method_name);
foreach($method->getParameters() as $index => $param)
{
if(!$param->isOptional() && !array_key_exists($index,$params))
{
error_log("Missing required parameter {$param->getPosition()}: {$param->getName()}");
$call = false;
}
if($param->isArray() && !is_array($params[$index]))
{
error_log("$method_name expects an array for {$param->getPosition()}: {$param->getName()}");
$params[$index] = (array)$params[$index];
}
}
if($call) call_user_func_array(array($this, $method_name), $params);
}
foreach($this->children as $child)
{
@ -537,7 +553,8 @@ class etemplate_widget
*/
public function __toString()
{
return $this->type.($this->attrs['type'] && $this->attrs['type'] != $this->type ? '('.$this->attrs['type'].')' : '').'#'.$this->id;
return '['.get_class($this).'] ' .
$this->type.($this->attrs['type'] && $this->attrs['type'] != $this->type ? '('.$this->attrs['type'].')' : '').'#'.$this->id;
}
/**

View File

@ -128,6 +128,7 @@ class etemplate_widget_grid extends etemplate_widget_box
continue; // do NOT run $method_name on disabled columns
}
}
//error_log('Running ' . $method_name . ' on child ' . $n . '(' . $child . ') ['.$expand['row'] . ','.$expand['c'] . ']');
$disabled = $child->run($method_name, $params, $respect_disabled, $columns_disabled) === false;
if ($this->type == 'columns' && $disabled)

View File

@ -25,6 +25,62 @@ class etemplate_widget_vfs extends etemplate_widget_file
if($xml) parent::__construct($xml);
}
/**
* If widget is a vfs-file widget, and there are files in the specified directory,
* they should be displayed.
*/
public function beforeSendToClient($cname, $expand = array())
{
if($this->type == 'vfs-upload')
{
echo "EXPAND";
_debug_array($expand);
$form_name = self::form_name($cname, $this->id, $expand ? $expand : array('cont'=>self::$request->content));
echo "this-ID: {$this->id}<br />";
echo "Form name: $form_name<br />";
// ID maps to path - check there for any existing files
list($app,$id,$relpath) = explode(':',$this->id,3);
if($app && $id)
{
echo "ID: $id<br />";
if(!is_numeric($id))
{
$_id = self::expand_name($id,0,0,0,0,self::$request->content);
if($_id != $id)
{
$id = $_id;
$form_name = "$app:$id:$relpath";
echo "Form name: $form_name<br />";
}
}
$value =& self::get_array(self::$request->content, $form_name, true);
echo "ID: $id<br />";
$path = egw_link::vfs_path($app,$id,'',true);
if (!empty($relpath)) $path .= '/'.$relpath;
// Single file, already existing
if (substr($path,-1) != '/' && egw_vfs::file_exists($path) && !egw_vfs::is_dir($path))
{
$value = $path;
}
else if (substr($path, -1) == '/' && egw_vfs::is_dir($path))
{
$value = egw_vfs::scandir($path);
echo 'HERE!';
foreach($value as &$file)
{
echo $file.'<br />';
$file = egw_vfs::stat("$path$file");
_debug_array($file);
}
}
}
echo $this;
_debug_array($value);
}
}
public static function ajax_upload() {
parent::ajax_upload();
error_log(array2string($_FILES));