allow to call etemplate_widget::setElementAttribute() static eg. from within a get_rows method

This commit is contained in:
Ralf Becker 2014-02-27 17:43:51 +00:00
parent b8801d64e5
commit 2e287689ef
2 changed files with 9 additions and 3 deletions

View File

@ -853,15 +853,18 @@ class etemplate_widget
/** /**
* Set an attribute in a named cell if val is not NULL else return the attribute * Set an attribute in a named cell if val is not NULL else return the attribute
* *
* Can be called static, in which case it only sets modifications.
*
* @param string $name cell-name * @param string $name cell-name
* @param string $attr attribute-name * @param string $attr attribute-name
* @param mixed $val if not NULL sets attribute else returns it * @param mixed $val if not NULL sets attribute else returns it
* @return reference to attribute * @return reference to attribute
*/ */
public function &setElementAttribute($name,$attr,$val) public static function &setElementAttribute($name,$attr,$val)
{ {
error_log(__METHOD__."('$name', '$attr', ...) request=".get_class(self::$request).", response=".get_class(self::$response).function_backtrace());
$ref =& self::$request->modifications[$name][$attr]; $ref =& self::$request->modifications[$name][$attr];
if(self::$request && self::$response && $val != $this->attrs[$attr]) if(self::$request && self::$response && (!isset($this) || $val != $this->attrs[$attr]))
{ {
// In an AJAX response - automatically add // In an AJAX response - automatically add
self::$response->generic('assign',array( self::$response->generic('assign',array(
@ -870,8 +873,9 @@ class etemplate_widget
'key' => $attr, 'key' => $attr,
'value' => $val 'value' => $val
)); ));
error_log(__METHOD__."('$name', '$attr', ...) ".function_backtrace());
} }
$this->attrs[$attr] = $val; if (isset($this)) $this->attrs[$attr] = $val;
if (!is_null($val)) $ref = $val; if (!is_null($val)) $ref = $val;
//error_log(__METHOD__."('$name', '$attr', ".array2string($val).')'); //error_log(__METHOD__."('$name', '$attr', ".array2string($val).')');

View File

@ -263,6 +263,8 @@ class etemplate_widget_nextmatch extends etemplate_widget
array $knownUids=null, $lastModified=null) array $knownUids=null, $lastModified=null)
{ {
self::$request = etemplate_request::read($exec_id); self::$request = etemplate_request::read($exec_id);
self::$response = egw_json_response::get();
$value = self::get_array(self::$request->content, $form_name, true); $value = self::get_array(self::$request->content, $form_name, true);
if(!is_array($value)) if(!is_array($value))
{ {