From 9c59fee929c0801df6d5bc6908b57f055a7ed359 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 1 Jul 2011 08:06:36 +0200 Subject: [PATCH] updated examples & Debugger --- examples/Nette/Debugger.php | 257 ++++++++++++++++----- examples/connecting-to-databases.php | 4 +- examples/data/style.css | 29 ++- examples/database-reflection.php | 2 +- examples/dumping-sql-and-result-set.php | 2 +- examples/fetching-examples.php | 20 +- examples/importing-dump-from-file.php | 4 +- examples/query-language-and-conditions.php | 2 +- examples/query-language-basic-examples.php | 2 +- examples/result-set-data-types.php | 6 +- examples/using-datetime.php | 2 +- examples/using-extension-methods.php | 4 +- examples/using-fluent-syntax.php | 2 +- examples/using-limit-and-offset.php | 2 +- examples/using-logger.php | 2 +- examples/using-profiler.php | 4 +- examples/using-substitutions.php | 2 +- examples/using-transactions.php | 2 +- 18 files changed, 249 insertions(+), 99 deletions(-) diff --git a/examples/Nette/Debugger.php b/examples/Nette/Debugger.php index 1872014..9f40af1 100644 --- a/examples/Nette/Debugger.php +++ b/examples/Nette/Debugger.php @@ -11,7 +11,7 @@ * @package Nette\Diagnostics */ -interface +define('NETTE_DIR',dirname(__FILE__));interface IBarPanel{function getTab();function getPanel();}class @@ -29,7 +29,7 @@ as$id=>$panel){try{$panels[]=array('id'=>preg_replace('#[^a-z0-9]+#i','-',$id),'   - + @@ -111,7 +111,7 @@ DebugBlueScreen{private$panels=array();public function addPanel($panel,$id=NULL){if($id===NULL){$this->panels[]=$panel;}else{$this->panels[$id]=$panel;}}public function -render(Exception$exception){if(class_exists('Environment',FALSE)){$application=Environment::getContext()->hasService('Nette\\Application\\Application',TRUE)?Environment::getContext()->getService('Nette\\Application\\Application'):NULL;}$panels=$this->panels;static$errorTypes=array(E_ERROR=>'Fatal Error',E_USER_ERROR=>'User Error',E_RECOVERABLE_ERROR=>'Recoverable Error',E_CORE_ERROR=>'Core Error',E_COMPILE_ERROR=>'Compile Error',E_PARSE=>'Parse Error',E_WARNING=>'Warning',E_CORE_WARNING=>'Core Warning',E_COMPILE_WARNING=>'Compile Warning',E_USER_WARNING=>'User Warning',E_NOTICE=>'Notice',E_USER_NOTICE=>'User Notice',E_STRICT=>'Strict',E_DEPRECATED=>'Deprecated',E_USER_DEPRECATED=>'User Deprecated');$title=($exception +render(Exception$exception){$panels=$this->panels;static$errorTypes=array(E_ERROR=>'Fatal Error',E_USER_ERROR=>'User Error',E_RECOVERABLE_ERROR=>'Recoverable Error',E_CORE_ERROR=>'Core Error',E_COMPILE_ERROR=>'Compile Error',E_PARSE=>'Parse Error',E_WARNING=>'Warning',E_CORE_WARNING=>'Core Warning',E_COMPILE_WARNING=>'Compile Warning',E_USER_WARNING=>'User Warning',E_NOTICE=>'Notice',E_USER_NOTICE=>'User Notice',E_STRICT=>'Strict',E_DEPRECATED=>'Deprecated',E_USER_DEPRECATED=>'User Deprecated');$title=($exception instanceof FatalErrorException&&isset($errorTypes[$exception->getSeverity()]))?$errorTypes[$exception->getSeverity()]:get_class($exception);$expandPath=NETTE_DIR.DIRECTORY_SEPARATOR;$counter=0;?> @@ -125,7 +125,7 @@ FatalErrorException&&isset($errorTypes[$exception->getSeverity()]))?$errorTypes[ htmlspecialchars($title)?> - + @@ -182,18 +182,16 @@ htmlSpecialChars($panel['tab'])?> getTrace();$expanded=NULL?> getFile(),$expandPath)===0){foreach($stack as$key=>$row){if(isset($row['file'])&&strpos($row['file'],$expandPath)!==0){$expanded=$key;break;}}}?> - getFile())):?> +

Source file

-

File: getFile(),$ex->getLine())),'">'?> - getFile()),(Debugger::$editor?'':'')?>   Line: getLine()?>

-
getFile(),$ex->getLine())?>
+

File: getFile(),$ex->getLine())?>   Line: getLine()?>

+ getFile())):?>
getFile(),$ex->getLine(),15,isset($ex->context)?$ex->context:NULL)?>
- @@ -210,12 +208,9 @@ as$key=>$row):?> title=""> - ',htmlSpecialChars(basename($row['file'])),'',(Debugger::$editor?'':''),' (',$row['line'],')'?> +DebugHelpers::editorLink($row['file'],$row['line']),':',$row['line']?> - inner-code + inner-code ">source   @@ -274,20 +269,17 @@ as$k=>$v){echo'$',htmlspecialchars($k),'',DebugHelpers::clickab - + +
-

Nette Application

+

-

Requests

- getRequests())?> - -

Presenter

