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:
79
site/plugins/debug_kit/views/helpers/fire_php_toolbar.php
Normal file
79
site/plugins/debug_kit/views/helpers/fire_php_toolbar.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* FirePHP Toolbar Helper
|
||||
*
|
||||
* Injects the toolbar elements into non-HTML layouts via FireCake.
|
||||
*
|
||||
* 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.views.helpers
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('helper', 'DebugKit.Toolbar');
|
||||
App::import('Vendor', 'DebugKit.FireCake');
|
||||
|
||||
class FirePhpToolbarHelper extends ToolbarHelper {
|
||||
/**
|
||||
* send method
|
||||
*
|
||||
* @return void
|
||||
* @access protected
|
||||
*/
|
||||
function _send() {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$view->element('debug_toolbar', array('plugin' => 'debug_kit', 'disableTimer' => true));
|
||||
Configure::write('debug', 1);
|
||||
}
|
||||
/**
|
||||
* makeNeatArray.
|
||||
*
|
||||
* wraps FireCake::dump() allowing panel elements to continue functioning
|
||||
*
|
||||
* @param string $values
|
||||
* @return void
|
||||
*/
|
||||
function makeNeatArray($values) {
|
||||
FireCake::info($values);
|
||||
}
|
||||
/**
|
||||
* Create a simple message
|
||||
*
|
||||
* @param string $label Label of message
|
||||
* @param string $message Message content
|
||||
* @return void
|
||||
*/
|
||||
function message($label, $message) {
|
||||
FireCake::log($message, $label);
|
||||
}
|
||||
/**
|
||||
* Generate a table with FireCake
|
||||
*
|
||||
* @param array $rows Rows to print
|
||||
* @param array $headers Headers for table
|
||||
* @param array $options Additional options and params
|
||||
* @return void
|
||||
*/
|
||||
function table($rows, $headers, $options = array()) {
|
||||
$title = $headers[0];
|
||||
if (isset($options['title'])) {
|
||||
$title = $options['title'];
|
||||
}
|
||||
array_unshift($rows, $headers);
|
||||
FireCake::table($title, $rows);
|
||||
}
|
||||
}
|
||||
?>
|
||||
150
site/plugins/debug_kit/views/helpers/html_toolbar.php
Normal file
150
site/plugins/debug_kit/views/helpers/html_toolbar.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Html Toolbar Helper
|
||||
*
|
||||
* Injects the toolbar elements into HTML layouts.
|
||||
* Contains helper methods for
|
||||
*
|
||||
* 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.views.helpers
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('helper', 'DebugKit.Toolbar');
|
||||
|
||||
class HtmlToolbarHelper extends ToolbarHelper {
|
||||
/**
|
||||
* helpers property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $helpers = array('Html', 'Javascript');
|
||||
/**
|
||||
* settings property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $settings = array('format' => 'html');
|
||||
/**
|
||||
* Recursively goes through an array and makes neat HTML out of it.
|
||||
*
|
||||
* @param mixed $values Array to make pretty.
|
||||
* @param int $openDepth Depth to add open class
|
||||
* @param int $currentDepth current depth.
|
||||
* @return string
|
||||
**/
|
||||
function makeNeatArray($values, $openDepth = 0, $currentDepth = 0) {
|
||||
$className ="neat-array depth-$currentDepth";
|
||||
if ($openDepth > $currentDepth) {
|
||||
$className .= ' expanded';
|
||||
}
|
||||
$nextDepth = $currentDepth + 1;
|
||||
$out = "<ul class=\"$className\">";
|
||||
if (!is_array($values)) {
|
||||
if (is_bool($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
if (is_null($values)) {
|
||||
$values = array(null);
|
||||
}
|
||||
}
|
||||
foreach ($values as $key => $value) {
|
||||
$out .= '<li><strong>' . $key . '</strong>';
|
||||
if ($value === null) {
|
||||
$value = '(null)';
|
||||
}
|
||||
if ($value === false) {
|
||||
$value = '(false)';
|
||||
}
|
||||
if ($value === true) {
|
||||
$value = '(true)';
|
||||
}
|
||||
if (empty($value) && $value != 0) {
|
||||
$value = '(empty)';
|
||||
}
|
||||
|
||||
if (is_object($value)) {
|
||||
$value = Set::reverse($value, true);
|
||||
}
|
||||
|
||||
if (is_array($value) && !empty($value)) {
|
||||
$out .= $this->makeNeatArray($value, $openDepth, $nextDepth);
|
||||
} else {
|
||||
$out .= $value;
|
||||
}
|
||||
$out .= '</li>';
|
||||
}
|
||||
$out .= '</ul>';
|
||||
return $out;
|
||||
}
|
||||
/**
|
||||
* Create an HTML message
|
||||
*
|
||||
* @param string $label label content
|
||||
* @param string $message message content
|
||||
* @return string
|
||||
*/
|
||||
function message($label, $message) {
|
||||
return sprintf('<p><strong>%s</strong> %s</p>', $label, $message);
|
||||
}
|
||||
/**
|
||||
* Create a table.
|
||||
*
|
||||
* @param array $rows Rows to make.
|
||||
* @param array $headers Optional header row.
|
||||
* @return string
|
||||
*/
|
||||
function table($rows, $headers = array()) {
|
||||
$out = '<table class="debug-table">';
|
||||
if (!empty($headers)) {
|
||||
$out .= $this->Html->tableHeaders($headers);
|
||||
}
|
||||
$out .= $this->Html->tableCells($rows, array('class' => 'odd'), array('class' => 'even'));
|
||||
$out .= '</table>';
|
||||
return $out;
|
||||
}
|
||||
/**
|
||||
* send method
|
||||
*
|
||||
* @return void
|
||||
* @access protected
|
||||
*/
|
||||
function _send() {
|
||||
if (Configure::read('debug') == 0) {
|
||||
return;
|
||||
}
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$head = $this->Html->css('/debug_kit/css/debug_toolbar');
|
||||
if (isset($view->viewVars['debugToolbarJavascript'])) {
|
||||
foreach ($view->viewVars['debugToolbarJavascript'] as $script) {
|
||||
if ($script) {
|
||||
$head .= $this->Javascript->link($script);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (preg_match('#</head>#', $view->output)) {
|
||||
$view->output = preg_replace('#</head>#', $head . "\n</head>", $view->output, 1);
|
||||
}
|
||||
$toolbar = $view->element('debug_toolbar', array('plugin' => 'debug_kit', 'disableTimer' => true));
|
||||
if (preg_match('#</body>#', $view->output)) {
|
||||
$view->output = preg_replace('#</body>#', $toolbar . "\n</body>", $view->output, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
90
site/plugins/debug_kit/views/helpers/toolbar.php
Normal file
90
site/plugins/debug_kit/views/helpers/toolbar.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Abstract Toolbar helper. Provides Base methods for content
|
||||
* specific debug toolbar helpers. Acts as a facade for other toolbars helpers as well.
|
||||
*
|
||||
* helps with development.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
*
|
||||
* 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.views.helpers
|
||||
* @since v 1.0
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('Vendor', 'DebugKit.DebugKitDebugger');
|
||||
|
||||
class ToolbarHelper extends AppHelper {
|
||||
/**
|
||||
* settings property to be overloaded. Subclasses should specify a format
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $settings = array();
|
||||
/**
|
||||
* Construct the helper and make the backend helper.
|
||||
*
|
||||
* @param string $options
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct($options = array()) {
|
||||
$this->_myName = strtolower(get_class($this));
|
||||
if ($this->_myName !== 'toolbarhelper') {
|
||||
return;
|
||||
}
|
||||
if (!isset($options['output'])) {
|
||||
$options['output'] = 'DebugKit.HtmlToolbar';
|
||||
}
|
||||
App::import('Helper', $options['output']);
|
||||
$className = $options['output'];
|
||||
if (strpos($options['output'], '.') !== false) {
|
||||
list($plugin, $className) = explode('.', $options['output']);
|
||||
}
|
||||
$this->_backEndClassName = $className;
|
||||
$this->helpers = array($options['output']);
|
||||
}
|
||||
|
||||
/**
|
||||
* call__
|
||||
*
|
||||
* Allows method calls on backend helper
|
||||
*
|
||||
* @param string $method
|
||||
* @param mixed $params
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function call__($method, $params) {
|
||||
if (method_exists($this->{$this->_backEndClassName}, $method)) {
|
||||
return $this->{$this->_backEndClassName}->dispatchMethod($method, $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* postRender method
|
||||
*
|
||||
* Custom Callback defined in DebugView to allow helpers to modify
|
||||
* View output after all rendering is complete.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function postRender() {
|
||||
$this->_send();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user