diff --git a/library/ZFDebug/Controller/Plugin/Debug.php b/library/ZFDebug/Controller/Plugin/Debug.php index 64e591a..c8df36a 100644 --- a/library/ZFDebug/Controller/Plugin/Debug.php +++ b/library/ZFDebug/Controller/Plugin/Debug.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -30,7 +30,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug extends Zend_Controller_Plugin_Abstract { @@ -73,7 +73,7 @@ class ZFDebug_Controller_Plugin_Debug extends Zend_Controller_Plugin_Abstract * * @var string */ - protected $version = '1.6.5'; + protected $version = '1.7.0'; /** * Creates a new instance of the Debug Bar diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin.php index 19d5dd7..8e1d710 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id: $ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Auth.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Auth.php index 78aff31..8bdf33f 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Auth.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Auth.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id: $ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Auth implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Cache.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Cache.php index cfa5733..2fa80af 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Cache.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Cache.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Cache extends ZFDebug_Controller_Plugin_Debug_Plugin implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Database.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Database.php index 60ba67a..ba93fa7 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Database.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Database.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -20,7 +20,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Database extends ZFDebug_Controller_Plugin_Debug_Plugin implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Exception.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Exception.php index 3592c35..3947820 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Exception.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Exception.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Exception extends Zend_Controller_Plugin_Abstract implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/File.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/File.php index d92ebe9..5298704 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/File.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/File.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_File extends ZFDebug_Controller_Plugin_Debug_Plugin implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Html.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Html.php index 71fe27a..937f9d3 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Html.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Html.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Html extends ZFDebug_Controller_Plugin_Debug_Plugin implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Interface.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Interface.php index 30986ca..efc982e 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Interface.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Interface.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ interface ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Log.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Log.php index 66b4fd2..a4fc976 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Log.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Log.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Log extends Zend_Controller_Plugin_Abstract implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Log/Writer.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Log/Writer.php index cc1311a..7a6c1ea 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Log/Writer.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Log/Writer.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Log_Writer extends Zend_Log_Writer_Abstract { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Text.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Text.php index 4d01ef6..f1ff089 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Text.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Text.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Text implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Variables.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Variables.php index 1147a2f..d0b8103 100644 --- a/library/ZFDebug/Controller/Plugin/Debug/Plugin/Variables.php +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/Variables.php @@ -6,7 +6,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License * @version $Id$ */ @@ -15,7 +15,7 @@ * @package ZFDebug_Controller * @subpackage Plugins * @copyright Copyright (c) 2008-2009 ZF Debug Bar Team (http://code.google.com/p/zfdebug) - * @license http://code.google.com/p/zfdebug/wiki/License New BSD License + * @license https://github.com/jokkedk/ZFDebug/blob/master/license New BSD License */ class ZFDebug_Controller_Plugin_Debug_Plugin_Variables extends ZFDebug_Controller_Plugin_Debug_Plugin implements ZFDebug_Controller_Plugin_Debug_Plugin_Interface { diff --git a/library/ZFDebug/Controller/Plugin/Debug/Plugin/ZendDb.php b/library/ZFDebug/Controller/Plugin/Debug/Plugin/ZendDb.php new file mode 100644 index 0000000..a926ed0 --- /dev/null +++ b/library/ZFDebug/Controller/Plugin/Debug/Plugin/ZendDb.php @@ -0,0 +1,168 @@ +db[0] = $options['adapter']; + if (isset($options['backtrace']) && $options['backtrace']) { + $this->backtrace = true; + $this->db[0]->setProfiler(new ZFDebug_Db_ZendDbProfiler); + } else { + $this->db[0]->setProfiler(new Zend\Db\Adapter\Profiler\Profiler); + } + } else { + foreach ($options['adapter'] as $name => $adapter) { + if ($adapter instanceof Zend\Db\AdapterInterface) { + $this->db[$name] = $adapter; + } + } + } + } + + /** + * Gets identifier for this plugin + * + * @return string + */ + public function getIdentifier() + { + return $this->identifier; + } + + /** + * Returns the base64 encoded icon + * + * @return string + **/ + public function getIconData() + { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC'; + } + + /** + * Gets menu tab for the Debugbar + * + * @return string + */ + public function getTab() + { + if (!$this->db) { + return 'No adapter'; + } + foreach ($this->db as $adapter) { + $profiler = $adapter->getProfiler(); + $profiles = $profiler->getProfiles(); + $adapterInfo[] = count($profiles) + . ' in ' + . round( + array_reduce( + $profiles, + function ($carry, $item) { + return $carry + $item['elapse']; + } + ) * 1000, + 2 + ) . ' ms'; + } + $html = implode(' / ', $adapterInfo); + + return $html; + } + + /** + * Gets content panel for the Debugbar + * + * @return string + */ + public function getPanel() + { + if (!$this->db) + return ''; + + $html = '

Zend\Db queries

'; + + return $html . $this->getProfile(); + } + + public function getProfile() + { + $queries = ''; + foreach ($this->db as $name => $adapter) { + if ($profiles = $adapter->getProfiler()->getProfiles()) { + if (1 < count($this->db)) { + $queries .= '

Adapter '.$name.'

'; + } + $queries .=''; + foreach ($profiles as $profile) { + $queries .= "\n\n\n\n"; + if ($this->backtrace) { + $trace = $profile['trace']; + array_walk( + $trace, + function (&$v, $k) { + $v = ($k+1).'. '.$v; + } + ); + $queries .= "\n\n\n\n"; + } + } + $queries .= "
\n" + . sprintf('%0.2f', $profile['elapse']*1000) + . "ms"; + + if ($profile['parameters']) { + $queryParameters = array_values($profile['parameters']->getNamedArray()); + $queryParameters[] = null; + $parts = explode('?', $profile['sql']); + foreach ($parts as $partIndex => $partValue) { + $queries .= $partValue . $queryParameters[$partIndex]; + } + } else { + $queries .= $profile['sql']; + } + + $queries .= "
".implode('
', $trace)."
\n"; + } + } + return $queries; + } +} diff --git a/library/ZFDebug/Db/ZendDbProfiler.php b/library/ZFDebug/Db/ZendDbProfiler.php new file mode 100644 index 0000000..332b48f --- /dev/null +++ b/library/ZFDebug/Db/ZendDbProfiler.php @@ -0,0 +1,53 @@ +profiles[$this->currentIndex]['trace'] = $trace; + + return $this; + } + + public function profilerFinish() + { + parent::profilerFinish(); + + return $this; + } +}