getDebugInformation();
$NL = "\n";
$logHTML = '' . $NL . $NL;
// DB PROFILER
function log_iconv(&$array)
{
foreach ($array as $key => &$element) {
if (is_string($element)) {
$from = mb_detect_encoding($element, mb_detect_order(), true);
if ($from) {
$element = htmlspecialchars(iconv($from, 'UTF-8', $element));
}
}
}
return true;
}
$logHTML .= '
' . $NL;
$config = Zend_Registry::get('config');
if ($config->database->params->profiler) {
// Zend_Db
$db = Qs_Db::getInstance($config);
$profiler = $db->getProfiler();
$list = $profiler->getQueryProfiles();
$profilerHtml = '';
if (is_array($list) && !empty($list)) {
$maxQueryDuration = defined('MAX_QUERY_DURATION') && MAX_QUERY_DURATION ? MAX_QUERY_DURATION : 0.5;
$countHardQueries = 0;
$profilerHtml .= '
';
foreach ($list as $k => $v) {
/** @var $v Zend_Db_Profiler_Query */
$params = $v->getQueryParams();
$color = ($k % 2 == 0) ? 'white' : '#EFEFEF';
if ($v->getElapsedSecs() >= $maxQueryDuration) {
$countHardQueries++;
$color = '#FFAAAA';
}
$profilerHtml .= '';
$profilerHtml .= '' . ($k + 1) . ' | ';
$profilerHtml .= '' . number_format($v->getElapsedSecs(), 3, '.', ',') . ' sec | ';
$profilerHtml .= '';
$profilerHtml .= '';
$profilerHtml .= ' +'
. Qs_SqlFormatter::getHighlightedCode($v->getQuery())
. ' ';
$profilerHtml .= '';
if (!empty($params)) {
log_iconv($params);
$profilerHtml .= ' ' . $NL
. 'params' . $NL
. '' . $NL
. ' ' . $NL . print_r($params, true) . ' ' . $NL
. ' ' . $NL;
}
$profilerHtml .= ' |
' . $NL;
}
$profilerHtml .= '
';
$logHTML .= '
'
. '
' . $NL
. '
'
. 'DB PROFILER' . $NL
. '
' . $NL
. ($countHardQueries ? 'Hard Queries: ' . $countHardQueries . '
' : '')
. 'Total Number of Queries: ' . $profiler->getTotalNumQueries() . '
' . $NL
. 'Total Elapsed Seconds:
' . number_format($profiler->getTotalElapsedSecs(), 4, '.', '')
. '' . $NL
. '
' . $NL
. $profilerHtml . '
' . $NL . '
' . $NL;
}
}
if (is_array($debugList) && !empty($debugList)) {
$logHTML .= '
';
$logHTML .= '
'
. 'DEBUG INFO';
$logHTML .= '
';
foreach ($debugList as $k => $v) {
$logHTML .= ($k + 1) . ') ' . $v['added'] . ': ' . iconv('UTF-8', 'UTF-8', $v['message']) . ' ';
$logHTML .= 'in the ' . $v['file'] . ' line ' . $v['line'] . '';
$logHTML .= '
';
}
$logHTML .= '
';
$logHTML .= '
';
}
// page items started
if (Zend_Registry::isRegistered('_pageItems')) {
$tableColumns = array(
array('name' => 'id', 'title' => 'ID', 'type' => 'text'),
array('name' => 'groupName', 'title' => 'Group', 'type' => 'text'),
array('name' => 'type', 'title' => 'Type', 'type' => 'text'),
array('name' => 'executed', 'title' => 'Executed', 'type' => 'bool'),
array('name' => 'config', 'title' => 'Config', 'type' => 'array'),
);
$pageItems = (array) Zend_Registry::get('_pageItems');
$logHTML .= '
' . $NL;
$logHTML .= 'PAGE ITEMS' . $NL;
$logHTML .= '
' . $NL;
$logHTML .= '';
foreach ($tableColumns as $column) {
$logHTML .= '' . htmlspecialchars($column['title']) . ' | ';
}
$logHTML .= '
' . $NL;
if (!empty($pageItems)) {
foreach ($pageItems as $i) {
$logHTML .= '' . $NL;
foreach ($tableColumns as $column) {
$value = ' ';
switch ($column['type']) {
case 'bool':
$value = (isset($i[$column['name']]) && $i[$column['name']]) ? 'Yes' : 'No';
break;
case 'array':
$value = (isset($i[$column['name']])) ? json_encode($i[$column['name']]) : ' ';
break;
case 'text':
// break omitted
default:
$value = (isset($i[$column['name']])) ? $i[$column['name']] : ' ';
}
$logHTML .= '' . htmlspecialchars($value) . ' | ';
}
$logHTML .= '
' . $NL;
}
} else {
$logHTML .= 'No items found |
' . $NL;
}
$logHTML .= '
' . $NL;
}
// page items finished
// side blocks started
if (Zend_Registry::isRegistered('_pageSideBlocks')) {
$sideBlocks = (array) Zend_Registry::get('_pageSideBlocks');
$logHTML .= '
' . $NL;
$logHTML .= 'SIDE BLOCKS' . $NL;
$logHTML .= '
' . $NL;
$logHTML .= 'ID | Type | Title | Pages | Link Type | Link URL |
' . $NL;
if (!empty($sideBlocks)) {
foreach ($sideBlocks as $b) {
$logHTML .= ''
. '' . $b['id'] . ' | '
. '' . ucfirst($b['blockType']) . ' | '
. '' . htmlspecialchars($b['title']) . ' | '
. '' . ucfirst($b['pageType']) . ' | '
. '' . ucfirst($b['linkType']) . ' | '
. '' . (($b['linkType'] == 'none') ? ' ' : htmlspecialchars($b['linkUrl'])) . ' | '
. '
' . $NL;
}
} else {
$logHTML .= 'No blocks found |
' . $NL;
}
$logHTML .= '
' . $NL;
}
// side blocks finished
$logHTML .= '
'
. '
SCRIPT DURATION: ' . number_format((microtime(true) - SCRIPT_START), 4, '.', '') . '
';
$logHTML .= '
'; // end of qsf-debug-container
return $logHTML;