mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
Better fix for some widgets not being properly initialized (that doesn't break others)
This commit is contained in:
parent
865151f977
commit
bcd52bb375
@ -295,12 +295,20 @@ class etemplate_widget
|
||||
if (!isset($class_name))
|
||||
{
|
||||
list($basetype) = explode('-',$type);
|
||||
$class_name = self::$widget_registry[$basetype];
|
||||
if (!$class_name && !(class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$basetype)) ||
|
||||
class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$type))))
|
||||
if (!class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$type)) &&
|
||||
!class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$basetype)))
|
||||
{
|
||||
// default to widget class, we can not ignore it, as the widget may contain other widgets
|
||||
// Try for base type, it's probably better than the root
|
||||
if(self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name)
|
||||
{
|
||||
$class_name = self::$widget_registry[$basetype];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fall back to widget class, we can not ignore it, as the widget may contain other widgets
|
||||
$class_name = 'etemplate_widget';
|
||||
//trigger_error("Could not find a class for $type, using $class_name", E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,3 +59,4 @@ class etemplate_widget_button extends etemplate_widget
|
||||
}
|
||||
}
|
||||
}
|
||||
etemplate_widget::registerWidget('etemplate_widget_button', array('button','buttononly'));
|
||||
|
@ -209,6 +209,7 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
|
||||
// Re-format date custom fields from Y-m-d
|
||||
$field_settings =& self::get_array(self::$request->modifications, "{$this->id}[customfields]",true);
|
||||
$field_settings = array();
|
||||
$link_types = egw_link::app_list();
|
||||
foreach($fields as $fname => $field)
|
||||
{
|
||||
if($field['type'] == 'date' && ($d_val = self::$request->content[self::$prefix.$fname]) && !is_numeric($d_val))
|
||||
@ -217,11 +218,21 @@ class etemplate_widget_customfields extends etemplate_widget_transformer
|
||||
}
|
||||
|
||||
// Run beforeSendToClient for each field
|
||||
$widget = self::factory($field['type'], '<'.$field['type'].' type="'.$field['type'].'" id="'.self::$prefix.$fname.'"/>', self::$prefix.$fname);
|
||||
$type = $field['type'];
|
||||
// Link-tos needs to change from appname to link-to
|
||||
if($link_types[$field['type']])
|
||||
{
|
||||
$type = 'link-to';
|
||||
}
|
||||
$widget = self::factory($type, '<'.$type.' type="'.$type.'" id="'.self::$prefix.$fname.'"/>', self::$prefix.$fname);
|
||||
if(method_exists($widget, 'beforeSendToClient'))
|
||||
{
|
||||
$widget->id = self::$prefix.$fname;
|
||||
$widget->attrs['type'] = $field['type'];
|
||||
$widget->attrs['type'] = $type;
|
||||
if($type == 'link-to')
|
||||
{
|
||||
$widget->attrs['only_app'] = $field['type'];
|
||||
}
|
||||
$widget->beforeSendToClient($this->id == self::GLOBAL_ID ? '':$this->id, $fname);
|
||||
}
|
||||
}
|
||||
|
@ -57,10 +57,10 @@ class etemplate_widget_link extends etemplate_widget
|
||||
$form_name = self::form_name($cname, $this->id);
|
||||
$value =& self::get_array(self::$request->content, $form_name, true);
|
||||
|
||||
if($value && !is_array($value))
|
||||
if($value && !is_array($value) && !$this->attrs['only_app'])
|
||||
{
|
||||
// Try to explode
|
||||
if(!is_array(explode(':',$value))) {
|
||||
if(count(explode(':',$value)) < 2) {
|
||||
throw new egw_exception_wrong_parameter("Wrong value sent to link widget, needs to be an array. ".array2string($value));
|
||||
}
|
||||
list($app, $id) = explode(':', $value,2);
|
||||
@ -71,13 +71,13 @@ class etemplate_widget_link extends etemplate_widget
|
||||
return;
|
||||
}
|
||||
|
||||
$app = $value['to_app'];
|
||||
$id = $value['to_id'];
|
||||
|
||||
// ToDo: implement on client-side
|
||||
if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application');
|
||||
|
||||
if($attrs['type'] == 'link-list') {
|
||||
$app = $value['to_app'];
|
||||
$id = $value['to_id'];
|
||||
$links = egw_link::get_links($app,$id,'','link_lastmod DESC',true, $value['show_deleted']);
|
||||
foreach($links as $link) {
|
||||
$value[] = $link;
|
||||
|
@ -654,4 +654,4 @@ class etemplate_widget_menupopup extends etemplate_widget
|
||||
}
|
||||
}
|
||||
|
||||
etemplate_widget::registerWidget('etemplate_widget_menupopup', array('selectbox','listbox','select'));
|
||||
etemplate_widget::registerWidget('etemplate_widget_menupopup', array('selectbox','listbox','select','menulist','menupopup'));
|
||||
|
@ -154,4 +154,4 @@ class etemplate_widget_textbox extends etemplate_widget
|
||||
}
|
||||
}
|
||||
}
|
||||
etemplate_widget::registerWidget('etemplate_widget_textbox', array('textbox','int','integer','float','passwd','hidden','colorpicker'));
|
||||
etemplate_widget::registerWidget('etemplate_widget_textbox', array('textbox','text','int','integer','float','passwd','hidden','colorpicker'));
|
||||
|
Loading…
Reference in New Issue
Block a user