本文整理汇总了PHP中JError::renderBacktrace方法的典型用法代码示例。如果您正苦于以下问题:PHP JError::renderBacktrace方法的具体用法?PHP JError::renderBacktrace怎么用?PHP JError::renderBacktrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JError
的用法示例。
在下文中一共展示了JError::renderBacktrace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __destruct
/**
* Show the debug info
*
*/
function __destruct()
{
global $_PROFILER;
// Do not render if debugging is not enabled
if (!JDEBUG) {
return;
}
if (!$_PROFILER instanceof JProfiler) {
return;
}
// Load the language
$this->loadLanguage();
// Capture output
$contents = ob_get_contents();
ob_end_clean();
// No debug for Safari and Chrome redirection
if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false && substr($contents, 0, 50) == '<html><head><meta http-equiv="refresh" content="0;') {
echo $contents;
return;
}
$document = JFactory::getDocument();
$doctype = $document->getType();
// Only render for HTML output
if ($doctype !== 'html') {
echo $contents;
return;
}
// If the user is not allowed to view the output then end here
$filterGroups = (array) $this->params->get('filter_groups', null);
if (!empty($filterGroups)) {
$userGroups = JFactory::getUser()->get('groups');
if (!array_intersect($filterGroups, array_keys($userGroups))) {
echo $contents;
return;
}
}
// Load language file
$this->loadLanguage('plg_system_debug');
$profiler =& $_PROFILER;
ob_start();
echo '<div id="system-debug" class="profiler">';
$errors = JError::getErrors();
if (!empty($errors)) {
echo '<h4>' . JText::_('PLG_DEBUG_ERRORS') . '</h4><ol>';
while ($error = JError::getError(true)) {
echo '<li>' . $error->getMessage() . '<br /><h4>' . JText::_('PLG_DEBUG_INFO') . '</h4><pre>' . print_r($error->get('info'), true) . '</pre><br /><h4>' . JText::_('PLG_DEBUG_BACKTRACE') . '</h4>' . JError::renderBacktrace($error) . '</li>';
}
echo '</ol>';
}
if ($this->params->get('profile', 1)) {
echo '<h4>' . JText::_('PLG_DEBUG_PROFILE_INFORMATION') . '</h4>';
foreach ($profiler->getBuffer() as $mark) {
echo '<div>' . $mark . '</div>';
}
}
if ($this->params->get('memory', 1)) {
echo '<h4>' . JText::_('PLG_DEBUG_MEMORY_USAGE') . '</h4>';
$bytes = $profiler->getMemory();
echo JHtml::_('number.bytes', $bytes);
echo ' (' . number_format($bytes) . ' Bytes)';
}
if ($this->params->get('queries', 1)) {
$newlineKeywords = '#\\b(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND)\\b#i';
$db = JFactory::getDbo();
echo '<h4>' . JText::sprintf('PLG_DEBUG_QUERIES_LOGGED', $db->getTicker()) . '</h4>';
if ($log = $db->getLog()) {
echo '<ol>';
$selectQueryTypeTicker = array();
$otherQueryTypeTicker = array();
foreach ($log as $k => $sql) {
// Start Query Type Ticker Additions
$fromStart = stripos($sql, 'from');
$whereStart = stripos($sql, 'where', $fromStart);
if ($whereStart === false) {
$whereStart = stripos($sql, 'order by', $fromStart);
}
if ($whereStart === false) {
$whereStart = strlen($sql) - 1;
}
$fromString = substr($sql, 0, $whereStart);
$fromString = str_replace("\t", " ", $fromString);
$fromString = str_replace("\n", " ", $fromString);
$fromString = trim($fromString);
// Initialize the select/other query type counts the first time:
if (!isset($selectQueryTypeTicker[$fromString])) {
$selectQueryTypeTicker[$fromString] = 0;
}
if (!isset($otherQueryTypeTicker[$fromString])) {
$otherQueryTypeTicker[$fromString] = 0;
}
// Increment the count:
if (stripos($sql, 'select') === 0) {
$selectQueryTypeTicker[$fromString] = $selectQueryTypeTicker[$fromString] + 1;
unset($otherQueryTypeTicker[$fromString]);
} else {
$otherQueryTypeTicker[$fromString] = $otherQueryTypeTicker[$fromString] + 1;
//.........这里部分代码省略.........
示例2: onAfterRender
/**
* Converting the site URL to fit to the HTTP request
*
*/
function onAfterRender()
{
global $_PROFILER;
// Do not render if debugging is not enabled
if (!JDEBUG) {
return;
}
$document =& JFactory::getDocument();
$doctype = $document->getType();
// Only render for HTML output
if ($doctype !== 'html') {
return;
}
// If the user is not allowed to view the output then end here
$filterGroups = (array) $this->params->get('filter_groups', null);
if (!empty($filterGroups)) {
$userGroups = JFactory::getUser()->get('groups');
if (!array_intersect($filterGroups, array_keys($userGroups))) {
return;
}
}
$profiler =& $_PROFILER;
ob_start();
echo '<div id="system-debug" class="profiler">';
$errors = JError::getErrors();
if (!empty($errors)) {
echo '<h4>' . JText::_('Errors') . '</h4><ol>';
while ($error = JError::getError(true)) {
echo '<li>' . $error->getMessage() . '<br /><h4>' . JText::_('Info') . '</h4><pre>' . print_r($error->get('info'), true) . '</pre><br /><h4>' . JText::_('Backtrace') . '</h4>' . JError::renderBacktrace($error) . '</li>';
}
echo '</ol>';
}
if ($this->params->get('profile', 1)) {
echo '<h4>' . JText::_('Debug_Profile_Information') . '</h4>';
foreach ($profiler->getBuffer() as $mark) {
echo '<div>' . $mark . '</div>';
}
}
if ($this->params->get('memory', 1)) {
echo '<h4>' . JText::_('Debug_Memory_Usage') . '</h4>';
echo number_format($profiler->getMemory());
}
if ($this->params->get('queries', 1)) {
$newlineKeywords = '#\\b(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND)\\b#i';
$db =& JFactory::getDbo();
echo '<h4>' . JText::sprintf('Debug_Queries_logged', $db->getTicker()) . '</h4>';
if ($log = $db->getLog()) {
echo '<ol>';
foreach ($log as $k => $sql) {
$text = preg_replace($newlineKeywords, '<br /> \\0', $sql);
echo '<li>' . $text . '</li>';
}
echo '</ol>';
}
}
$lang =& JFactory::getLanguage();
if ($this->params->get('language_files', 1)) {
echo '<h4>' . JText::_('Debug_Language_Files_Loaded') . '</h4>';
echo '<ul>';
$extensions = $lang->getPaths();
foreach ($extensions as $extension => $files) {
foreach ($files as $file => $status) {
echo "<li>{$file} {$status}</li>";
}
}
echo '</ul>';
}
if ($this->params->get('language_strings')) {
$stripFirst = $this->params->get('strip-first');
$stripPref = $this->params->get('strip-prefix');
$stripSuff = $this->params->get('strip-suffix');
echo '<h4>' . JText::_('Debug_Untranslated_Strings') . '</h4>';
echo '<pre>';
$orphans = $lang->getOrphans();
if (count($orphans)) {
ksort($orphans, SORT_STRING);
$guesses = array();
foreach ($orphans as $key => $occurance) {
if (is_array($occurance) and isset($occurance[0])) {
$info =& $occurance[0];
$file = @$info['file'];
if (!isset($guesses[$file])) {
$guesses[$file] = array();
}
// Prepare the key
if (($pos = strpos($info['string'], '=')) > 0) {
$parts = explode('=', $info['string']);
$key = $parts[0];
$guess = $parts[1];
} else {
$guess = str_replace('_', ' ', $info['string']);
if ($stripFirst) {
$parts = explode(' ', $guess);
if (count($parts) > 1) {
array_shift($parts);
$guess = implode(' ', $parts);
//.........这里部分代码省略.........