Added the debug toolkit plugin, found on the bakery website.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@92 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
165
site/plugins/debug_kit/vendors/css/debug_toolbar.css
vendored
Normal file
165
site/plugins/debug_kit/vendors/css/debug_toolbar.css
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/* @override http://localhost/cake_debug_kit/debug_kit/css/debug_toolbar.css */
|
||||
#debug-kit-toolbar {
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
right:0px;
|
||||
width: 100%;
|
||||
height: 1%;
|
||||
overflow: visible;
|
||||
z-index:10000;
|
||||
}
|
||||
/* panel tabs */
|
||||
#debug-kit-toolbar #panel-tabs {
|
||||
float: right;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
#debug-kit-toolbar .panel-tab {
|
||||
clear: none;
|
||||
float: left;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#debug-kit-toolbar .panel-tab a {
|
||||
float: left;
|
||||
clear: none;
|
||||
background: #efefef;
|
||||
color: #222;
|
||||
padding: 6px;
|
||||
border-right: 1px solid #ccc;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
margin: 0;
|
||||
display: block;
|
||||
}
|
||||
#debug-kit-toolbar .panel-tab .active,
|
||||
#debug-kit-toolbar .panel-tab a:hover {
|
||||
background: #fff;
|
||||
}
|
||||
#debug-kit-toolbar .panel-tab.icon a {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
/* Hovering over link shows tab, useful for no js */
|
||||
#debug-kit-toolbar .panel-tab a:hover + .panel-content,
|
||||
#debug-kit-toolbar .panel-tab a + .panel-content:hover {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* panel content */
|
||||
#debug-kit-toolbar .panel-content {
|
||||
position: absolute;
|
||||
text-align: left;
|
||||
width: auto;
|
||||
top:28px;
|
||||
right:0px;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
width:96%;
|
||||
padding:20px 2%;
|
||||
max-height: 550px;
|
||||
overflow:auto;
|
||||
border-bottom: 3px solid #333;
|
||||
}
|
||||
|
||||
/* Hide panel content by default */
|
||||
.panel-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.panel-content p {
|
||||
margin: 1em 0;
|
||||
}
|
||||
.panel-content h2 {
|
||||
padding: 0;
|
||||
margin-top:0;
|
||||
}
|
||||
.panel-content h3 {
|
||||
padding: 0;
|
||||
margin-top: 1em;
|
||||
}
|
||||
.panel-content .info {
|
||||
padding: 4px;
|
||||
border-top: 1px dashed #6c6cff;
|
||||
border-bottom: 1px dashed #6c6cff;
|
||||
}
|
||||
|
||||
/* panel tables */
|
||||
table.debug-table {
|
||||
width: auto;
|
||||
border: 0;
|
||||
}
|
||||
table.debug-table td,
|
||||
table.debug-table th {
|
||||
text-align: left;
|
||||
border: 0;
|
||||
padding: 3px;
|
||||
}
|
||||
table.debug-table th {
|
||||
border-bottom: 1px solid #222;
|
||||
background: 0;;
|
||||
}
|
||||
table.debug-table tr.even td {
|
||||
background:#efefef;
|
||||
}
|
||||
|
||||
/** code tables **/
|
||||
#debug-kit-toolbar .code-table td {
|
||||
white-space: pre;
|
||||
font-family: monaco, corsiva, "courier new", courier, monospaced;
|
||||
}
|
||||
#debug-kit-toolbar .code-table td:first-child {
|
||||
width: 15%;
|
||||
}
|
||||
#debug-kit-toolbar .code-table td:last-child {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
|
||||
.panel-content.request {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
/** Neat Array styles **/
|
||||
.neat-array {
|
||||
padding: 1px 2px 1px 20px;
|
||||
background: #CE9E23;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
.neat-array .neat-array {
|
||||
padding: 0 0 0 20px;
|
||||
}
|
||||
.neat-array li {
|
||||
background: #FEF6E5;
|
||||
border-top: 1px solid #CE9E23;
|
||||
border-bottom: 1px solid #CE9E23;
|
||||
margin: 0;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
.neat-array li:hover {
|
||||
background: #fff;
|
||||
}
|
||||
.neat-array li strong {
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
/* expandable sections */
|
||||
.neat-array li.expandable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.neat-array li.expandable.expanded > strong:before {
|
||||
content: 'v ';
|
||||
}
|
||||
.neat-array li.expandable.collapsed > strong:before,
|
||||
.neat-array li.expandable.expanded .expandable.collapsed > strong:before {
|
||||
content: '> ';
|
||||
}
|
||||
|
||||
.neat-array li {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
226
site/plugins/debug_kit/vendors/debug_kit_debugger.php
vendored
Normal file
226
site/plugins/debug_kit/vendors/debug_kit_debugger.php
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* DebugKit Debugger class. Extends and enhances core
|
||||
* debugger. Adds benchmarking and timing functionality.
|
||||
*
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('Core', 'Debugger');
|
||||
App::import('Vendor', 'DebugKit.FireCake');
|
||||
/**
|
||||
* Debug Kit Temporary Debugger Class
|
||||
*
|
||||
* Provides the future features that are planned. Yet not implemented in the 1.2 code base
|
||||
*
|
||||
* This file will not be needed in future version of CakePHP.
|
||||
* @todo merge these changes with core Debugger
|
||||
*/
|
||||
class DebugKitDebugger extends Debugger {
|
||||
|
||||
/**
|
||||
* Start an benchmarking timer.
|
||||
*
|
||||
* @param string $name The name of the timer to start.
|
||||
* @param string $message A message for your timer
|
||||
* @return bool true
|
||||
* @static
|
||||
**/
|
||||
function startTimer($name = 'default', $message = '') {
|
||||
$now = getMicrotime();
|
||||
$_this = DebugKitDebugger::getInstance();
|
||||
$_this->__benchmarks[$name] = array(
|
||||
'start' => $now,
|
||||
'message' => $message,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a benchmarking timer.
|
||||
*
|
||||
* $name should be the same as the $name used in startTimer().
|
||||
*
|
||||
* @param string $name The name of the timer to end.
|
||||
* @access public
|
||||
* @return boolean true if timer was ended, false if timer was not started.
|
||||
* @static
|
||||
*/
|
||||
function stopTimer($name = 'default') {
|
||||
$now = getMicrotime();
|
||||
$_this = DebugKitDebugger::getInstance();
|
||||
if (!isset($_this->__benchmarks[$name])) {
|
||||
return false;
|
||||
}
|
||||
$_this->__benchmarks[$name]['end'] = $now;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all timers that have been started and stopped.
|
||||
* Calculates elapsed time for each timer.
|
||||
*
|
||||
* @return array
|
||||
**/
|
||||
function getTimers() {
|
||||
$_this =& DebugKitDebugger::getInstance();
|
||||
$times = array();
|
||||
foreach ($_this->__benchmarks as $name => $timer) {
|
||||
$times[$name]['time'] = DebugKitDebugger::elapsedTime($name);
|
||||
$times[$name]['message'] = $timer['message'];
|
||||
}
|
||||
return $times;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all existing timers
|
||||
*
|
||||
* @return bool true
|
||||
**/
|
||||
function clearTimers() {
|
||||
$_this =& DebugKitDebugger::getInstance();
|
||||
$_this->__benchmarks = array();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the difference in time between the timer start and timer end.
|
||||
*
|
||||
* @param $name string the name of the timer you want elapsed time for.
|
||||
* @param $precision int the number of decimal places to return, defaults to 5.
|
||||
* @return float number of seconds elapsed for timer name, 0 on missing key
|
||||
* @static
|
||||
**/
|
||||
function elapsedTime($name = 'default', $precision = 5) {
|
||||
$_this =& DebugKitDebugger::getInstance();
|
||||
if (!isset($_this->__benchmarks[$name]['start']) || !isset($_this->__benchmarks[$name]['end'])) {
|
||||
return 0;
|
||||
}
|
||||
return round($_this->__benchmarks[$name]['end'] - $_this->__benchmarks[$name]['start'], $precision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total execution time until this point
|
||||
*
|
||||
* @access public
|
||||
* @return float elapsed time in seconds since script start.
|
||||
* @static
|
||||
*/
|
||||
function requestTime() {
|
||||
$start = DebugKitDebugger::requestStartTime();
|
||||
$now = getMicroTime();
|
||||
return ($now - $start);
|
||||
}
|
||||
/**
|
||||
* get the time the current request started.
|
||||
*
|
||||
* @access public
|
||||
* @return float time of request start
|
||||
* @static
|
||||
*/
|
||||
function requestStartTime() {
|
||||
if (defined('TIME_START')) {
|
||||
$startTime = TIME_START;
|
||||
} else if (isset($_GLOBALS['TIME_START'])) {
|
||||
$startTime = $_GLOBALS['TIME_START'];
|
||||
} else {
|
||||
$startTime = env('REQUEST_TIME');
|
||||
}
|
||||
return $startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* get current memory usage
|
||||
*
|
||||
* @return integer number of bytes ram currently in use. 0 if memory_get_usage() is not available.
|
||||
* @static
|
||||
**/
|
||||
function getMemoryUse() {
|
||||
if (!function_exists('memory_get_usage')) {
|
||||
return 0;
|
||||
}
|
||||
return memory_get_usage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get peak memory use
|
||||
*
|
||||
* @return integer peak memory use (in bytes). Returns 0 if memory_get_peak_usage() is not available
|
||||
* @static
|
||||
**/
|
||||
function getPeakMemoryUse() {
|
||||
if (!function_exists('memory_get_peak_usage')) {
|
||||
return 0;
|
||||
}
|
||||
return memory_get_peak_usage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles object conversion to debug string.
|
||||
*
|
||||
* @param string $var Object to convert
|
||||
* @access protected
|
||||
*/
|
||||
function _output($level, $error, $code, $helpCode, $description, $file, $line, $kontext) {
|
||||
$files = $this->trace(array('start' => 2, 'format' => 'points'));
|
||||
$listing = $this->excerpt($files[0]['file'], $files[0]['line'] - 1, 1);
|
||||
$trace = $this->trace(array('start' => 2, 'depth' => '20'));
|
||||
$context = array();
|
||||
|
||||
foreach ((array)$kontext as $var => $value) {
|
||||
$context[] = "\${$var}\t=\t" . $this->exportVar($value, 1);
|
||||
}
|
||||
if ($this->_outputFormat == 'fb') {
|
||||
$this->_fireError($error, $code, $description, $file, $line, $trace, $context);
|
||||
} else {
|
||||
echo parent::_output($level, $error, $code, $helpCode, $description, $file, $line, $kontext);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a FirePHP error message
|
||||
*
|
||||
* @param string $error Name of error
|
||||
* @param string $code Code of error
|
||||
* @param string $description Description of error
|
||||
* @param string $file File error occured in
|
||||
* @param string $line Line error occured on
|
||||
* @param string $trace Stack trace at time of error
|
||||
* @param string $context context of error
|
||||
* @return void
|
||||
* @access protected
|
||||
*/
|
||||
function _fireError($error, $code, $description, $file, $line, $trace, $context) {
|
||||
$name = $error . ' - ' . $description;
|
||||
$message = "$error $code $description on line: $line in file: $file";
|
||||
FireCake::group($name);
|
||||
FireCake::error($message, $name);
|
||||
FireCake::log($context, 'Context');
|
||||
FireCake::log($trace, 'Trace');
|
||||
FireCake::groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Debugger::invoke(DebugKitDebugger::getInstance());
|
||||
Debugger::getInstance('DebugKitDebugger');
|
||||
?>
|
||||
539
site/plugins/debug_kit/vendors/fire_cake.php
vendored
Normal file
539
site/plugins/debug_kit/vendors/fire_cake.php
vendored
Normal file
@@ -0,0 +1,539 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* FirePHP Class for CakePHP
|
||||
*
|
||||
* Provides most of the functionality offered by FirePHPCore
|
||||
* Interoperates with FirePHP extension for firefox
|
||||
*
|
||||
* For more information see: http://www.firephp.org/
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package debug_kit.
|
||||
* @subpackage debug_kit.vendors
|
||||
* @since
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('Core', 'Debugger');
|
||||
|
||||
class FireCake extends Object {
|
||||
/**
|
||||
* Options for FireCake.
|
||||
*
|
||||
* @see _defaultOptions and setOptions();
|
||||
* @var string
|
||||
*/
|
||||
var $options = array();
|
||||
/**
|
||||
* Default Options used in CakeFirePhp
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
var $_defaultOptions = array(
|
||||
'maxObjectDepth' => 10,
|
||||
'maxArrayDepth' => 20,
|
||||
'useNativeJsonEncode' => true,
|
||||
'includeLineNumbers' => true,
|
||||
);
|
||||
/**
|
||||
* Message Levels for messages sent via FirePHP
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $_levels = array(
|
||||
'log' => 'LOG',
|
||||
'info' => 'INFO',
|
||||
'warn' => 'WARN',
|
||||
'error' => 'ERROR',
|
||||
'dump' => 'DUMP',
|
||||
'trace' => 'TRACE',
|
||||
'exception' => 'EXCEPTION',
|
||||
'table' => 'TABLE',
|
||||
'groupStart' => 'GROUP_START',
|
||||
'groupEnd' => 'GROUP_END',
|
||||
);
|
||||
|
||||
var $_version = '0.2.1';
|
||||
/**
|
||||
* internal messageIndex counter
|
||||
*
|
||||
* @var int
|
||||
* @access protected
|
||||
*/
|
||||
var $_messageIndex = 1;
|
||||
/**
|
||||
* stack of objects encoded by stringEncode()
|
||||
*
|
||||
* @var array
|
||||
**/
|
||||
var $_encodedObjects = array();
|
||||
/**
|
||||
* methodIndex to include in tracebacks when using includeLineNumbers
|
||||
*
|
||||
* @var array
|
||||
**/
|
||||
var $_methodIndex = array('info', 'log', 'warn', 'error', 'table', 'trace');
|
||||
/**
|
||||
* FireCake output status
|
||||
*
|
||||
* @var bool
|
||||
**/
|
||||
var $_enabled = true;
|
||||
/**
|
||||
* get Instance of the singleton
|
||||
*
|
||||
* @param string $class Class instance to store in the singleton. Used with subclasses and Tests.
|
||||
* @access public
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
function &getInstance($class = null) {
|
||||
static $instance = array();
|
||||
if (!empty($class)) {
|
||||
if (!$instance || strtolower($class) != strtolower(get_class($instance[0]))) {
|
||||
$instance[0] = new $class();
|
||||
$instance[0]->setOptions();
|
||||
}
|
||||
}
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
$instance[0] = new FireCake();
|
||||
$instance[0]->setOptions();
|
||||
}
|
||||
return $instance[0];
|
||||
}
|
||||
/**
|
||||
* setOptions
|
||||
*
|
||||
* @param array $options Array of options to set.
|
||||
* @access public
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
function setOptions($options = array()) {
|
||||
$_this = FireCake::getInstance();
|
||||
if (empty($_this->options)) {
|
||||
$_this->options = array_merge($_this->_defaultOptions, $options);
|
||||
} else {
|
||||
$_this->options = array_merge($_this->options, $options);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return boolean based on presence of FirePHP extension
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
**/
|
||||
function detectClientExtension() {
|
||||
$ua = FireCake::getUserAgent();
|
||||
if (!preg_match('/\sFirePHP\/([\.|\d]*)\s?/si', $ua, $match) || !version_compare($match[1], '0.0.6', '>=')) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Get the Current UserAgent
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @return string UserAgent string of active client connection
|
||||
**/
|
||||
function getUserAgent() {
|
||||
return env('HTTP_USER_AGENT');
|
||||
}
|
||||
/**
|
||||
* Disable FireCake output
|
||||
* All subsequent output calls will not be run.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function disable() {
|
||||
$_this = FireCake::getInstance();
|
||||
$_this->_enabled = false;
|
||||
}
|
||||
/**
|
||||
* Enable FireCake output
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function enable() {
|
||||
$_this = FireCake::getInstance();
|
||||
$_this->_enabled = true;
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for LOG messages
|
||||
*
|
||||
* @param string $message Message to log
|
||||
* @param string $label Label for message (optional)
|
||||
* @access public
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
function log($message, $label = null) {
|
||||
FireCake::fb($message, $label, 'log');
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for WARN messages
|
||||
*
|
||||
* @param string $message Message to log
|
||||
* @param string $label Label for message (optional)
|
||||
* @access public
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
function warn($message, $label = null) {
|
||||
FireCake::fb($message, $label, 'warn');
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for INFO messages
|
||||
*
|
||||
* @param string $message Message to log
|
||||
* @param string $label Label for message (optional)
|
||||
* @access public
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
function info($message, $label = null) {
|
||||
FireCake::fb($message, $label, 'info');
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for ERROR messages
|
||||
*
|
||||
* @param string $message Message to log
|
||||
* @param string $label Label for message (optional)
|
||||
* @access public
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
function error($message, $label = null) {
|
||||
FireCake::fb($message, $label, 'error');
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for TABLE messages
|
||||
*
|
||||
* @param string $message Message to log
|
||||
* @param string $label Label for message (optional)
|
||||
* @access public
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
function table($label, $message) {
|
||||
FireCake::fb($message, $label, 'table');
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for DUMP messages
|
||||
*
|
||||
* @param string $message Message to log
|
||||
* @param string $label Unique label for message
|
||||
* @access public
|
||||
* @static
|
||||
* @return void
|
||||
*/
|
||||
function dump($label, $message) {
|
||||
FireCake::fb($message, $label, 'dump');
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for TRACE messages
|
||||
*
|
||||
* @param string $label Label for message (optional)
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function trace($label) {
|
||||
FireCake::fb($label, 'trace');
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for GROUP messages
|
||||
* Messages following the group call will be nested in a group block
|
||||
*
|
||||
* @param string $label Label for group (optional)
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function group($label) {
|
||||
FireCake::fb(null, $label, 'groupStart');
|
||||
}
|
||||
/**
|
||||
* Convenience wrapper for GROUPEND messages
|
||||
* Closes a group block
|
||||
*
|
||||
* @param string $label Label for group (optional)
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function groupEnd() {
|
||||
FireCake::fb(null, null, 'groupEnd');
|
||||
}
|
||||
/**
|
||||
* fb - Send messages with FireCake to FirePHP
|
||||
*
|
||||
* Much like FirePHP's fb() this method can be called with various parameter counts
|
||||
* fb($message) - Just send a message defaults to LOG type
|
||||
* fb($message, $type) - Send a message with a specific type
|
||||
* fb($message, $label, $type) - Send a message with a custom label and type.
|
||||
*
|
||||
* @param mixed $message Message to output. For other parameters see usage above.
|
||||
* @static
|
||||
* @return void
|
||||
**/
|
||||
function fb($message) {
|
||||
$_this = FireCake::getInstance();
|
||||
|
||||
if (headers_sent($filename, $linenum)) {
|
||||
trigger_error(sprintf(__('Headers already sent in %s on line %s. Cannot send log data to FirePHP.', true), $filename, $linenum), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
if (!$_this->_enabled || !$_this->detectClientExtension()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$args = func_get_args();
|
||||
$type = $label = null;
|
||||
switch (count($args)) {
|
||||
case 1:
|
||||
$type = $_this->_levels['log'];
|
||||
break;
|
||||
case 2:
|
||||
$type = $args[1];
|
||||
break;
|
||||
case 3:
|
||||
$type = $args[2];
|
||||
$label = $args[1];
|
||||
break;
|
||||
default:
|
||||
trigger_error(__('Incorrect parameter count for FireCake::fb()', true), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
if (isset($_this->_levels[$type])) {
|
||||
$type = $_this->_levels[$type];
|
||||
} else {
|
||||
$type = $_this->_levels['log'];
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
$skipFinalObjectEncode = false;
|
||||
if ($type == $_this->_levels['trace']) {
|
||||
$trace = debug_backtrace();
|
||||
if (!$trace) {
|
||||
return false;
|
||||
}
|
||||
$message = $_this->_parseTrace($trace, $args[0]);
|
||||
$skipFinalObjectEncode = true;
|
||||
}
|
||||
|
||||
if ($_this->options['includeLineNumbers']) {
|
||||
if (!isset($meta['file']) || !isset($meta['line'])) {
|
||||
$trace = debug_backtrace();
|
||||
for ($i = 0, $len = count($trace); $i < $len ; $i++) {
|
||||
$keySet = (isset($trace[$i]['class']) && isset($trace[$i]['function']));
|
||||
$selfCall = ($keySet && $trace[$i]['class'] == 'FireCake' && in_array($trace[$i]['function'], $_this->_methodIndex));
|
||||
if ($selfCall) {
|
||||
$meta['File'] = isset($trace[$i]['file']) ? Debugger::trimPath($trace[$i]['file']) : '';
|
||||
$meta['Line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$structureIndex = 1;
|
||||
if ($type == $_this->_levels['dump']) {
|
||||
$structureIndex = 2;
|
||||
$_this->_sendHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1');
|
||||
} else {
|
||||
$_this->_sendHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
|
||||
}
|
||||
|
||||
$_this->_sendHeader('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
|
||||
$_this->_sendHeader('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'. $_this->_version);
|
||||
|
||||
if ($type == $_this->_levels['dump']) {
|
||||
$dump = $_this->jsonEncode($message);
|
||||
$msg = '{"' . $label .'":' . $dump .'}';
|
||||
} else {
|
||||
$meta['Type'] = $type;
|
||||
if ($label !== null) {
|
||||
$meta['Label'] = $label;
|
||||
}
|
||||
$msg = '[' . $_this->jsonEncode($meta) . ',' . $_this->jsonEncode($message, $skipFinalObjectEncode).']';
|
||||
}
|
||||
|
||||
$lines = explode("\n", chunk_split($msg, 5000, "\n"));
|
||||
foreach ($lines as $i => $line) {
|
||||
if (empty($line)) {
|
||||
continue;
|
||||
}
|
||||
$header = 'X-Wf-1-' . $structureIndex . '-1-' . $_this->_messageIndex;
|
||||
if (count($lines) > 2) {
|
||||
$first = ($i == 0) ? strlen($msg) : '';
|
||||
$end = ($i < count($lines) - 2) ? '\\' : '';
|
||||
$message = $first . '|' . $line . '|' . $end;
|
||||
$_this->_sendHeader($header, $message);
|
||||
} else {
|
||||
$_this->_sendHeader($header, strlen($line) . '|' . $line . '|');
|
||||
}
|
||||
$_this->_messageIndex++;
|
||||
if ($_this->_messageIndex > 99999) {
|
||||
trigger_error(__('Maximum number (99,999) of messages reached!', true), E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
$_this->_sendHeader('X-Wf-1-Index', $_this->_messageIndex - 1);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Parse a debug backtrace
|
||||
*
|
||||
* @param array $trace Debug backtrace output
|
||||
* @access protected
|
||||
* @return array
|
||||
**/
|
||||
function _parseTrace($trace, $messageName) {
|
||||
$message = array();
|
||||
for ($i = 0, $len = count($trace); $i < $len ; $i++) {
|
||||
$keySet = (isset($trace[$i]['class']) && isset($trace[$i]['function']));
|
||||
$selfCall = ($keySet && $trace[$i]['class'] == 'FireCake');
|
||||
if (!$selfCall) {
|
||||
$message = array(
|
||||
'Class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : '',
|
||||
'Type' => isset($trace[$i]['type']) ? $trace[$i]['type'] : '',
|
||||
'Function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : '',
|
||||
'Message' => $messageName,
|
||||
'File' => isset($trace[$i]['file']) ? Debugger::trimPath($trace[$i]['file']) : '',
|
||||
'Line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : '',
|
||||
'Args' => isset($trace[$i]['args']) ? $this->stringEncode($trace[$i]['args']) : '',
|
||||
'Trace' => $this->_escapeTrace(array_splice($trace, $i + 1))
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
/**
|
||||
* Fix a trace for use in output
|
||||
*
|
||||
* @param mixed $trace Trace to fix
|
||||
* @access protected
|
||||
* @static
|
||||
* @return string
|
||||
**/
|
||||
function _escapeTrace($trace) {
|
||||
for ($i = 0, $len = count($trace); $i < $len; $i++) {
|
||||
if (isset($trace[$i]['file'])) {
|
||||
$trace[$i]['file'] = Debugger::trimPath($trace[$i]['file']);
|
||||
}
|
||||
if (isset($trace[$i]['args'])) {
|
||||
$trace[$i]['args'] = $this->stringEncode($trace[$i]['args']);
|
||||
}
|
||||
}
|
||||
return $trace;
|
||||
}
|
||||
/**
|
||||
* Encode non string objects to string.
|
||||
* Filter out recursion, so no errors are raised by json_encode or $javascript->object()
|
||||
*
|
||||
* @param mixed $object Object or variable to encode to string.
|
||||
* @param int $objectDepth Current Depth in object chains.
|
||||
* @param int $arrayDepth Current Depth in array chains.
|
||||
* @static
|
||||
* @return void
|
||||
**/
|
||||
function stringEncode($object, $objectDepth = 1, $arrayDepth = 1) {
|
||||
$_this = FireCake::getInstance();
|
||||
$return = array();
|
||||
if (is_resource($object)) {
|
||||
return '** ' . (string)$object . '**';
|
||||
}
|
||||
if (is_object($object)) {
|
||||
if ($objectDepth == $_this->options['maxObjectDepth']) {
|
||||
return '** Max Object Depth (' . $_this->options['maxObjectDepth'] . ') **';
|
||||
}
|
||||
foreach ($_this->_encodedObjects as $encoded) {
|
||||
if ($encoded === $object) {
|
||||
return '** Recursion (' . get_class($object) . ') **';
|
||||
}
|
||||
}
|
||||
$_this->_encodedObjects[] = $object;
|
||||
|
||||
$return['__className'] = $class = get_class($object);
|
||||
$properties = (array) $object;
|
||||
foreach ($properties as $name => $property) {
|
||||
$return[$name] = FireCake::stringEncode($property, 1, $objectDepth + 1);
|
||||
}
|
||||
array_pop($_this->_encodedObjects);
|
||||
}
|
||||
if (is_array($object)) {
|
||||
if ($arrayDepth == $_this->options['maxArrayDepth']) {
|
||||
return '** Max Array Depth ('. $_this->options['maxArrayDepth'] . ') **';
|
||||
}
|
||||
foreach ($object as $key => $value) {
|
||||
$return[$key] = FireCake::stringEncode($value, 1, $arrayDepth + 1);
|
||||
}
|
||||
}
|
||||
if (is_string($object) || is_numeric($object) || is_bool($object) || is_null($object)) {
|
||||
return $object;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
/**
|
||||
* Encode an object into JSON
|
||||
*
|
||||
* @param mixed $object Object or array to json encode
|
||||
* @param boolean $doIt
|
||||
* @access public
|
||||
* @static
|
||||
* @return string
|
||||
**/
|
||||
function jsonEncode($object, $skipEncode = false) {
|
||||
$_this = FireCake::getInstance();
|
||||
if (!$skipEncode) {
|
||||
$object = FireCake::stringEncode($object);
|
||||
}
|
||||
|
||||
if (function_exists('json_encode') && $_this->options['useNativeJsonEncode']) {
|
||||
return json_encode($object);
|
||||
} else {
|
||||
return FireCake::_jsonEncode($object);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* jsonEncode Helper method for PHP4 compatibility
|
||||
*
|
||||
* @param mixed $object Something to encode
|
||||
* @access protected
|
||||
* @static
|
||||
* @return string
|
||||
**/
|
||||
function _jsonEncode($object) {
|
||||
if (!class_exists('JavascriptHelper')) {
|
||||
App::import('Helper', 'Javascript');
|
||||
}
|
||||
$javascript = new JavascriptHelper();
|
||||
$javascript->useNative = false;
|
||||
return $javascript->object($object);
|
||||
}
|
||||
/**
|
||||
* Send Headers - write headers.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
**/
|
||||
function _sendHeader($name, $value) {
|
||||
header($name . ': ' . $value);
|
||||
}
|
||||
}
|
||||
?>
|
||||
BIN
site/plugins/debug_kit/vendors/img/cake.icon.png
vendored
Normal file
BIN
site/plugins/debug_kit/vendors/img/cake.icon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
84
site/plugins/debug_kit/vendors/js/jquery_debug_toolbar.js
vendored
Normal file
84
site/plugins/debug_kit/vendors/js/jquery_debug_toolbar.js
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Debug Toolbar Javascript. jQuery 1.2.x compatible.
|
||||
*
|
||||
* Long description here.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
$(document).ready(function(){
|
||||
DebugKit.Toolbar();
|
||||
DebugKit.NeatArray();
|
||||
});
|
||||
|
||||
var DebugKit = {};
|
||||
/**
|
||||
* Create all behaviors for neat array elements
|
||||
*
|
||||
*/
|
||||
DebugKit.NeatArray = function() {
|
||||
$('.neat-array').find('li:has(ul)').toggle(
|
||||
function() {
|
||||
$(this).toggleClass('expanded').removeClass('collapsed').find('ul:first').show();
|
||||
},
|
||||
function() {
|
||||
$(this).toggleClass('expanded').addClass('collapsed').find('ul:first').hide();
|
||||
}
|
||||
).addClass('expandable').addClass('collapsed').find('ul').hide();
|
||||
}
|
||||
/**
|
||||
* Add behavior for toolbar buttons
|
||||
*
|
||||
*/
|
||||
DebugKit.Toolbar = function() {
|
||||
var tabCollection = $('#debug-kit-toolbar li > div');
|
||||
|
||||
$('#debug-kit-toolbar .panel-tab > a').click(
|
||||
function(e){
|
||||
e.preventDefault();
|
||||
var targetPanel = $(this.hash + '-tab');
|
||||
if (targetPanel.hasClass('active')) {
|
||||
tabCollection.hide().removeClass('active');
|
||||
} else {
|
||||
tabCollection
|
||||
.hide().removeClass('active')
|
||||
.filter(this.hash + '-tab').show().addClass('active');
|
||||
}
|
||||
$('#debug-kit-toolbar .panel-tab > a').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
}
|
||||
);
|
||||
|
||||
//enable hiding of toolbar.
|
||||
var panelButtons = $('#debug-kit-toolbar .panel-tab:not(.panel-tab.icon)');
|
||||
$('#debug-kit-toolbar #hide-toolbar').toggle(
|
||||
function() {
|
||||
panelButtons.hide();
|
||||
},
|
||||
function() {
|
||||
panelButtons.show();
|
||||
}
|
||||
);
|
||||
}
|
||||
})(jQuery);
|
||||
212
site/plugins/debug_kit/vendors/js/js_debug_toolbar.js
vendored
Normal file
212
site/plugins/debug_kit/vendors/js/js_debug_toolbar.js
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Debug Toolbar Javascript.
|
||||
*
|
||||
* Long description here.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
var DebugKit = function(id) {
|
||||
var undefined,
|
||||
elements = {},
|
||||
panels = {},
|
||||
hidden = false;
|
||||
|
||||
this.initialize = function(id) {
|
||||
elements.toolbar = document.getElementById(id || 'debug-kit-toolbar');
|
||||
|
||||
if (elements.toolbar === undefined) {
|
||||
throw new Exception('Toolbar not found, make sure you loaded it.');
|
||||
}
|
||||
|
||||
for (var i in elements.toolbar.childNodes) {
|
||||
var element = elements.toolbar.childNodes[i];
|
||||
if (element.nodeName && element.id === 'panel-tabs') {
|
||||
elements.panel = element;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in elements.panel.childNodes) {
|
||||
var element = elements.panel.childNodes[i];
|
||||
if (element.className && element.className.match(/panel-tab/)) {
|
||||
this.addPanel(element);
|
||||
}
|
||||
}
|
||||
|
||||
var lists = document.getElementsByTagName('ul'), index = 0;
|
||||
while (lists[index] !== undefined) {
|
||||
var element = lists[index];
|
||||
if (element.className && element.className.match(/neat-array/)) {
|
||||
neatArray(element);
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add a panel to the toolbar
|
||||
*/
|
||||
this.addPanel = function(tab, callback) {
|
||||
if (!tab.nodeName || tab.nodeName.toUpperCase() !== 'LI') {
|
||||
throw new Exception('Toolbar not found, make sure you loaded it.');
|
||||
}
|
||||
var panel = {
|
||||
id : false,
|
||||
element : tab,
|
||||
callback : callback,
|
||||
button : undefined,
|
||||
content : undefined,
|
||||
active : false
|
||||
};
|
||||
for (var i in tab.childNodes) {
|
||||
var element = tab.childNodes[i],
|
||||
tag = element.nodeName? element.nodeName.toUpperCase(): false;
|
||||
if (tag === 'A') {
|
||||
panel.id = element.hash.replace(/^#/, '');
|
||||
panel.button = element;
|
||||
} else if (tag === 'DIV') {
|
||||
panel.content = element;
|
||||
}
|
||||
}
|
||||
if (!panel.id) {
|
||||
throw new Exception('invalid element');
|
||||
}
|
||||
|
||||
if (panel.button.id && panel.button.id === 'hide-toolbar') {
|
||||
panel.callback = this.toggleToolbar;
|
||||
}
|
||||
|
||||
if (panel.callback !== undefined) {
|
||||
panel.button.onclick = function() { return panel.callback(); };
|
||||
} else {
|
||||
panel.button.onclick = function() { return window.DebugKit.togglePanel(panel.id); };
|
||||
}
|
||||
|
||||
panels[panel.id] = panel;
|
||||
return panel.id;
|
||||
};
|
||||
/**
|
||||
* Hide/show the toolbar (minimize cake)
|
||||
*/
|
||||
this.toggleToolbar = function() {
|
||||
for (var i in panels) {
|
||||
var panel = panels[i],
|
||||
display = hidden? 'block': 'none';
|
||||
if (panel.content !== undefined) {
|
||||
panel.element.style.display = display;
|
||||
}
|
||||
}
|
||||
hidden = !hidden;
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
* Toggle a panel
|
||||
*/
|
||||
this.togglePanel = function(id) {
|
||||
if (panels[id] && panels[id].active) {
|
||||
this.deactivatePanel(true);
|
||||
} else {
|
||||
this.deactivatePanel(true);
|
||||
this.activatePanel(id);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Make a panel active.
|
||||
*/
|
||||
this.activatePanel = function(id, unique) {
|
||||
if (panels[id] !== undefined && !panels[id].active) {
|
||||
var panel = panels[id];
|
||||
this.deactivatePanel(true);
|
||||
if (panel.content !== undefined) {
|
||||
panel.content.style.display = 'block';
|
||||
}
|
||||
panel.button.className = panel.button.className.replace(/^(.*)$/, '$1 active');
|
||||
panel.active = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* Deactivate a panel. use true to hide all panels.
|
||||
*/
|
||||
this.deactivatePanel = function(id) {
|
||||
if (id === true) {
|
||||
for (var i in panels) {
|
||||
this.deactivatePanel(i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (panels[id] !== undefined && panels[id].active) {
|
||||
var panel = panels[id];
|
||||
if (panel.content !== undefined) {
|
||||
panel.content.style.display = 'none';
|
||||
}
|
||||
panel.button.className = panel.button.className.replace(/ ?(active) ?/, '');
|
||||
panel.active = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* Add neat array functionality.
|
||||
*/
|
||||
function neatArray(list) {
|
||||
if (!list.className.match(/depth-0/)) {
|
||||
var item = list.parentNode;
|
||||
list.style.display = 'none';
|
||||
item.className = (item.className || '').replace(/^(.*)$/, '$1 expandable collapsed');
|
||||
item.onclick = function(event) {
|
||||
//var element = (event === undefined)? this: event.target;
|
||||
var element = this,
|
||||
event = event || window.event,
|
||||
act = Boolean(item === element),
|
||||
hide = Boolean(list.style.display === 'block');
|
||||
if (act && hide) {
|
||||
list.style.display = 'none';
|
||||
item.className = item.className.replace(/expanded|$/, 'collapsed');
|
||||
} else if (act) {
|
||||
list.style.display = 'block';
|
||||
item.className = item.className.replace('collapsed', 'expanded');
|
||||
}
|
||||
|
||||
if (event.cancelBubble !== undefined) {
|
||||
event.cancelBubble = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.initialize(id);
|
||||
}
|
||||
|
||||
DebugKit.install = function() {
|
||||
var initializer = window.onload || function() {};
|
||||
window.onload = function() {
|
||||
initializer();
|
||||
// makes DebugKit a singletone instance
|
||||
window.DebugKit = new DebugKit();
|
||||
}
|
||||
}
|
||||
|
||||
DebugKit.install();
|
||||
95
site/plugins/debug_kit/vendors/js/mootools_debug_toolbar.js
vendored
Normal file
95
site/plugins/debug_kit/vendors/js/mootools_debug_toolbar.js
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Debug Toolbar Javascript. Mootools 1.2 compatible.
|
||||
*
|
||||
* Requires Class, Event, Element, and Selectors
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
window.addEvent('domready', function() {
|
||||
new DebugKit();
|
||||
});
|
||||
var DebugKit = new Class({
|
||||
initialize : function() {
|
||||
this.neatArray();
|
||||
this.toolbar();
|
||||
},
|
||||
/**
|
||||
* Create all behaviors for neat array elements
|
||||
*/
|
||||
neatArray : function() {
|
||||
$$('#debug-kit-toolbar .neat-array li').each(function(listItem) {
|
||||
var subUl = listItem.getElement('ul');
|
||||
if (subUl) {
|
||||
listItem.addClass('expandable').addClass('collapsed');
|
||||
subUl.setStyle('display', 'none').set('state', 'closed');
|
||||
listItem.addEvent('click', function(event) {
|
||||
event.stop();
|
||||
this.toggleClass('expanded').toggleClass('collapsed');
|
||||
if (subUl.get('state') == 'closed') {
|
||||
subUl.setStyle('display', 'block').set('state', 'open');
|
||||
} else {
|
||||
subUl.setStyle('display', 'none').set('state', 'closed');
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Add behavior for toolbar buttons
|
||||
*/
|
||||
toolbar : function() {
|
||||
var tabCollection = $$('#debug-kit-toolbar li > div');
|
||||
|
||||
$$('#debug-kit-toolbar .panel-tab > a').addEvent('click', function(event) {
|
||||
event.stop();
|
||||
var buttonId = this.hash.substring(1, this.hash.length) + '-tab';
|
||||
var targetPanel = $(buttonId);
|
||||
if (!targetPanel) return;
|
||||
$$('#debug-kit-toolbar .panel-tab > a').removeClass('active');
|
||||
if (targetPanel.hasClass('active')) {
|
||||
tabCollection.removeClass('active').setStyle('display', 'none');
|
||||
} else {
|
||||
tabCollection.setStyle('display', 'none').removeClass('active');
|
||||
targetPanel.addClass('active').setStyle('display', 'block');
|
||||
this.addClass('active');
|
||||
}
|
||||
});
|
||||
|
||||
//enable hiding of toolbar.
|
||||
var panelButtons = $$('#debug-kit-toolbar .panel-tab:not(.panel-tab.icon)');
|
||||
var toolbarHide = $('hide-toolbar').set('state', 'open');
|
||||
toolbarHide.addEvent('click', function(event) {
|
||||
event.stop();
|
||||
var state = this.get('state');
|
||||
if (state == 'open') {
|
||||
panelButtons.setStyle('display', 'none');
|
||||
this.set('state', 'closed')
|
||||
} else {
|
||||
panelButtons.setStyle('display');
|
||||
this.set('state', 'open');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
95
site/plugins/debug_kit/vendors/js/prototype_debug_toolbar.js
vendored
Normal file
95
site/plugins/debug_kit/vendors/js/prototype_debug_toolbar.js
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Debug Toolbar Javascript. Prototype 1.6.x compatible.
|
||||
*
|
||||
* Long description here.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
document.observe('dom:loaded', function() {
|
||||
new DebugKit();
|
||||
});
|
||||
|
||||
var DebugKit = Class.create({
|
||||
|
||||
initialize: function(){
|
||||
this.toolbar();
|
||||
this.neatArray();
|
||||
},
|
||||
|
||||
toolbar: function(){
|
||||
var tabCollection = $('debug-kit-toolbar').select('li > div');
|
||||
|
||||
$('debug-kit-toolbar').select('.panel-tab > a').invoke('observe', 'click', function(e){
|
||||
e.stop();
|
||||
var targetPanel = $(e.element().hash.replace(/#/, '') + '-tab');
|
||||
if (targetPanel.hasClassName('active')) {
|
||||
tabCollection.each(function(ele){
|
||||
ele.hide().removeClassName('active');
|
||||
});
|
||||
} else {
|
||||
tabCollection.each(function(ele){
|
||||
ele.hide().removeClassName('active');
|
||||
if (targetPanel.id == ele.id) {
|
||||
ele.setStyle({display: 'block'}).addClassName('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
$('debug-kit-toolbar').select('.panel-tab > a').invoke('removeClassName', 'active');
|
||||
e.element().addClassName('active');
|
||||
});
|
||||
|
||||
// enable hiding of toolbar.
|
||||
var panelButtons = $('debug-kit-toolbar').select('.panel-tab');
|
||||
$('hide-toolbar').observe('click', function(eve){
|
||||
eve.stop();
|
||||
panelButtons.each(function(panel){
|
||||
if (!panel.hasClassName('icon')) {
|
||||
panel.toggle();
|
||||
};
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Create all behaviors for neat array elements
|
||||
*/
|
||||
neatArray: function() {
|
||||
$('debug-kit-toolbar').select('.neat-array li').each(function(ele){
|
||||
var sub = ele.select('ul');
|
||||
if (sub.length > 0) {
|
||||
ele.addClassName('collapsed').addClassName('expandable');
|
||||
sub.invoke('hide');
|
||||
ele.observe('click', function(eve){
|
||||
if (eve.element() == ele || eve.element().up() == ele) {
|
||||
if (sub.length > 0) {
|
||||
ele.toggleClassName('expanded').toggleClassName('collapsed');
|
||||
sub[0].toggle();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
126
site/plugins/debug_kit/vendors/js/yui_debug_toolbar.js
vendored
Normal file
126
site/plugins/debug_kit/vendors/js/yui_debug_toolbar.js
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Debug Toolbar Javascript. YUI 2.6 compatible.
|
||||
*
|
||||
* Long description here.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
YAHOO.namespace('CakePHP.DebugKit');
|
||||
|
||||
YAHOO.CakePHP.DebugKit = function() {
|
||||
|
||||
var Event = YAHOO.util.Event;
|
||||
var Dom = YAHOO.util.Dom;
|
||||
var Selector = YAHOO.util.Selector;
|
||||
|
||||
|
||||
var toggle = function(el) {
|
||||
Dom.setStyle(el, 'display', ((Dom.getStyle(el, 'display') == 'none') ? '' : 'none'));
|
||||
};
|
||||
|
||||
var toggleClass = function(element, className) {
|
||||
(Dom.hasClass(element, className)) ? Dom.removeClass(element, className) : Dom.addClass(element, className);
|
||||
};
|
||||
|
||||
|
||||
|
||||
var toolbar = function() {
|
||||
var tabCollection = Selector.query('#debug-kit-toolbar li > div');
|
||||
|
||||
Dom.batch(Selector.query('#debug-kit-toolbar .panel-tab > a'), function(el) {
|
||||
Event.on(el, 'click', function(ev) {
|
||||
Event.preventDefault(ev);
|
||||
targetPanel =Dom.get(el.hash.replace(/#/, '') + '-tab');
|
||||
|
||||
if (Dom.hasClass(targetPanel, 'active')) {
|
||||
Dom.batch(tabCollection, function(ele) {
|
||||
toggle(ele);
|
||||
Dom.removeClass(ele, 'active');
|
||||
Dom.setStyle(ele, 'display', '');
|
||||
});
|
||||
} else {
|
||||
Dom.batch(tabCollection, function(ele) {
|
||||
toggle(ele);
|
||||
Dom.removeClass(ele, 'active');
|
||||
|
||||
if (targetPanel && targetPanel.id == ele.id) {
|
||||
Dom.setStyle(ele, 'display', 'block');
|
||||
Dom.addClass(ele, 'active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Dom.removeClass(Selector.query('#debug-kit-toolbar .panel-tab > a'), 'active');
|
||||
Dom.addClass(el, 'active');
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
var neatArray = function() {
|
||||
nodes = Selector.query('#debug-kit-toolbar .panel-content > ul.neat-array li > ul');
|
||||
|
||||
if (nodes.length > 0) {
|
||||
Dom.batch(nodes, function(el) {
|
||||
|
||||
var parent = el.parentNode;
|
||||
|
||||
Dom.addClass(parent, 'collapsed');
|
||||
Dom.addClass(parent, 'expandable');
|
||||
toggle(nodes);
|
||||
|
||||
Event.on(parent, 'click', function(ev) {
|
||||
sub = Selector.query('ul', parent);
|
||||
toggleClass(parent, 'expanded');
|
||||
toggleClass(parent, 'collapsed');
|
||||
toggle(sub);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var panelButtons = function() {
|
||||
Event.on('hide-toolbar', 'click', function(ev) {
|
||||
Event.preventDefault(ev);
|
||||
|
||||
Dom.getElementsByClassName('panel-tab', 'li', 'debug-kit-toolbar', function (el) {
|
||||
if (!Dom.hasClass(el, 'icon')) {
|
||||
toggle(el);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
initialize: function() {
|
||||
neatArray();
|
||||
toolbar();
|
||||
panelButtons();
|
||||
}
|
||||
};
|
||||
}(); // Execute annonymous closure & return results
|
||||
|
||||
YAHOO.util.Event.onDOMReady(YAHOO.CakePHP.DebugKit.initialize);
|
||||
79
site/plugins/debug_kit/vendors/shells/benchmark.php
vendored
Normal file
79
site/plugins/debug_kit/vendors/shells/benchmark.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Benchmark Shell.
|
||||
*
|
||||
* Provides basic benchmarking of application requests
|
||||
* functionally similar to Apache AB
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.debug_kit.vendors.shells
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
class BenchmarkShell extends Shell {
|
||||
function main() {
|
||||
$url = $this->args[0];
|
||||
$this->out(sprintf('-> Testing %s', $url));
|
||||
|
||||
$n = 100;
|
||||
$t = $i = 0;
|
||||
if (isset($this->params['n'])) {
|
||||
$n = $this->params['n'];
|
||||
}
|
||||
if (isset($this->params['t'])) {
|
||||
$t = $this->params['t'];
|
||||
}
|
||||
$start = microtime(true);
|
||||
while (true) {
|
||||
if ($t && $t <= floor(microtime(true) - $start)) {
|
||||
break;
|
||||
}
|
||||
if ($n <= $i) {
|
||||
break;
|
||||
}
|
||||
file_get_contents($url);
|
||||
$i++;
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
$this->out('Total Requests made: ' . $i);
|
||||
$this->out('Total Time elapsed: ' . $duration . '(s)');
|
||||
$this->out(round($n / $duration, 2).' req/sec');
|
||||
}
|
||||
|
||||
function help() {
|
||||
$out = <<<EOL
|
||||
DebugKit Benchmark Shell
|
||||
|
||||
Test a fully qualified url to get avg requests per second.
|
||||
By default it does 100 requests to the provided url.
|
||||
|
||||
Use:
|
||||
cake benchmark [params] [url]
|
||||
|
||||
Params
|
||||
-n The maximum number of iterations to do.
|
||||
|
||||
-t The maximum time to take. If a single request takes more
|
||||
than this time. Only one request will be made.
|
||||
EOL;
|
||||
$this->out($out);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user