This now allows the _debug_array() to either print or not print the debug info.

This commit is contained in:
skeeter 2002-04-06 15:13:51 +00:00
parent 927cb82b09
commit 92c0505fe3
3 changed files with 42 additions and 22 deletions

View File

@ -1263,7 +1263,7 @@ class boicalendar
} }
else else
{ {
$this->debug("Setting ".$type." = "._debug_array($value)); $this->debug("Setting ".$type." = "._debug_array($value,False));
} }
} }
@ -1411,7 +1411,7 @@ class boicalendar
} }
elseif(ereg('(.*(\:\\\\)?.*):(.*)',$value,$temp)) elseif(ereg('(.*(\:\\\\)?.*):(.*)',$value,$temp))
{ {
$this->debug('Value : '._debug_array($temp)); $this->debug('Value : '._debug_array($temp,False));
$this->debug('Param '.$majortype.' Value : '.$temp[3]); $this->debug('Param '.$majortype.' Value : '.$temp[3]);
if($temp[3]) if($temp[3])
{ {
@ -1423,7 +1423,7 @@ class boicalendar
} }
while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp)) while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp))
{ {
$this->debug('Value : '._debug_array($temp)); $this->debug('Value : '._debug_array($temp,False));
$this->debug('Param '.$temp[2].' Value : '.$temp[3]); $this->debug('Param '.$temp[2].' Value : '.$temp[3]);
$return_value[] = Array( $return_value[] = Array(
'param' => $temp[2], 'param' => $temp[2],
@ -1438,7 +1438,7 @@ class boicalendar
{ {
while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp)) while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp))
{ {
$this->debug('Value : '._debug_array($temp)); $this->debug('Value : '._debug_array($temp,False));
$this->debug('Param '.$temp[2].' Value : '.$temp[3]); $this->debug('Param '.$temp[2].' Value : '.$temp[3]);
$return_value[] = Array( $return_value[] = Array(
'param' => $temp[2], 'param' => $temp[2],
@ -1512,7 +1512,7 @@ class boicalendar
{ {
$this->set_var($event[$majortype],$param,$value); $this->set_var($event[$majortype],$param,$value);
} }
$this->debug('Event : '._debug_array($event)); $this->debug('Event : '._debug_array($event,False));
break; break;
} }
} }
@ -1526,7 +1526,7 @@ class boicalendar
$this->parse_parameters($var,$majortype,$value); $this->parse_parameters($var,$majortype,$value);
if($this->property[$majortype][$mode]['multiples']) if($this->property[$majortype][$mode]['multiples'])
{ {
$this->debug(_debug_array($var)); $this->debug(_debug_array($var,False));
$event[$majortype][] = $var; $event[$majortype][] = $var;
} }
else else
@ -1543,7 +1543,7 @@ class boicalendar
{ {
$var[$key] = $val; $var[$key] = $val;
} }
$this->debug($majortype.' : '._debug_array($var)); $this->debug($majortype.' : '._debug_array($var,False));
} }
$this->set_var($event,$majortype,$var); $this->set_var($event,$majortype,$var);
} }
@ -2065,7 +2065,7 @@ class boicalendar
} }
} }
} }
$this->debug('DATETIME : '._debug_array($dtime)); $this->debug('DATETIME : '._debug_array($dtime,False));
return $dtime; return $dtime;
} }
elseif(is_array($var)) elseif(is_array($var))

View File

@ -623,7 +623,7 @@
} }
/* Just a wrapper to my new print_r() function I added to the php3 support file. Seek3r */ /* Just a wrapper to my new print_r() function I added to the php3 support file. Seek3r */
function _debug_array($array) function _debug_array($array,$print=True)
{ {
$four = False; $four = False;
if(@floor(phpversion()) == 4) if(@floor(phpversion()) == 4)
@ -632,12 +632,23 @@
} }
if($four) if($four)
{ {
echo '<pre>'; if(!$print)
}
print_r($array);
if($four)
{ {
ob_start();
}
echo '<pre>';
print_r($array);
echo '</pre>'; echo '</pre>';
if(!$print)
{
$v = ob_get_contents();
ob_end_clean();
return $v;
}
}
else
{
return print_r($array,False,$print);
} }
} }

View File

@ -275,31 +275,40 @@
} }
} }
function print_r($array,$recursed=False) function print_r($array,$recursed=False,$print=True)
{ {
$str = '';
if(is_array($array) || is_object($array)) if(is_array($array) || is_object($array))
{ {
if(!$recursed) if(!$recursed)
{ {
echo '<p>'; $str .= '<p>';
} }
echo ucfirst(gettype($array)) . '(<ul>'; $str .= ucfirst(gettype($array)) . '(<ul>';
while(list($index, $subarray) = each($array) ) while(list($index, $subarray) = each($array) )
{ {
echo '<li>'.$index.' <code>=&gt;&nbsp;</code>'; $str .= '<li>'.$index.' <code>=&gt;&nbsp;</code>';
print_r($subarray,True); $str .= print_r($subarray,True,$print);
echo '</li>'; $str .= '</li>';
} }
echo '</ul>)'; $str .= '</ul>)';
} }
elseif(is_string($array)) elseif(is_string($array))
{ {
echo ucfirst(gettype($array)) . '("' . $array . '")'; $str .= ucfirst(gettype($array)) . '("' . $array . '")';
} }
else else
{ {
echo gettype($array) . '(' . $array . ')'; $str .= gettype($array) . '(' . $array . ')';
}
if($print)
{
echo $str;
}
else
{
return $str;
} }
} }