Check variable existance and type to avoid some warnings

This commit is contained in:
Nathan Gray 2012-06-19 19:52:07 +00:00
parent 60ad22de68
commit cd6ff18379
2 changed files with 28 additions and 19 deletions

View File

@ -29,27 +29,30 @@ class etemplate_widget_historylog extends etemplate_widget
{
$form_name = self::form_name($cname, $this->id);
foreach(self::$request->content[$form_name]['status-widgets'] as $key => $type)
if(is_array(self::$request->content[$form_name]['status-widgets']))
{
if(!is_array($type))
foreach(self::$request->content[$form_name]['status-widgets'] as $key => $type)
{
list($basetype) = explode('-',$type);
$widget = @self::factory($basetype, '<?xml version="1.0"?><'.$type.' type="'.$type.'"/>', $key);
$widget->id = $key;
$widget->attrs['type'] = $type;
$widget->type = $type;
if(method_exists($widget, 'beforeSendToClient'))
if(!is_array($type))
{
$widget->beforeSendToClient($cname);
list($basetype) = explode('-',$type);
$widget = @self::factory($basetype, '<?xml version="1.0"?><'.$type.' type="'.$type.'"/>', $key);
$widget->id = $key;
$widget->attrs['type'] = $type;
$widget->type = $type;
if(method_exists($widget, 'beforeSendToClient'))
{
$widget->beforeSendToClient($cname);
}
}
else
{
if (!is_array(self::$request->sel_options[$key])) self::$request->sel_options[$key] = array();
self::$request->sel_options[$key] += $type;
}
}
else
{
if (!is_array(self::$request->sel_options[$key])) self::$request->sel_options[$key] = array();
self::$request->sel_options[$key] += $type;
}
}
}
}

View File

@ -376,10 +376,16 @@ class etemplate_widget_menupopup extends etemplate_widget
}
// Make sure all values are present, even if not normally sent (according to preferences)
$remaining = array_diff_key($value, $options);
foreach($remaining as $id)
if(is_array($value))
{
$options[$id] = !$id && !is_numeric($rows) ? lang($rows) : self::accountInfo($id,null,$type2,$type=='both');
$remaining = array_diff_key($value, $options);
}
if(is_array($remaining))
{
foreach($remaining as $id)
{
$options[$id] = !$id && !is_numeric($rows) ? lang($rows) : self::accountInfo($id,null,$type2,$type=='both');
}
}
break;