'html', 'forceEnable' => false);
/**
* Recursively goes through an array and makes neat HTML out of it.
*
* @param mixed $values Array to make pretty.
* @param integer $openDepth Depth to add open class
* @param integer $currentDepth current depth.
* @param boolean $doubleEncode
* @return string
*/
public function makeNeatArray($values, $openDepth = 0, $currentDepth = 0, $doubleEncode = false) {
static $printedObjects = null;
if ($currentDepth === 0) {
$printedObjects = new SplObjectStorage();
}
$className = "neat-array depth-$currentDepth";
if ($openDepth > $currentDepth) {
$className .= ' expanded';
}
$nextDepth = $currentDepth + 1;
$out = "
";
if (!is_array($values)) {
if (is_bool($values)) {
$values = array($values);
}
if ($values === null) {
$values = array(null);
}
}
if (empty($values)) {
$values[] = '(empty)';
}
foreach ($values as $key => $value) {
$out .= '- ' . h($key, $doubleEncode) . '';
if (is_array($value) && count($value) > 0) {
$out .= '(array)';
} elseif (is_object($value)) {
$out .= '(object)';
}
if ($value === null) {
$value = '(null)';
}
if ($value === false) {
$value = '(false)';
}
if ($value === true) {
$value = '(true)';
}
if (empty($value) && $value != 0) {
$value = '(empty)';
}
if ($value instanceof Closure) {
$value = 'function';
}
$isObject = is_object($value);
if ($isObject && $printedObjects->contains($value)) {
$isObject = false;
$value = ' - recursion';
}
if ($isObject) {
$printedObjects->attach($value);
}
if (
(
$value instanceof ArrayAccess ||
$value instanceof Iterator ||
is_array($value) ||
$isObject
) && !empty($value)
) {
$out .= $this->makeNeatArray($value, $openDepth, $nextDepth, $doubleEncode);
} else {
$out .= h($value, $doubleEncode);
}
$out .= '
';
}
$out .= '
';
return $out;
}
/**
* Create an HTML message
*
* @param string $label label content
* @param string $message message content
* @return string
*/
public function message($label, $message) {
return sprintf('%s %s
', $label, $message);
}
/**
* Start a panel.
* Make a link and anchor.
*
* @param $title
* @param $anchor
* @return string
*/
public function panelStart($title, $anchor) {
$link = $this->Html->link($title, '#' . $anchor);
return $link;
}
/**
* Create a table.
*
* @param array $rows Rows to make.
* @param array $headers Optional header row.
* @return string
*/
public function table($rows, $headers = array()) {
$out = '';
if (!empty($headers)) {
$out .= $this->Html->tableHeaders($headers);
}
$out .= $this->Html->tableCells($rows, array('class' => 'odd'), array('class' => 'even'), false, false);
$out .= '
';
return $out;
}
/**
* Send method
*
* @return void
*/
public function send() {
if (!$this->settings['forceEnable'] && Configure::read('debug') == 0) {
return;
}
$view = $this->_View;
$head = '';
if (isset($view->viewVars['debugToolbarCss']) && !empty($view->viewVars['debugToolbarCss'])) {
$head .= $this->Html->css($view->viewVars['debugToolbarCss']);
}
$js = sprintf('window.DEBUGKIT_JQUERY_URL = "%s";', $this->webroot('/debug_kit/js/jquery.js'));
$head .= $this->Html->scriptBlock($js);
if (isset($view->viewVars['debugToolbarJavascript'])) {
foreach ($view->viewVars['debugToolbarJavascript'] as $script) {
if ($script) {
$head .= $this->Html->script($script);
}
}
}
$search = '';
$pos = strpos($view->output, $search);
if ($pos !== false) {
$view->output = substr_replace($view->output, $head . "\n", $pos, strlen($search));
}
$toolbar = $view->element('debug_toolbar', array('disableTimer' => true), array('plugin' => 'DebugKit'));
$search = '