mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-27 18:33:39 +01:00
change api\Etemplate\Widget::getElementAttribute($name,$attr) to NO longer return a reference, use setElementAttribute($name,$attr) if you need a reference
This commit is contained in:
parent
1612ddb030
commit
2552bea6a2
@ -644,7 +644,7 @@ class Etemplate extends Etemplate\Widget\Template
|
||||
* @return mixed reference to attribute, usually NULL
|
||||
* @deprecated use getElementAttribute($name, $attr)
|
||||
*/
|
||||
public function &get_cell_attribute($name,$attr)
|
||||
public function get_cell_attribute($name,$attr)
|
||||
{
|
||||
return self::getElementAttribute($name, $attr);
|
||||
}
|
||||
|
@ -1075,14 +1075,15 @@ class Widget
|
||||
/**
|
||||
* Returns reference to an attribute in a named cell
|
||||
*
|
||||
* Currently we always return a reference to an not set value, unless it was set before.
|
||||
* We do not return a reference to the actual cell, as it get's contructed on client-side!
|
||||
* We no longer return a reference to the attribute!
|
||||
*
|
||||
* If you need a reference, use: $attr =& setElementAttribute($name, $attr)
|
||||
*
|
||||
* @param string $name cell-name
|
||||
* @param string $attr attribute-name
|
||||
* @return mixed reference to attribute, usually NULL
|
||||
* @return mixed attribute, usually NULL
|
||||
*/
|
||||
public function &getElementAttribute($name, $attr)
|
||||
public function getElementAttribute($name, $attr)
|
||||
{
|
||||
//error_log(__METHOD__."('$name', '$attr')");
|
||||
return self::$request->modifications[$name][$attr];
|
||||
@ -1098,7 +1099,7 @@ class Widget
|
||||
* @param mixed $val if not NULL sets attribute else returns it
|
||||
* @return reference to attribute
|
||||
*/
|
||||
public static function &setElementAttribute($name,$attr,$val)
|
||||
public static function &setElementAttribute($name,$attr,$val=null)
|
||||
{
|
||||
if (!isset(self::$request))
|
||||
{
|
||||
@ -1106,7 +1107,7 @@ class Widget
|
||||
}
|
||||
//error_log(__METHOD__."('$name', '$attr', ...) request=".get_class(self::$request).", response=".get_class(self::$response).function_backtrace());
|
||||
$ref =& self::$request->modifications[$name][$attr];
|
||||
if(self::$request && self::$response)
|
||||
if(self::$request && self::$response && isset($val))
|
||||
{
|
||||
// In an AJAX response - automatically add
|
||||
self::$response->generic('assign',array(
|
||||
@ -1119,8 +1120,10 @@ class Widget
|
||||
self::$request->unset_to_process('');
|
||||
//error_log(__METHOD__."('$name', '$attr', ...) ".function_backtrace());
|
||||
}
|
||||
if (!is_null($val)) $ref = $val;
|
||||
|
||||
if (isset($val))
|
||||
{
|
||||
$ref = $val;
|
||||
}
|
||||
//error_log(__METHOD__."('$name', '$attr', ".array2string($val).')');
|
||||
return $ref;
|
||||
}
|
||||
@ -1130,7 +1133,7 @@ class Widget
|
||||
*
|
||||
* @param string $name cell-name
|
||||
* @param boolean $disabled =true disable or enable a cell, default true=disable
|
||||
* @return reference to attribute
|
||||
* @return attribute
|
||||
*/
|
||||
public function disableElement($name,$disabled=True)
|
||||
{
|
||||
|
@ -104,10 +104,10 @@ class Customfields extends Transformer
|
||||
}
|
||||
else
|
||||
{
|
||||
$app =& $this->getElementAttribute(self::GLOBAL_VALS, 'app');
|
||||
if($this->getElementAttribute($form_name, 'app'))
|
||||
$app =& self::setElementAttribute(self::GLOBAL_VALS, 'app');
|
||||
if(self::getElementAttribute($form_name, 'app'))
|
||||
{
|
||||
$app =& $this->getElementAttribute($form_name, 'app');
|
||||
$app =& self::setElementAttribute($form_name, 'app');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -116,15 +116,15 @@ class Customfields extends Transformer
|
||||
}
|
||||
}
|
||||
|
||||
if($this->getElementAttribute($form_name, 'customfields'))
|
||||
if(self::getElementAttribute($form_name, 'customfields'))
|
||||
{
|
||||
$customfields =& $this->getElementAttribute($form_name, 'customfields');
|
||||
$customfields =& self::setElementAttribute($form_name, 'customfields');
|
||||
}
|
||||
elseif($app)
|
||||
{
|
||||
// Checking creates it even if it wasn't there
|
||||
unset(self::$request->modifications[$form_name]['customfields']);
|
||||
$customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields');
|
||||
$customfields =& self::setElementAttribute(self::GLOBAL_VALS, 'customfields');
|
||||
}
|
||||
|
||||
if(!$app && !$customfields)
|
||||
@ -484,13 +484,13 @@ class Customfields extends Transformer
|
||||
// if we have no id / use self::GLOBAL_ID, we have to set $value_in in global namespace for regular widgets validation to find
|
||||
if (!$this->id) $content = array_merge($content, (array)$value_in);
|
||||
//error_log(__METHOD__."($cname, ...) form_name=$form_name, private={$this->attrs['private']}, value_in=".array2string($value_in));
|
||||
if($this->getElementAttribute($form_name, 'customfields'))
|
||||
if(self::getElementAttribute($form_name, 'customfields'))
|
||||
{
|
||||
$customfields =& $this->getElementAttribute($form_name, 'customfields');
|
||||
$customfields =& self::setElementAttribute($form_name, 'customfields');
|
||||
}
|
||||
else
|
||||
{
|
||||
$customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields');
|
||||
$customfields =& self::setElementAttribute(self::GLOBAL_VALS, 'customfields');
|
||||
}
|
||||
if(is_array($value_in))
|
||||
{
|
||||
|
@ -149,9 +149,10 @@ class Select extends Etemplate\Widget
|
||||
{
|
||||
$widget_type = substr($widget_type, 4);
|
||||
}
|
||||
$multiple = $this->attrs['multiple'] || $this->getElementAttribute($form_name, 'multiple') || $this->getElementAttribute($form_name, 'rows') > 1;
|
||||
$allowFreeEntries = $this->attrs['allowFreeEntries'] || $this->getElementAttribute($form_name, 'allowFreeEntries') ||
|
||||
$this->attrs['searchUrl'] || $this->getElementAttribute($form_name, 'searchUrl');
|
||||
$multiple = $this->attrs['multiple'] || self::getElementAttribute($form_name, 'multiple') ||
|
||||
self::getElementAttribute($form_name, 'rows') > 1;
|
||||
$allowFreeEntries = $this->attrs['allowFreeEntries'] || self::getElementAttribute($form_name, 'allowFreeEntries') ||
|
||||
$this->attrs['searchUrl'] || self::getElementAttribute($form_name, 'searchUrl');
|
||||
|
||||
$ok = true;
|
||||
if (!$this->is_readonly($cname, $form_name))
|
||||
|
@ -54,7 +54,7 @@ class Tabbox extends Etemplate\Widget
|
||||
$form_name = self::form_name($params[0], $this->id, $params[1]);
|
||||
|
||||
// Make sure additional tabs are processed for any method
|
||||
if(!($tabs =& self::getElementAttribute($form_name, 'extraTabs')))
|
||||
if(!($tabs =& self::setElementAttribute($form_name, 'extraTabs')))
|
||||
{
|
||||
$tabs = $this->attrs['extraTabs'];
|
||||
}
|
||||
@ -231,7 +231,7 @@ class Tabbox extends Etemplate\Widget
|
||||
}
|
||||
}
|
||||
// filter out previously added custom-field tabs, as they might change due to cfTypeFilter
|
||||
if (($extra_tabs =& self::getElementAttribute($this->id, 'extraTabs')))
|
||||
if (($extra_tabs =& self::setElementAttribute($this->id, 'extraTabs')))
|
||||
{
|
||||
$extra_tabs = array_filter($extra_tabs, static function($tab)
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
$content = array();
|
||||
$etemplate->read('calendar.planner');
|
||||
$etemplate->set_dom_id($id);
|
||||
$this->actions =& $etemplate->getElementAttribute('planner', 'actions');
|
||||
$this->actions =& $etemplate->setElementAttribute('planner', 'actions');
|
||||
// Don't notify the calendar app of date changes
|
||||
$etemplate->setElementAttribute('planner','onchange',false);
|
||||
$ui->planner_view = $this->favorite['state']['planner_view'];
|
||||
@ -120,7 +120,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
case 'weekN':
|
||||
$etemplate->read('calendar.view');
|
||||
$etemplate->set_dom_id($id);
|
||||
$this->actions =& $etemplate->getElementAttribute('view', 'actions');
|
||||
$this->actions =& $etemplate->setElementAttribute('view', 'actions');
|
||||
|
||||
$ui->month($this->favorite['state']['view'] == 'month' ?
|
||||
0 :
|
||||
@ -131,7 +131,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
case 'week':
|
||||
$etemplate->read('calendar.view');
|
||||
$etemplate->set_dom_id($id);
|
||||
$this->actions =& $etemplate->getElementAttribute('view', 'actions');
|
||||
$this->actions =& $etemplate->setElementAttribute('view', 'actions');
|
||||
// Don't notify the calendar app of date changes
|
||||
$etemplate->setElementAttribute('view[0]','onchange',false);
|
||||
$ui->week(array(), $etemplate);
|
||||
@ -143,7 +143,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
$days = $this->favorite['state']['days'] ? $this->favorite['state']['days'] : (
|
||||
$this->favorite['state']['view'] == 'day' ? 1 : 4
|
||||
);
|
||||
$this->actions =& $etemplate->getElementAttribute('view', 'actions');
|
||||
$this->actions =& $etemplate->setElementAttribute('view', 'actions');
|
||||
$ui->week($days, $etemplate);
|
||||
return;
|
||||
}
|
||||
|
@ -1623,7 +1623,7 @@ class filemanager_ui
|
||||
// add to existing tabs in template
|
||||
$tpl->setElementAttribute('tabs', 'add_tabs', true);
|
||||
|
||||
$tabs =& $tpl->getElementAttribute('tabs', 'extraTabs');
|
||||
$tabs =& $tpl->setElementAttribute('tabs', 'extraTabs');
|
||||
if (true) $tabs = array();
|
||||
|
||||
foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
|
||||
|
@ -41,7 +41,7 @@ class importexport_widget_filter extends Etemplate\Widget\Transformer
|
||||
public function beforeSendToClient($cname, Array $expand = Array())
|
||||
{
|
||||
$form_name = self::form_name($cname, $this->id);
|
||||
if($this->getElementAttribute($form_name, 'customfields'))
|
||||
if(self::getElementAttribute($form_name, 'customfields'))
|
||||
{
|
||||
// Already done? Still need to process, or sel_options may be missing
|
||||
unset(self::$request->modifications[$form_name]);
|
||||
|
Loading…
Reference in New Issue
Block a user