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

@ -150,7 +150,7 @@ class etemplate_widget
* This is necessary as templates can be used multiple time, so we can not alter the cached template!
*
* @param string|XMLReader $xml
* @param boolean $cloned=true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object
* @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object
* @return etemplate_widget_template current object or clone, if any attribute was set
*/
public function set_attrs($xml, $cloned=true)
@ -221,9 +221,9 @@ class etemplate_widget
* - csv_split('"a""b,c",d') === array('a"b,c','d') // to escape enclosures double them!
*
* @param string $str
* @param int $num=null in how many parts to split maximal, parts over this number end up (unseparated) in the last part
* @param string $delimiter=','
* @param string $enclosure='"'
* @param int $num =null in how many parts to split maximal, parts over this number end up (unseparated) in the last part
* @param string $delimiter =','
* @param string $enclosure ='"'
* @return array
*/
public static function csv_split($str,$num=null,$delimiter=',',$enclosure='"')
@ -246,14 +246,14 @@ class etemplate_widget
$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 = array_slice($parts,0,$num);
$parts_renum[$num-1] = implode($delimiter,array_slice($parts_renum,$num-1,count($parts_renum)-$num+1));
$parts_renum = array_slice($parts_renum,0,$num);
}
return $parts;
return $parts_renum;
}
/**
@ -289,7 +289,7 @@ class etemplate_widget
*
* @param string $type
* @param string|XMLReader $xml
* @param string $id=null
* @param string $id =null
*/
public static function factory($type, $xml, $id=null)
{
@ -344,7 +344,7 @@ class etemplate_widget
* Iterate over children to find the one with the given id and optional type
*
* @param string $id
* @param string $type=null
* @param string $type =null
* @return etemplate_widget or NULL
*/
public function getElementById($id, $type=null)
@ -378,7 +378,7 @@ class etemplate_widget
{
$elements[] = $child;
}
$elements += $child->getElementsByType($type, $subclass_ok);
$elements += $child->getElementsByType($type);
}
return $elements;
}
@ -389,8 +389,8 @@ class etemplate_widget
* Default implementation only calls method on itself and run on all children
*
* @param string $method_name
* @param array $params=array('') parameter(s) first parameter has to be the cname, second $expand!
* @param boolean $respect_disabled=false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
* @param array $params =array('') parameter(s) first parameter has to be the cname, second $expand!
* @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
*/
public function run($method_name, $params=array(''), $respect_disabled=false)
{
@ -471,15 +471,15 @@ class etemplate_widget
*/
protected static function check_disabled($disabled, array $expand)
{
if ($not = $disabled[0] == '!')
if (($not = $disabled[0] == '!'))
{
$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 $
$val = self::expand_name($val,$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']);
$val = self::expand_name($value, $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);
if ($not) $result = !$result;
@ -532,13 +532,14 @@ class etemplate_widget
$cont = array();
}
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);
$row_cont = $cont[$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
// 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 ")
@ -644,7 +645,7 @@ class etemplate_widget
/**
* Convert widget (incl. children) to xml
*
* @param string $indent=''
* @param string $indent =''
* @return string
*/
public function toXml($indent='')
@ -685,7 +686,7 @@ class etemplate_widget
*
* @param string $cname basename
* @param string $name name
* @param array $expand=null values for keys 'c', 'row', 'c_', 'row_', 'cont'
* @param array $expand =null values for keys 'c', 'row', 'c_', 'row_', 'cont'
* @return string complete form-name
*/
static function form_name($cname,$name,array $expand=null)
@ -719,21 +720,21 @@ class etemplate_widget
* $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 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 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
*/
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))
{
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
$idx = str_replace(array('[',']'),array('[',']'),$idx);
$idx = str_replace(array('[',']'), array('[',']'), $_idx);
// Handle things expecting arrays - ends in []
if(substr($idx,-2) == "[]")
@ -765,8 +766,8 @@ class etemplate_widget
* - $readonlys[__ALL__] set and $readonlys[$form_name] !== false
* - $readonlys[$form_name] evaluates to true
*
* @param string $cname=''
* @param string $form_name=null form_name, to not calculate him again
* @param string $cname =''
* @param string $form_name =null form_name, to not calculate him again
* @return boolean
*/
public function is_readonly($cname='', $form_name=null)
@ -801,7 +802,7 @@ class etemplate_widget
*
* @param string $name (complete) name of the widget causing the error
* @param string|boolean $error error-message already translated or false to reset all existing error for given name
* @param string $cname=null set it to '', if the name is already a form-name, defaults to self::$name_vars
* @param string $cname =null set it to '', if the name is already a form-name, defaults to self::$name_vars
*/
public static function set_validation_error($name,$error,$cname=null)
{
@ -827,8 +828,8 @@ class etemplate_widget
/**
* Check if we have not ignored validation errors
*
* @param string $ignore_validation='' if not empty regular expression for validation-errors to ignore
* @param string $cname=null name-prefix, which need to be ignored, default self::$name_vars
* @param string $ignore_validation ='' if not empty regular expression for validation-errors to ignore
* @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars
* @return boolean true if there are not ignored validation errors, false otherwise
*/
public static function validation_errors($ignore_validation='',$cname='')
@ -837,7 +838,7 @@ class etemplate_widget
//echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors);
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);
@ -907,7 +908,7 @@ class etemplate_widget
* disables all cells with name == $name
*
* @param sting $name cell-name
* @param boolean $disabled=true disable or enable a cell, default true=disable
* @param boolean $disabled =true disable or enable a cell, default true=disable
* @return reference to attribute
*/
public function disableElement($name,$disabled=True)
@ -939,8 +940,8 @@ class etemplate_widget_box extends etemplate_widget
* Reimplemented because grids and boxes can have an own namespace
*
* @param string $method_name
* @param array $params=array('') parameter(s) first parameter has to be cname!
* @param boolean $respect_disabled=false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
* @param array $params =array('') parameter(s) first parameter has to be cname!
* @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
*/
public function run($method_name, $params=array(''), $respect_disabled=false)
{
@ -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)))
{
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;
}
if (method_exists($this, $method_name))
@ -966,6 +967,7 @@ class etemplate_widget_box extends etemplate_widget
}
// Expand children
$columns_disabled = null;
for($n = 0; ; ++$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)
{
$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_' ||
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!)
{
//error_log(__METHOD__."($widget,$cname) $this autorepeating row $expand[row] because of $check_widget->id = '$fname' is ".array2string($value));
unset($value);
return true;
}
}