- getPresenter())?> +
- + @@ -412,11 +404,16 @@ for(var i=0,styles=document.styleSheets;i*/ - +',$source[1]);array_unshift($source,NULL);$i=$start;while(--$i>=1){if(preg_match('#.*(]*>)#',$source[$i],$m)){if($m[1]!==''){$spans++;$out.=$m[1];}break;}}$source=array_slice($source,$start,$count,TRUE);end($source);$numWidth=strlen((string)key($source));foreach($source -as$n=>$s){$spans+=substr_count($s,']+>#',$s,$tags);if($n===$line){$out.=sprintf("%{$numWidth}s: %s\n%s",$n,strip_tags($s),implode('',$tags[0]));}else{$out.=sprintf("%{$numWidth}s: %s\n",$n,$s);}}return$out.str_repeat('',$spans).'';}}final +highlightFile($file,$line,$count=15,$vars=array()){if(function_exists('ini_set')){ini_set('highlight.comment','#998; font-style: italic');ini_set('highlight.default','#000');ini_set('highlight.html','#06B');ini_set('highlight.keyword','#D24; font-weight: bold');ini_set('highlight.string','#080');}$start=max(1,$line-floor($count/2));$source=@file_get_contents($file);if(!$source){return;}$source=explode("\n",highlight_string($source,TRUE));$spans=1;$out=$source[0];$source=explode('
',$source[1]);array_unshift($source,NULL);$i=$start;while(--$i>=1){if(preg_match('#.*(]*>)#',$source[$i],$m)){if($m[1]!==''){$spans++;$out.=$m[1];}break;}}$source=array_slice($source,$start,$count,TRUE);end($source);$numWidth=strlen((string)key($source));foreach($source +as$n=>$s){$spans+=substr_count($s,']+>#',$s,$tags);if($n===$line){$out.=sprintf("%{$numWidth}s: %s\n%s",$n,strip_tags($s),implode('',$tags[0]));}else{$out.=sprintf("%{$numWidth}s: %s\n",$n,$s);}}$out.=str_repeat('',$spans).'';$out=preg_replace_callback('#">\$(\w+)( )?#',create_function('$m','extract(NClosureFix::$vars['.NClosureFix::uses(array('vars'=>$vars)).'], EXTR_REFS); + return isset($vars[$m[1]]) + ? \'" title="\' . str_replace(\'"\', \'"\', strip_tags(DebugHelpers::htmlDump($vars[$m[1]]))) . $m[0] + : $m[0]; + '),$out);return$out;}}final class DefaultBarPanel implements @@ -442,7 +439,7 @@ array_sum($data)?> errors ob_get_clean();}public function getPanel(){ob_start();$data=$this->data;if($this->id==='dumps'){?> - +

Dumped variables

@@ -471,8 +468,6 @@ htmlspecialchars($key)?> id==='errors'){?>

Errors

- -
@@ -482,11 +477,12 @@ as$item=>$count):list($message,$file,$line)=explode('|',$item)?> 2?'nette-alt':''?>"> +htmlspecialchars($message),' in ',DebugHelpers::editorLink($file,$line),':',$line?>
':''),htmlspecialchars(($relative?str_replace($relative,"...",$file):$file)),':',$line,(Debugger::$editor?'':'')?>
-
+'PHP','level'=>$priority,'order'=>count(self::$payload['logs']),'time'=>str_pad(number_format((microtime(TRUE)-Debugger::$time)*1000,1,'.',' '),8,'0',STR_PAD_LEFT).' ms','template'=>'','message'=>'','style'=>'background:#767ab6');$args=func_get_args();if(isset($args[0])&&is_string($args[0])){$item['template']=array_shift($args);}if(isset($args[0])&&$args[0]instanceof -Exception){$e=array_shift($args);$trace=$e->getTrace();if(isset($trace[0]['class'])&&$trace[0]['class']===__CLASS__&&($trace[0]['function']==='_shutdownHandler'||$trace[0]['function']==='_errorHandler')){unset($trace[0]);}$item['exc_info']=array($e->getMessage(),$e->getFile(),array());$item['exc_frames']=array();foreach($trace -as$frame){$frame+=array('file'=>NULL,'line'=>NULL,'class'=>NULL,'type'=>NULL,'function'=>NULL,'object'=>NULL,'args'=>NULL);$item['exc_info'][2][]=array($frame['file'],$frame['line'],"$frame[class]$frame[type]$frame[function]",$frame['object']);$item['exc_frames'][]=$frame['args'];}$file=str_replace(dirname(dirname(dirname($e->getFile()))),"\xE2\x80\xA6",$e->getFile());$item['template']=($e +Exception){$e=array_shift($args);$trace=$e->getTrace();if(isset($trace[0]['class'])&&$trace[0]['class']==='Debugger'&&($trace[0]['function']==='_shutdownHandler'||$trace[0]['function']==='_errorHandler')){unset($trace[0]);}$file=str_replace(dirname(dirname(dirname($e->getFile()))),"\xE2\x80\xA6",$e->getFile());$item['template']=($e instanceof -ErrorException?'':get_class($e).': ').$e->getMessage().($e->getCode()?' #'.$e->getCode():'').' in '.$file.':'.$e->getLine();array_unshift($trace,array('file'=>$e->getFile(),'line'=>$e->getLine()));}else{$trace=debug_backtrace();if(isset($trace[0]['class'])&&$trace[0]['class']===__CLASS__&&($trace[0]['function']==='_shutdownHandler'||$trace[0]['function']==='_errorHandler')){unset($trace[0]);}}if(isset($args[0])&&in_array($args[0],array(self::DEBUG,self::INFO,self::WARNING,self::ERROR,self::CRITICAL),TRUE)){$item['level']=array_shift($args);}$item['args']=$args;foreach($trace -as$frame){if(isset($frame['file'])&&is_file($frame['file'])){$item['pathname']=$frame['file'];$item['lineno']=$frame['line'];break;}}self::$payload['logs'][]=self::jsonDump($item,-1);foreach(str_split(base64_encode(@json_encode(self::$payload)),4990)as$k=>$v){header("FireLogger-de11e-$k:$v");}return +ErrorException?'':get_class($e).': ').$e->getMessage().($e->getCode()?' #'.$e->getCode():'').' in '.$file.':'.$e->getLine();$item['pathname']=$e->getFile();$item['lineno']=$e->getLine();}else{$trace=debug_backtrace();if(isset($trace[1]['class'])&&$trace[1]['class']==='Debugger'&&($trace[1]['function']==='fireLog')){unset($trace[0]);}foreach($trace +as$frame){if(isset($frame['file'])&&is_file($frame['file'])){$item['pathname']=$frame['file'];$item['lineno']=$frame['line'];break;}}}$item['exc_info']=array('','',array());$item['exc_frames']=array();foreach($trace +as$frame){$frame+=array('file'=>NULL,'line'=>NULL,'class'=>NULL,'type'=>NULL,'function'=>NULL,'object'=>NULL,'args'=>NULL);$item['exc_info'][2][]=array($frame['file'],$frame['line'],"$frame[class]$frame[type]$frame[function]",$frame['object']);$item['exc_frames'][]=$frame['args'];}if(isset($args[0])&&in_array($args[0],array(self::DEBUG,self::INFO,self::WARNING,self::ERROR,self::CRITICAL),TRUE)){$item['level']=array_shift($args);}$item['args']=$args;self::$payload['logs'][]=self::jsonDump($item,-1);foreach(str_split(base64_encode(@json_encode(self::$payload)),4990)as$k=>$v){header("FireLogger-de11e-$k:$v");}return TRUE;}private static function -jsonDump(&$var,$level=0){if(is_bool($var)||is_null($var)||is_int($var)||is_float($var)){return$var;}elseif(is_string($var)){if(Debugger::$maxLen&&strlen($var)>Debugger::$maxLen){$var=substr($var,0,Debugger::$maxLen)." \xE2\x80\xA6 ";}return@iconv('UTF-16','UTF-8//IGNORE',iconv('UTF-8','UTF-16//IGNORE',$var));}elseif(is_array($var)){static$marker;if($marker===NULL)$marker=uniqid("\x00",TRUE);if(isset($var[$marker])){return"\xE2\x80\xA6RECURSION\xE2\x80\xA6";}elseif($level&$v){if($k!==$marker)$res[self::jsonDump($k)]=self::jsonDump($v,$level+1);}unset($var[$marker]);return$res;}else{return" \xE2\x80\xA6 ";}}elseif(is_object($var)){$arr=(array)$var;static$list=array();if(in_array($var,$list,TRUE)){return"\xE2\x80\xA6RECURSION\xE2\x80\xA6";}elseif($level'(object) '.get_class($var));foreach($arr +jsonDump(&$var,$level=0){if(is_bool($var)||is_null($var)||is_int($var)||is_float($var)){return$var;}elseif(is_string($var)){if(Debugger::$maxLen&&strlen($var)>Debugger::$maxLen){$var=substr($var,0,Debugger::$maxLen)." \xE2\x80\xA6 ";}return@iconv('UTF-16','UTF-8//IGNORE',iconv('UTF-8','UTF-16//IGNORE',$var));}elseif(is_array($var)){static$marker;if($marker===NULL){$marker=uniqid("\x00",TRUE);}if(isset($var[$marker])){return"\xE2\x80\xA6RECURSION\xE2\x80\xA6";}elseif($level&$v){if($k!==$marker){$res[self::jsonDump($k)]=self::jsonDump($v,$level+1);}}unset($var[$marker]);return$res;}else{return" \xE2\x80\xA6 ";}}elseif(is_object($var)){$arr=(array)$var;static$list=array();if(in_array($var,$list,TRUE)){return"\xE2\x80\xA6RECURSION\xE2\x80\xA6";}elseif($level'(object) '.get_class($var));foreach($arr as$k=>&$v){if($k[0]==="\x00"){$k=substr($k,strrpos($k,"\x00")+1);}$res[self::jsonDump($k)]=self::jsonDump($v,$level+1);}array_pop($list);return$res;}else{return" \xE2\x80\xA6 ";}}elseif(is_resource($var)){return"resource ".get_resource_type($var);}else{return"unknown type";}}}final class DebugHelpers{public static function -editorLink($file,$line){return -strtr(Debugger::$editor,array('%file'=>rawurlencode($file),'%line'=>$line));}public +editorLink($file,$line){if(Debugger::$editor&&is_file($file)){$dir=dirname(strtr($file,'/',DIRECTORY_SEPARATOR));$base=isset($_SERVER['SCRIPT_FILENAME'])?dirname(dirname(strtr($_SERVER['SCRIPT_FILENAME'],'/',DIRECTORY_SEPARATOR))):dirname($dir);if(substr($dir,0,strlen($base))===$base){$dir='...'.substr($dir,strlen($base));}return +Html::el('a')->href(strtr(Debugger::$editor,array('%file'=>rawurlencode($file),'%line'=>$line)))->title("$file:$line")->setHtml(htmlSpecialChars(rtrim($dir,DIRECTORY_SEPARATOR)).DIRECTORY_SEPARATOR.''.htmlSpecialChars(basename($file)).'');}else{return +Html::el('span')->setText($file);}}public static function -htmlDump(&$var,$level=0){static$tableUtf,$tableBin,$reBinary='#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}]#u';if($tableUtf===NULL){foreach(range("\x00","\xFF")as$ch){if(ord($ch)<32&&strpos("\r\n\t",$ch)===FALSE){$tableUtf[$ch]=$tableBin[$ch]='\\x'.str_pad(dechex(ord($ch)),2,'0',STR_PAD_LEFT);}elseif(ord($ch)<127){$tableUtf[$ch]=$tableBin[$ch]=$ch;}else{$tableUtf[$ch]=$ch;$tableBin[$ch]='\\x'.dechex(ord($ch));}}$tableBin["\\"]='\\\\';$tableBin["\r"]='\\r';$tableBin["\n"]='\\n';$tableBin["\t"]='\\t';$tableUtf['\\x']=$tableBin['\\x']='\\\\x';}if(is_bool($var)){return($var?'TRUE':'FALSE')."\n";}elseif($var===NULL){return"NULL\n";}elseif(is_int($var)){return"$var\n";}elseif(is_float($var)){$var=var_export($var,TRUE);if(strpos($var,'.')===FALSE)$var.='.0';return"$var\n";}elseif(is_string($var)){if(Debugger::$maxLen&&strlen($var)>Debugger::$maxLen){$s=htmlSpecialChars(substr($var,0,Debugger::$maxLen),ENT_NOQUOTES).' ... ';}else{$s=htmlSpecialChars($var,ENT_NOQUOTES);}$s=strtr($s,preg_match($reBinary,$s)||preg_last_error()?$tableBin:$tableUtf);$len=strlen($var);return"\"$s\"".($len>1?" ($len)":"")."\n";}elseif(is_array($var)){$s="array(".count($var).") ";$space=str_repeat($space1=' ',$level);$brackets=range(0,count($var)-1)===array_keys($var)?"[]":"{}";static$marker;if($marker===NULL)$marker=uniqid("\x00",TRUE);if(empty($var)){}elseif(isset($var[$marker])){$brackets=$var[$marker];$s.="$brackets[0] *RECURSION* $brackets[1]";}elseif($level$brackets[0]\n";$var[$marker]=$brackets;foreach($var -as$k=>&$v){if($k===$marker)continue;$k=is_int($k)?$k:'"'.htmlSpecialChars(strtr($k,preg_match($reBinary,$k)||preg_last_error()?$tableBin:$tableUtf)).'"';$s.="$space$space1$k => ".self::htmlDump($v,$level+1);}unset($var[$marker]);$s.="$space$brackets[1]";}else{$s.="$brackets[0] ... $brackets[1]";}return$s."\n";}elseif(is_object($var)){$arr=(array)$var;$s="".get_class($var)."(".count($arr).") ";$space=str_repeat($space1=' ',$level);static$list=array();if(empty($arr)){}elseif(in_array($var,$list,TRUE)){$s.="{ *RECURSION* }";}elseif($level{\n";$list[]=$var;foreach($arr -as$k=>&$v){$m='';if($k[0]==="\x00"){$m=$k[1]==='*'?' protected':' private';$k=substr($k,strrpos($k,"\x00")+1);}$k=htmlSpecialChars(strtr($k,preg_match($reBinary,$k)||preg_last_error()?$tableBin:$tableUtf));$s.="$space$space1\"$k\"$m => ".self::htmlDump($v,$level+1);}array_pop($list);$s.="$space}";}else{$s.="{ ... }";}return$s."\n";}elseif(is_resource($var)){return"".htmlSpecialChars(get_resource_type($var))." resource\n";}else{return"unknown type\n";}}public +htmlDump(&$var,$level=0){static$tableUtf,$tableBin,$reBinary='#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}]#u';if($tableUtf===NULL){foreach(range("\x00","\xFF")as$ch){if(ord($ch)<32&&strpos("\r\n\t",$ch)===FALSE){$tableUtf[$ch]=$tableBin[$ch]='\\x'.str_pad(dechex(ord($ch)),2,'0',STR_PAD_LEFT);}elseif(ord($ch)<127){$tableUtf[$ch]=$tableBin[$ch]=$ch;}else{$tableUtf[$ch]=$ch;$tableBin[$ch]='\\x'.dechex(ord($ch));}}$tableBin["\\"]='\\\\';$tableBin["\r"]='\\r';$tableBin["\n"]='\\n';$tableBin["\t"]='\\t';$tableUtf['\\x']=$tableBin['\\x']='\\\\x';}if(is_bool($var)){return''.($var?'TRUE':'FALSE')."\n";}elseif($var===NULL){return"NULL\n";}elseif(is_int($var)){return"$var\n";}elseif(is_float($var)){$var=var_export($var,TRUE);if(strpos($var,'.')===FALSE){$var.='.0';}return"$var\n";}elseif(is_string($var)){if(Debugger::$maxLen&&strlen($var)>Debugger::$maxLen){$s=htmlSpecialChars(substr($var,0,Debugger::$maxLen),ENT_NOQUOTES).' ... ';}else{$s=htmlSpecialChars($var,ENT_NOQUOTES);}$s=strtr($s,preg_match($reBinary,$s)||preg_last_error()?$tableBin:$tableUtf);$len=strlen($var);return"\"$s\"".($len>1?" ($len)":"")."\n";}elseif(is_array($var)){$s='array('.count($var).") ";$space=str_repeat($space1=' ',$level);$brackets=range(0,count($var)-1)===array_keys($var)?"[]":"{}";static$marker;if($marker===NULL){$marker=uniqid("\x00",TRUE);}if(empty($var)){}elseif(isset($var[$marker])){$brackets=$var[$marker];$s.="$brackets[0] *RECURSION* $brackets[1]";}elseif($level$brackets[0]\n";$var[$marker]=$brackets;foreach($var +as$k=>&$v){if($k===$marker){continue;}$k=strtr($k,preg_match($reBinary,$k)||preg_last_error()?$tableBin:$tableUtf);$k=htmlSpecialChars(preg_match('#^\w+$#',$k)?$k:"\"$k\"");$s.="$space$space1$k => ".self::htmlDump($v,$level+1);}unset($var[$marker]);$s.="$space$brackets[1]";}else{$s.="$brackets[0] ... $brackets[1]";}return$s."\n";}elseif(is_object($var)){if($var +instanceof +Closure){$rc=new +ReflectionFunction($var);$arr=array();foreach($rc->getParameters()as$param){$arr[]='$'.$param->getName();}$arr=array('file'=>$rc->getFileName(),'line'=>$rc->getStartLine(),'parameters'=>implode(', ',$arr));}else{$arr=(array)$var;}$s=''.get_class($var)."(".count($arr).") ";$space=str_repeat($space1=' ',$level);static$list=array();if(empty($arr)){}elseif(in_array($var,$list,TRUE)){$s.="{ *RECURSION* }";}elseif($level&$v){$m='';if($k[0]==="\x00"){$m=' '.($k[1]==='*'?'protected':'private').'';$k=substr($k,strrpos($k,"\x00")+1);}$k=strtr($k,preg_match($reBinary,$k)||preg_last_error()?$tableBin:$tableUtf);$k=htmlSpecialChars(preg_match('#^\w+$#',$k)?$k:"\"$k\"");$s.="$space$space1$k$m => ".self::htmlDump($v,$level+1);}array_pop($list);$s.="$space}";}else{$s.="{ ... }";}return$s."\n";}elseif(is_resource($var)){return''.htmlSpecialChars(get_resource_type($var))." resource\n";}else{return"unknown type\n";}}public static function clickableDump($dump){return'
'.preg_replace_callback('#^( *)((?>[^(]{1,200}))\((\d+)\) #m',create_function('$m','
@@ -531,10 +533,128 @@ static$emailSnooze=172800;public$mailer=array(__CLASS__,'defaultMailer');public$
 function
 log($message,$priority=self::INFO){if(!is_dir($this->directory)){throw
 new
-DirectoryNotFoundException("Directory '$this->directory' is not found or is not directory.");}if(is_array($message)){$message=implode(' ',$message);}$res=error_log(trim($message).PHP_EOL,3,$this->directory.'/'.strtolower($priority).'.log');if(($priority===self::ERROR||$priority===self::CRITICAL)&&$this->email&&@filemtime($this->directory.'/email-sent')+self::$emailSnoozedirectory.'/email-sent','sent')){call_user_func($this->mailer,$message,$this->email);}return$res;}private
+DirectoryNotFoundException("Directory '$this->directory' is not found or is not directory.");}if(is_array($message)){$message=implode(' ',$message);}$res=error_log(trim($message).PHP_EOL,3,$this->directory.'/'.strtolower($priority).'.log');if(($priority===self::ERROR||$priority===self::CRITICAL)&&$this->email&&$this->mailer&&@filemtime($this->directory.'/email-sent')+self::$emailSnoozedirectory.'/email-sent','sent')){call_user_func($this->mailer,$message,$this->email);}return$res;}private
 static
 function
