quiten permanent error_log on disabled cells and fixed IDE warnings

This commit is contained in:
Ralf Becker 2014-11-19 08:53:17 +00:00
parent b626fd1a88
commit b10cf0a295

View File

@ -246,14 +246,14 @@ class etemplate_widget
$part = substr(str_replace($enclosure.$enclosure,$enclosure,$part),1,-1); $part = substr(str_replace($enclosure.$enclosure,$enclosure,$part),1,-1);
} }
} }
$parts = array_values($parts); // renumber the parts (in case we had to concat them) $parts_renum = array_values($parts); // renumber the parts (in case we had to concat them)
if ($num > 0 && count($parts) > $num) if ($num > 0 && count($parts_renum) > $num)
{ {
$parts[$num-1] = implode($delimiter,array_slice($parts,$num-1,count($parts)-$num+1)); $parts_renum[$num-1] = implode($delimiter,array_slice($parts_renum,$num-1,count($parts_renum)-$num+1));
$parts = array_slice($parts,0,$num); $parts_renum = array_slice($parts_renum,0,$num);
} }
return $parts; return $parts_renum;
} }
/** /**
@ -378,7 +378,7 @@ class etemplate_widget
{ {
$elements[] = $child; $elements[] = $child;
} }
$elements += $child->getElementsByType($type, $subclass_ok); $elements += $child->getElementsByType($type);
} }
return $elements; return $elements;
} }
@ -471,15 +471,15 @@ class etemplate_widget
*/ */
protected static function check_disabled($disabled, array $expand) protected static function check_disabled($disabled, array $expand)
{ {
if ($not = $disabled[0] == '!') if (($not = $disabled[0] == '!'))
{ {
$disabled = substr($disabled,1); $disabled = substr($disabled,1);
} }
list($val,$check_val) = $vals = explode('=',$disabled); list($value,$check) = $vals = explode('=',$disabled);
// use expand_name to be able to use @ or $ // use expand_name to be able to use @ or $
$val = self::expand_name($val,$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); $val = self::expand_name($value, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
$check_val = self::expand_name($check_val,$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); $check_val = self::expand_name($check, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
$result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val,$val) : $val == $check_val); $result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val,$val) : $val == $check_val);
if ($not) $result = !$result; if ($not) $result = !$result;
@ -532,13 +532,14 @@ class etemplate_widget
$cont = array(); $cont = array();
} }
if (!is_numeric($c)) $c = boetemplate::chrs2num($c); if (!is_numeric($c)) $c = boetemplate::chrs2num($c);
unset($row, $c_, $row_); // not used, but required by function signature
/* RB: dont think any of this is needed in eTemplate2, as this escaping probably needs to be done on clientside anyway
$col = self::num2chrs($c-1); // $c-1 to get: 0:'@', 1:'A', ... $col = self::num2chrs($c-1); // $c-1 to get: 0:'@', 1:'A', ...
$col_ = self::num2chrs($c_-1); $col_ = self::num2chrs($c_-1);
$row_cont = $cont[$row]; $row_cont = $cont[$row];
$col_row_cont = $cont[$col.$row]; $col_row_cont = $cont[$col.$row];
/* RB: dont think any of this is needed in eTemplate2, as this escaping probably needs to be done on clientside anyway
// check if name is enclosed in single quotes as argument eg. to an event handler or // check if name is enclosed in single quotes as argument eg. to an event handler or
// variable name is contained in quotes and curly brackets, eg. "'{$cont[nm][path]}'" or // variable name is contained in quotes and curly brackets, eg. "'{$cont[nm][path]}'" or
// used as name for a button like "delete[$row_cont[something]]" --> quote contained quotes (' or ") // used as name for a button like "delete[$row_cont[something]]" --> quote contained quotes (' or ")
@ -719,21 +720,21 @@ class etemplate_widget
* $sub = get_array($arr,'a[b]'); $sub = 'c'; is equivalent to $arr['a']['b'] = 'c'; * $sub = get_array($arr,'a[b]'); $sub = 'c'; is equivalent to $arr['a']['b'] = 'c';
* *
* @param array $arr the array to search, referenz as a referenz gets returned * @param array $arr the array to search, referenz as a referenz gets returned
* @param string $idx the index, may contain sub-indices like a[b], see example below * @param string $_idx the index, may contain sub-indices like a[b], see example below
* @param boolean $reference_into default False, if True none-existing sub-arrays/-indices get created to be returned as referenz, else False is returned * @param boolean $reference_into default False, if True none-existing sub-arrays/-indices get created to be returned as referenz, else False is returned
* @param bool $skip_empty returns false if $idx is not present in $arr * @param bool $skip_empty returns false if $idx is not present in $arr
* @return mixed reference to $arr[$idx] or null if $idx is not set and not $reference_into * @return mixed reference to $arr[$idx] or null if $idx is not set and not $reference_into
*/ */
static function &get_array(&$arr,$idx,$reference_into=False,$skip_empty=False) static function &get_array(&$arr,$_idx,$reference_into=False,$skip_empty=False)
{ {
if (!is_array($arr)) if (!is_array($arr))
{ {
throw new egw_exception_assertion_failed(__METHOD__."(\$arr,'$idx',$reference_into,$skip_empty) \$arr is no array!"); throw new egw_exception_assertion_failed(__METHOD__."(\$arr,'$_idx',$reference_into,$skip_empty) \$arr is no array!");
} }
if (is_object($idx)) return false; // given an error in php5.2 if (is_object($_idx)) return false; // given an error in php5.2
// Make sure none of these are left // Make sure none of these are left
$idx = str_replace(array('[',']'),array('[',']'),$idx); $idx = str_replace(array('[',']'), array('[',']'), $_idx);
// Handle things expecting arrays - ends in [] // Handle things expecting arrays - ends in []
if(substr($idx,-2) == "[]") if(substr($idx,-2) == "[]")
@ -837,7 +838,7 @@ class etemplate_widget
//echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors); //echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors);
if (!$ignore_validation) return count(self::$validation_errors) > 0; if (!$ignore_validation) return count(self::$validation_errors) > 0;
foreach(self::$validation_errors as $name => $error) foreach(array_values(self::$validation_errors) as $name)
{ {
if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name); if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name);
@ -957,7 +958,7 @@ class etemplate_widget_box extends etemplate_widget
} }
if ($respect_disabled && ($disabled = $this->attrs['disabled'] && self::check_disabled($this->attrs['disabled'], $expand))) if ($respect_disabled && ($disabled = $this->attrs['disabled'] && self::check_disabled($this->attrs['disabled'], $expand)))
{ {
error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running"); //error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running");
return; return;
} }
if (method_exists($this, $method_name)) if (method_exists($this, $method_name))
@ -966,6 +967,7 @@ class etemplate_widget_box extends etemplate_widget
} }
// Expand children // Expand children
$columns_disabled = null;
for($n = 0; ; ++$n) for($n = 0; ; ++$n)
{ {
if (isset($this->children[$n])) if (isset($this->children[$n]))
@ -1008,9 +1010,9 @@ class etemplate_widget_box extends etemplate_widget
foreach(array($widget) + $widget->children as $check_widget) foreach(array($widget) + $widget->children as $check_widget)
{ {
$pat = $check_widget->id; $pat = $check_widget->id;
while(($pat = strstr($pat, '$'))) while(($pattern = strstr($pat, '$')))
{ {
$pat = substr($pat,$pat[1] == '{' ? 2 : 1); $pat = substr($pattern,$pattern[1] == '{' ? 2 : 1);
$Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' || $Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' ||
substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont'); substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont');
@ -1022,6 +1024,7 @@ class etemplate_widget_box extends etemplate_widget
($value = self::get_array(self::$request->content, $fname)) !== null) // null = not found (can be false!) ($value = self::get_array(self::$request->content, $fname)) !== null) // null = not found (can be false!)
{ {
//error_log(__METHOD__."($widget,$cname) $this autorepeating row $expand[row] because of $check_widget->id = '$fname' is ".array2string($value)); //error_log(__METHOD__."($widget,$cname) $this autorepeating row $expand[row] because of $check_widget->id = '$fname' is ".array2string($value));
unset($value);
return true; return true;
} }
} }