-defaultMailer($message,$email){$host=isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:(isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:'');$parts=str_replace(array("\r\n","\n"),array("\n",PHP_EOL),array('headers'=>"From: noreply@$host\nX-Mailer: Nette Framework\n",'subject'=>"PHP: An error occurred on the server $host",'body'=>"[".@date('Y-m-d H:i:s')."] $message"));mail($email,$parts['subject'],$parts['body'],$parts['headers']);}}final
+defaultMailer($message,$email){$host=isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:(isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:'');$parts=str_replace(array("\r\n","\n"),array("\n",PHP_EOL),array('headers'=>"From: noreply@$host\nX-Mailer: Nette Framework\n",'subject'=>"PHP: An error occurred on the server $host",'body'=>"[".@date('Y-m-d H:i:s')."] $message"));mail($email,$parts['subject'],$parts['body'],$parts['headers']);}}class
+Html
+implements
+ArrayAccess,Countable,IteratorAggregate{private$name;private$isEmpty;public$attrs=array();protected$children=array();public
+static$xhtml=TRUE;public
+static$emptyElements=array('img'=>1,'hr'=>1,'br'=>1,'input'=>1,'meta'=>1,'area'=>1,'embed'=>1,'keygen'=>1,'source'=>1,'base'=>1,'col'=>1,'link'=>1,'param'=>1,'basefont'=>1,'frame'=>1,'isindex'=>1,'wbr'=>1,'command'=>1);public
+static
+function
+el($name=NULL,$attrs=NULL){$el=new
+self;$parts=explode(' ',$name,2);$el->setName($parts[0]);if(is_array($attrs)){$el->attrs=$attrs;}elseif($attrs!==NULL){$el->setText($attrs);}if(isset($parts[1])){foreach(Strings::matchAll($parts[1].' ','#([a-z0-9:-]+)(?:=(["\'])?(.*?)(?(2)\\2|\s))?#i')as$m){$el->attrs[$m[1]]=isset($m[3])?$m[3]:TRUE;}}return$el;}final
+public
+function
+setName($name,$isEmpty=NULL){if($name!==NULL&&!is_string($name)){throw
+new
+InvalidArgumentException("Name must be string or NULL, ".gettype($name)." given.");}$this->name=$name;$this->isEmpty=$isEmpty===NULL?isset(self::$emptyElements[$name]):(bool)$isEmpty;return$this;}final
+public
+function
+getName(){return$this->name;}final
+public
+function
+isEmpty(){return$this->isEmpty;}public
+function
+addAttributes(array$attrs){$this->attrs=$attrs+$this->attrs;return$this;}final
+public
+function
+__set($name,$value){$this->attrs[$name]=$value;}final
+public
+function&__get($name){return$this->attrs[$name];}final
+public
+function
+__unset($name){unset($this->attrs[$name]);}final
+public
+function
+__call($m,$args){$p=substr($m,0,3);if($p==='get'||$p==='set'||$p==='add'){$m=substr($m,3);$m[0]=$m[0]|"\x20";if($p==='get'){return
+isset($this->attrs[$m])?$this->attrs[$m]:NULL;}elseif($p==='add'){$args[]=TRUE;}}if(count($args)===0){}elseif(count($args)===1){$this->attrs[$m]=$args[0];}elseif((string)$args[0]===''){$tmp=&$this->attrs[$m];}elseif(!isset($this->attrs[$m])||is_array($this->attrs[$m])){$this->attrs[$m][$args[0]]=$args[1];}else{$this->attrs[$m]=array($this->attrs[$m],$args[0]=>$args[1]);}return$this;}final
+public
+function
+href($path,$query=NULL){if($query){$query=http_build_query($query,NULL,'&');if($query!==''){$path.='?'.$query;}}$this->attrs['href']=$path;return$this;}final
+public
+function
+setHtml($html){if($html===NULL){$html='';}elseif(is_array($html)){throw
+new
+InvalidArgumentException("Textual content must be a scalar, ".gettype($html)." given.");}else{$html=(string)$html;}$this->removeChildren();$this->children[]=$html;return$this;}final
+public
+function
+getHtml(){$s='';foreach($this->children
+as$child){if(is_object($child)){$s.=$child->render();}else{$s.=$child;}}return$s;}final
+public
+function
+setText($text){if(!is_array($text)){$text=htmlspecialchars((string)$text,ENT_NOQUOTES);}return$this->setHtml($text);}final
+public
+function
+getText(){return
+html_entity_decode(strip_tags($this->getHtml()),ENT_QUOTES,'UTF-8');}final
+public
+function
+add($child){return$this->insert(NULL,$child);}final
+public
+function
+create($name,$attrs=NULL){$this->insert(NULL,$child=self::el($name,$attrs));return$child;}public
+function
+insert($index,$child,$replace=FALSE){if($child
+instanceof
+Html||is_scalar($child)){if($index===NULL){$this->children[]=$child;}else{array_splice($this->children,(int)$index,$replace?1:0,array($child));}}else{throw
+new
+InvalidArgumentException("Child node must be scalar or Html object, ".(is_object($child)?get_class($child):gettype($child))." given.");}return$this;}final
+public
+function
+offsetSet($index,$child){$this->insert($index,$child,TRUE);}final
+public
+function
+offsetGet($index){return$this->children[$index];}final
+public
+function
+offsetExists($index){return
+isset($this->children[$index]);}public
+function
+offsetUnset($index){if(isset($this->children[$index])){array_splice($this->children,(int)$index,1);}}final
+public
+function
+count(){return
+count($this->children);}public
+function
+removeChildren(){$this->children=array();}final
+public
+function
+getIterator($deep=FALSE){if($deep){$deep=$deep>0?RecursiveIteratorIterator::SELF_FIRST:RecursiveIteratorIterator::CHILD_FIRST;return
+new
+RecursiveIteratorIterator(new
+GenericRecursiveIterator(new
+ArrayIterator($this->children)),$deep);}else{return
+new
+GenericRecursiveIterator(new
+ArrayIterator($this->children));}}final
+public
+function
+getChildren(){return$this->children;}final
+public
+function
+render($indent=NULL){$s=$this->startTag();if(!$this->isEmpty){if($indent!==NULL){$indent++;}foreach($this->children
+as$child){if(is_object($child)){$s.=$child->render($indent);}else{$s.=$child;}}$s.=$this->endTag();}if($indent!==NULL){return"\n".str_repeat("\t",$indent-1).$s."\n".str_repeat("\t",max(0,$indent-2));}return$s;}final
+public
+function
+__toString(){return$this->render();}final
+public
+function
+startTag(){if($this->name){return'<'.$this->name.$this->attributes().(self::$xhtml&&$this->isEmpty?' />':'>');}else{return'';}}final
+public
+function
+endTag(){return$this->name&&!$this->isEmpty?'name.'>':'';}final
+public
+function
+attributes(){if(!is_array($this->attrs)){return'';}$s='';foreach($this->attrs
+as$key=>$value){if($value===NULL||$value===FALSE){continue;}elseif($value===TRUE){if(self::$xhtml){$s.=' '.$key.'="'.$key.'"';}else{$s.=' '.$key;}continue;}elseif(is_array($value)){if($key==='data'){foreach($value
+as$k=>$v){if($v!==NULL&&$v!==FALSE){$s.=' data-'.$k.'="'.htmlspecialchars((string)$v).'"';}}continue;}$tmp=NULL;foreach($value
+as$k=>$v){if($v!=NULL){$tmp[]=$v===TRUE?$k:(is_string($k)?$k.':'.$v:$v);}}if($tmp===NULL){continue;}$value=implode($key==='style'||!strncmp($key,'on',2)?';':' ',$tmp);}else{$value=(string)$value;}$s.=' '.$key.'="'.htmlspecialchars($value).'"';}$s=str_replace('@','@',$s);return$s;}public
+function
+__clone(){foreach($this->children
+as$key=>$value){if(is_object($value)){$this->children[$key]=clone$value;}}}}@header('X-Powered-By: Nette Framework');final
 class
 Debugger{public
 static$productionMode;public
@@ -571,14 +691,13 @@ StaticClassException;}public
 static
 function
 _init(){self::$time=microtime(TRUE);self::$consoleMode=PHP_SAPI==='cli';self::$productionMode=self::DETECT;if(self::$consoleMode){self::$source=empty($_SERVER['argv'])?'cli':'cli: '.implode(' ',$_SERVER['argv']);}else{self::$ajaxDetected=isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&$_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest';if(isset($_SERVER['REQUEST_URI'])){self::$source=(isset($_SERVER['HTTPS'])&&strcasecmp($_SERVER['HTTPS'],'off')?'https://':'http://').(isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:(isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:'')).$_SERVER['REQUEST_URI'];}}self::$logger=new
-Logger;self::$logger->directory=&self::$logDirectory;self::$logger->email=&self::$email;self::$logger->mailer=&self::$mailer;Logger::$emailSnooze=&self::$emailSnooze;self::$fireLogger=new
+Logger;self::$logDirectory=&self::$logger->directory;self::$email=&self::$logger->email;self::$mailer=&self::$logger->mailer;self::$emailSnooze=&Logger::$emailSnooze;self::$fireLogger=new
 FireLogger;self::$blueScreen=new
 DebugBlueScreen;self::$blueScreen->addPanel(create_function('$e','
 			if ($e instanceof TemplateException) {
-				$link = DebugHelpers::editorLink($e->sourceFile, $e->sourceLine);
 				return array(
 					\'tab\' => \'Template\',
-					\'panel\' => \'

File: \' . ($link ? \'\' : \'\') . htmlspecialchars($e->sourceFile) . ($link ? \'\' : \'\') + \'panel\' => \'

File: \' . DebugHelpers::editorLink($e->sourceFile, $e->sourceLine) . \'  Line: \' . ($e->sourceLine ? $e->sourceLine : \'n/a\') . \'

\' . ($e->sourceLine ? \'
\' . DebugBlueScreen::highlightFile($e->sourceFile, $e->sourceLine) . \'
\' : \'\') ); @@ -591,10 +710,10 @@ DefaultBarPanel('errors'));self::$bar->addPanel(self::$dumpPanel=new DefaultBarPanel('dumps'));}public static function -enable($mode=NULL,$logDirectory=NULL,$email=NULL){error_reporting(E_ALL|E_STRICT);if(is_bool($mode)){self::$productionMode=$mode;}elseif(is_string($mode)){$mode=preg_split('#[,\s]+#',"$mode 127.0.0.1 ::1");}if(is_array($mode)){self::$productionMode=!isset($_SERVER['REMOTE_ADDR'])||!in_array($_SERVER['REMOTE_ADDR'],$mode,TRUE);}if(self::$productionMode===self::DETECT){if(class_exists('Environment')){self::$productionMode=Environment::isProduction();}elseif(isset($_SERVER['SERVER_ADDR'])||isset($_SERVER['LOCAL_ADDR'])){$addrs=array();if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){$addrs=preg_split('#,\s*#',$_SERVER['HTTP_X_FORWARDED_FOR']);}if(isset($_SERVER['REMOTE_ADDR'])){$addrs[]=$_SERVER['REMOTE_ADDR'];}$addrs[]=isset($_SERVER['SERVER_ADDR'])?$_SERVER['SERVER_ADDR']:$_SERVER['LOCAL_ADDR'];self::$productionMode=FALSE;foreach($addrs +enable($mode=NULL,$logDirectory=NULL,$email=NULL){error_reporting(E_ALL|E_STRICT);if(is_bool($mode)){self::$productionMode=$mode;}elseif(is_string($mode)){$mode=preg_split('#[,\s]+#',"$mode 127.0.0.1 ::1");}if(is_array($mode)){self::$productionMode=!isset($_SERVER['REMOTE_ADDR'])||!in_array($_SERVER['REMOTE_ADDR'],$mode,TRUE);}if(self::$productionMode===self::DETECT){if(isset($_SERVER['SERVER_ADDR'])||isset($_SERVER['LOCAL_ADDR'])){$addrs=array();if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){$addrs=preg_split('#,\s*#',$_SERVER['HTTP_X_FORWARDED_FOR']);}if(isset($_SERVER['REMOTE_ADDR'])){$addrs[]=$_SERVER['REMOTE_ADDR'];}$addrs[]=isset($_SERVER['SERVER_ADDR'])?$_SERVER['SERVER_ADDR']:$_SERVER['LOCAL_ADDR'];self::$productionMode=FALSE;foreach($addrs as$addr){$oct=explode('.',$addr);if($addr!=='::1'&&(count($oct)!==4||($oct[0]!=='10'&&$oct[0]!=='127'&&($oct[0]!=='172'||$oct[1]<16||$oct[1]>31)&&($oct[0]!=='169'||$oct[1]!=='254')&&($oct[0]!=='192'||$oct[1]!=='168')))){self::$productionMode=TRUE;break;}}}else{self::$productionMode=!self::$consoleMode;}}if(is_string($logDirectory)){self::$logDirectory=realpath($logDirectory);if(self::$logDirectory===FALSE){throw new -DirectoryNotFoundException("Directory '$logDirectory' is not found.");}}elseif($logDirectory===FALSE){self::$logDirectory=FALSE;}else{self::$logDirectory=defined('APP_DIR')?APP_DIR.'/../log':getcwd().'/log';}if(self::$logDirectory){ini_set('error_log',self::$logDirectory.'/php_error.log');}if(function_exists('ini_set')){ini_set('display_errors',!self::$productionMode);ini_set('html_errors',FALSE);ini_set('log_errors',FALSE);}elseif(ini_get('display_errors')!=!self::$productionMode&&ini_get('display_errors')!==(self::$productionMode?'stderr':'stdout')){throw +DirectoryNotFoundException("Directory '$logDirectory' is not found.");}}elseif($logDirectory===FALSE){self::$logDirectory=FALSE;}elseif(self::$logDirectory===NULL){self::$logDirectory=defined('APP_DIR')?APP_DIR.'/../log':getcwd().'/log';}if(self::$logDirectory){ini_set('error_log',self::$logDirectory.'/php_error.log');}if(function_exists('ini_set')){ini_set('display_errors',!self::$productionMode);ini_set('html_errors',FALSE);ini_set('log_errors',FALSE);}elseif(ini_get('display_errors')!=!self::$productionMode&&ini_get('display_errors')!==(self::$productionMode?'stderr':'stdout')){throw new NotSupportedException('Function ini_set() must be enabled.');}if($email){if(!is_string($email)){throw new @@ -615,11 +734,11 @@ FatalErrorException?$exception->getMessage():"Uncaught exception ".get_class($ex DirectoryIterator(self::$logDirectory)as$entry){if(strpos($entry,$hash)){$exceptionFilename=NULL;break;}}}self::$logger->log(array(@date('[Y-m-d H-i-s]'),$message,self::$source?' @ '.self::$source:NULL,!empty($exceptionFilename)?' @@ '.$exceptionFilename:NULL),$priority);if(!empty($exceptionFilename)&&$logHandle=@fopen(self::$logDirectory.'/'.$exceptionFilename,'w')){ob_start();ob_start(create_function('$buffer','extract(NClosureFix::$vars['.NClosureFix::uses(array('logHandle'=>$logHandle)).'], EXTR_REFS); fwrite($logHandle, $buffer); '),1);self::$blueScreen->render($exception);ob_end_flush();ob_end_clean();fclose($logHandle);}}public static function -_shutdownHandler(){static$types=array(E_ERROR=>1,E_CORE_ERROR=>1,E_COMPILE_ERROR=>1,E_PARSE=>1);$error=error_get_last();if(isset($types[$error['type']])){self::_exceptionHandler(new -FatalErrorException($error['message'],0,$error['type'],$error['file'],$error['line'],NULL));}if(self::$bar&&!self::$productionMode&&!self::$ajaxDetected&&!self::$consoleMode&&!preg_match('#^Content-Type: (?!text/html)#im',implode("\n",headers_list()))){self::$bar->render();}}public +_shutdownHandler(){if(!self::$enabled){return;}static$types=array(E_ERROR=>1,E_CORE_ERROR=>1,E_COMPILE_ERROR=>1,E_PARSE=>1);$error=error_get_last();if(isset($types[$error['type']])){self::_exceptionHandler(new +FatalErrorException($error['message'],0,$error['type'],$error['file'],$error['line'],NULL));}if(self::$bar&&!self::$productionMode&&self::isHtmlMode()){self::$bar->render();}}public static function -_exceptionHandler(Exception$exception){if(!headers_sent()){header('HTTP/1.1 500 Internal Server Error');}$htmlMode=!self::$ajaxDetected&&!preg_match('#^Content-Type: (?!text/html)#im',implode("\n",headers_list()));try{if(self::$productionMode){self::log($exception,self::ERROR);if(self::$consoleMode){echo"ERROR: the server encountered an internal error and was unable to complete your request.\n";}elseif($htmlMode){?> +_exceptionHandler(Exception$exception){if(!headers_sent()){header('HTTP/1.1 500 Internal Server Error');}try{if(self::$productionMode){self::log($exception,self::ERROR);if(self::$consoleMode){echo"ERROR: the server encountered an internal error and was unable to complete your request.\n";}elseif(self::isHtmlMode()){?> @@ -632,8 +751,8 @@ _exceptionHandler(Exception$exception){if(!headers_sent()){header('HTTP/1.1 500

We're sorry! The server encountered an internal error and was unable to complete your request. Please try again later.

error 500

-render($exception);if(self::$bar){self::$bar->render();}}elseif(!self::fireLog($exception,self::ERROR)){self::log($exception);}}foreach(self::$onFatalError -as$handler){call_user_func($handler,$exception);}}catch(Exception$e){echo"\nNette\\Debug FATAL ERROR: thrown ",get_class($e),': ',$e->getMessage(),"\nwhile processing ",get_class($exception),': ',$exception->getMessage(),"\n";}exit(255);}public +render($exception);if(self::$bar){self::$bar->render();}}elseif(!self::fireLog($exception,self::ERROR)){self::log($exception);}}foreach(self::$onFatalError +as$handler){call_user_func($handler,$exception);}}catch(Exception$e){echo"\nNette\\Debug FATAL ERROR: thrown ",get_class($e),': ',$e->getMessage(),"\nwhile processing ",get_class($exception),': ',$exception->getMessage(),"\n";}self::$enabled=FALSE;exit(255);}public static function _errorHandler($severity,$message,$file,$line,$context){if(self::$scream){error_reporting(E_ALL|E_STRICT);}if(self::$lastError!==FALSE&&($severity&error_reporting())===$severity){self::$lastError=new @@ -645,8 +764,7 @@ FALSE;}elseif(self::$strictMode&&!self::$productionMode){self::_exceptionHandler FatalErrorException($message,0,$severity,$file,$line,$context));}static$types=array(E_WARNING=>'Warning',E_COMPILE_WARNING=>'Warning',E_USER_WARNING=>'Warning',E_NOTICE=>'Notice',E_USER_NOTICE=>'Notice',E_STRICT=>'Strict standards',E_DEPRECATED=>'Deprecated',E_USER_DEPRECATED=>'Deprecated');$message='PHP '.(isset($types[$severity])?$types[$severity]:'Unknown error').": $message";$count=&self::$errorPanel->data["$message|$file|$line"];if($count++){return NULL;}elseif(self::$productionMode){self::log("$message in $file:$line",self::ERROR);return NULL;}else{$ok=self::fireLog(new -ErrorException($message,0,$severity,$file,$line),self::WARNING);return -self::$consoleMode||(!self::$bar&&!$ok)?FALSE:NULL;}return +ErrorException($message,0,$severity,$file,$line),self::WARNING);return!self::isHtmlMode()||(!self::$bar&&!$ok)?FALSE:NULL;}return FALSE;}public static function @@ -659,7 +777,7 @@ function catchError(&$error){if(!self::$enabled&&self::$lastError!==FALSE){restore_error_handler();}$error=self::$lastError;self::$lastError=FALSE;return(bool)$error;}public static function -dump($var,$return=FALSE){if(!$return&&self::$productionMode){return$var;}$output="
".DebugHelpers::htmlDump($var)."
\n";if(!$return&&self::$showLocation){$trace=debug_backtrace();$i=isset($trace[1]['class'])&&$trace[1]['class']===__CLASS__?1:0;if(isset($trace[$i]['file'],$trace[$i]['line'])){$output=substr_replace($output,' '.htmlspecialchars("in file {$trace[$i]['file']} on line {$trace[$i]['line']}",ENT_NOQUOTES).'',-8,0);}}if(self::$consoleMode){$output=htmlspecialchars_decode(strip_tags($output),ENT_NOQUOTES);}if($return){return$output;}else{echo$output;return$var;}}public +dump($var,$return=FALSE){if(!$return&&self::$productionMode){return$var;}$output="
".DebugHelpers::htmlDump($var)."
\n";if(!$return){$trace=debug_backtrace();$i=!isset($trace[1]['class'])&&isset($trace[1]['function'])&&$trace[1]['function']==='dump'?1:0;if(isset($trace[$i]['file'],$trace[$i]['line'])&&is_file($trace[$i]['file'])){$lines=file($trace[$i]['file']);preg_match('#dump\((.*)\)#',$lines[$trace[$i]['line']-1],$m);$output=substr_replace($output,' title="'.htmlspecialchars((isset($m[0])?"$m[0] \n":'')."in file {$trace[$i]['file']} on line {$trace[$i]['line']}").'"',4,0);if(self::$showLocation){$output=substr_replace($output,' in '.DebugHelpers::editorLink($trace[$i]['file'],$trace[$i]['line']).":{$trace[$i]['line']}",-8,0);}}}if(self::$consoleMode){$output=htmlspecialchars_decode(strip_tags($output),ENT_NOQUOTES);}if($return){return$output;}else{echo$output;return$var;}}public static function timer($name=NULL){static$time=array();$now=microtime(TRUE);$delta=isset($time[$name])?$now-$time[$name]:0;$time[$name]=$now;return$delta;}public @@ -669,7 +787,22 @@ barDump($var,$title=NULL){if(!self::$productionMode){$dump=array();foreach((is_a static function fireLog($message){if(!self::$productionMode){return -self::$fireLogger->log($message);}}public +self::$fireLogger->log($message);}}private static function -addPanel(IBarPanel$panel,$id=NULL){self::$bar->addPanel($panel,$id);}}Debugger::_init(); \ No newline at end of file +isHtmlMode(){return!self::$ajaxDetected&&!self::$consoleMode&&!preg_match('#^Content-Type: (?!text/html)#im',implode("\n",headers_list()));}public +static +function +addPanel(IBarPanel$panel,$id=NULL){self::$bar->addPanel($panel,$id);}}function +dump($var){foreach(func_get_args()as$arg)Debugger::dump($arg);return$var;}class +FatalErrorException +extends +Exception{private$severity;public +function +__construct($message,$code,$severity,$file,$line,$context){parent::__construct($message,$code);$this->severity=$severity;$this->file=$file;$this->line=$line;$this->context=$context;}public +function +getSeverity(){return$this->severity;}}class +NClosureFix{static$vars=array();static +function +uses($args){self::$vars[]=$args;return +count(self::$vars)-1;}}Debugger::_init(); diff --git a/examples/connecting-to-databases.php b/examples/connecting-to-databases.php index 922f86f..5ff08b8 100644 --- a/examples/connecting-to-databases.php +++ b/examples/connecting-to-databases.php @@ -4,7 +4,7 @@ getMessage(), "\n"; } -echo "

\n"; \ No newline at end of file +echo "

\n"; diff --git a/examples/data/style.css b/examples/data/style.css index 348292c..f19c938 100644 --- a/examples/data/style.css +++ b/examples/data/style.css @@ -16,12 +16,6 @@ h2 { font-size: 150%; } -pre.dump { - border: 1px solid silver; - padding: 1em; - margin: 1em 0; -} - a { color: #000080; } @@ -45,3 +39,26 @@ table.dump th { color: #525b37; background: #e3e9ba; } + +/* dump() */ +pre.nette-dump, pre.dump { + color: #444; background: white; + border: 1px solid silver; + padding: 1em; + margin: 1em 0; +} +pre.nette-dump .php-array, pre.nette-dump .php-object { + color: #C22; +} +pre.nette-dump .php-string { + color: #080; +} +pre.nette-dump .php-int, pre.nette-dump .php-float { + color: #37D; +} +pre.nette-dump .php-null, pre.nette-dump .php-bool { + color: black; +} +pre.nette-dump .php-visibility { + font-size: 85%; color: #999; +} diff --git a/examples/database-reflection.php b/examples/database-reflection.php index a2a9575..5d0b29e 100644 --- a/examples/database-reflection.php +++ b/examples/database-reflection.php @@ -4,7 +4,7 @@ fetch()\n"; $row = dibi::fetch('SELECT title FROM products'); -Debug::dump($row); // Chair +Debugger::dump($row); // Chair // fetch a single value echo "

fetchSingle()

\n"; $value = dibi::fetchSingle('SELECT title FROM products'); -Debug::dump($value); // Chair +Debugger::dump($value); // Chair // fetch complete result set echo "

fetchAll()

\n"; $all = dibi::fetchAll('SELECT * FROM products'); -Debug::dump($all); +Debugger::dump($all); // fetch complete result set like association array echo "

fetchAssoc('title')

\n"; $res = dibi::query('SELECT * FROM products'); $assoc = $res->fetchAssoc('title'); // key -Debug::dump($assoc); +Debugger::dump($assoc); // fetch complete result set like pairs key => value echo "

fetchPairs('product_id', 'title')

\n"; $pairs = $res->fetchPairs('product_id', 'title'); -Debug::dump($pairs); +Debugger::dump($pairs); // fetch row by row echo "

using foreach

\n"; foreach ($res as $n => $row) { - Debug::dump($row); + Debugger::dump($row); } @@ -74,12 +74,12 @@ $res = dibi::query(' echo "

fetchAssoc('customers.name|products.title')

\n"; $assoc = $res->fetchAssoc('customers.name|products.title'); // key -Debug::dump($assoc); +Debugger::dump($assoc); echo "

fetchAssoc('customers.name[]products.title')

\n"; $assoc = $res->fetchAssoc('customers.name[]products.title'); // key -Debug::dump($assoc); +Debugger::dump($assoc); echo "

fetchAssoc('customers.name->products.title')

\n"; $assoc = $res->fetchAssoc('customers.name->products.title'); // key -Debug::dump($assoc); +Debugger::dump($assoc); diff --git a/examples/importing-dump-from-file.php b/examples/importing-dump-from-file.php index 72a8019..c9bd4b5 100644 --- a/examples/importing-dump-from-file.php +++ b/examples/importing-dump-from-file.php @@ -4,7 +4,7 @@ setType('customer_id', Dibi::INTEGER) ->setType('added', Dibi::DATETIME, 'H:i j.n.Y'); -Debug::dump( $res->fetch() ); +Debugger::dump( $res->fetch() ); // outputs: // object(DibiRow)#3 (3) { // customer_id => int(1) @@ -37,7 +37,7 @@ $res = dibi::query('SELECT * FROM [customers]'); $res->detectTypes(); -Debug::dump( $res->fetch() ); +Debugger::dump( $res->fetch() ); // outputs: // object(DibiRow)#3 (3) { // customer_id => int(1) diff --git a/examples/using-datetime.php b/examples/using-datetime.php index 2eba972..2c02223 100644 --- a/examples/using-datetime.php +++ b/examples/using-datetime.php @@ -4,7 +4,7 @@ fetchShuffle(); -Debug::dump($all); +Debugger::dump($all); diff --git a/examples/using-fluent-syntax.php b/examples/using-fluent-syntax.php index aa5bc2a..3b5b2f4 100644 --- a/examples/using-fluent-syntax.php +++ b/examples/using-fluent-syntax.php @@ -4,7 +4,7 @@
  • Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843
  • FirePHP: http://www.firephp.org/ - \ No newline at end of file + diff --git a/examples/using-substitutions.php b/examples/using-substitutions.php index f9fbde2..6a9e51d 100644 --- a/examples/using-substitutions.php +++ b/examples/using-substitutions.php @@ -4,7 +4,7 @@