function _geshiHighlight($content, $language = '') { $langauge = is_empty($language) ? 'text' : strtolower($language); $langInfo = grabLangInfo($language); $ext = doArgs('ext', null, $langInfo); $language = doArgs('lang', null, $langInfo); $geshiExt = doArgs('geshi', null, $langInfo); if (is_empty($content)) { return false; } $content = trim($content); $content = htmlspecialchars_decode($content, ENT_NOQUOTES); $geshi = Core_Classes_coreObj::getLib('GeSHi', array($content, $geshiExt)); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5); $content = $geshi->parse_code(); return "\n<div class=\"markdown_code\">\n<div class=\"markdown_code_body\">" . $content . "</div>\n</div>\n"; }
/** * Retrieves all the SQL Queries and pumps them out * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @param bool $output If True, The function will output the HTML * * @return array */ public function getSQLQueries($output = false) { if ($output !== true) { return ''; } $output = ''; $objSQL = Core_Classes_coreObj::getDBO(); $debug = $objSQL->getVar('debug'); if (!empty($debug)) { foreach ($debug as $query) { $output .= '<table class="table">'; //$output .= '</tr>'; $output .= sprintf('<tr class="%s"><td colspan="11" style="height: 5px; padding: 0;"></td></tr>', $query['affected_rows'] == '-1' ? 'error' : 'success'); $replace = array('FROM', 'LEFT JOIN', 'RIGHT JOIN', 'INNER JOIN', 'ON', 'OR', 'AND', 'SET', 'WHERE', 'LIMIT', 'GROUP BY', 'ORDER BY', 'VALUES'); if (strlen($query['query']) > 100) { foreach ($replace as $r) { $replace = "\n"; $r = ' ' . $r; $query['query'] = str_replace($r, $replace . $r, $query['query']); } } $geshi = Core_Classes_coreObj::getLib('GeSHi', array($query['query'], 'sql')); $output .= '</tr><tr>'; $output .= sprintf('<tr><td style="background-color: #1E1E1E; color: white;"> <strong>%1$s</strong> @ <strong>%2$s</strong> // Affected %3$d Rows <span class="pull-right">%5$s</span> <br /> %4$s </td></tr>', str_replace($this->config('global', 'realPath'), '', $query['file']), $query['line'], $query['affected_rows'], $geshi->parse_code(), $query['time_taken']); if ($query['affected_rows'] == '-1') { $output .= '</tr><tr>'; $output .= sprintf('<td style="background-color: #1E1E1E; color: white;"> %s </td>', dump($query) . $query['error']); } $output .= '</tr>'; $output .= '</table>'; } } return array('count' => count($debug) . ' / ' . $objSQL->totalTime, 'content' => sprintf('<ul>%s</ul>', $output)); }
function doCode($content, $name = NULL, $lineNumbers = false, $killWS = true) { $lang = isset($name) && $name !== NULL ? strtolower($name) : 'text'; $extInfo = grabLangInfo($lang); $ext = doArgs('ext', null, $extInfo); $lang = doArgs('lang', null, $extInfo); $geshiExt = doArgs('geshi', null, $extInfo); if (is_empty($content)) { $lang = isset($lang) ? '=' . $params . '' : ''; return "[code{$lang}][/code]"; } $content = html_entity_decode(trim($content)); $content = str_replace(array("<br />", "\t", ' '), array('', ' ', "\t"), $content); if ($killWS) { $content = preg_replace('/[\\n\\r]+/', "\n", $content); } if (!$lineNumbers) { if ($ext != 'php') { $geshi = Core_Classes_coreObj::getLib('GeSHi', array($content, $geshiExt)); $geshi->set_header_type(GESHI_HEADER_PRE); $content = $geshi->parse_code(); } if ($ext == 'php') { /* if(preg_match("#<\?[^php]#", $content)) $content = str_replace("<?", "<?php", $content); if(!preg_match("#<(\?php|\?)#", $content)) $content = "<?php".$content; if(!preg_match("#\?>#", $content)) $content = $content."?>"; */ } } else { $geshi = Core_Classes_coreObj::getLib('GeSHi', array($content, $geshiExt)); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5); $content = $geshi->parse_code(); } return "\n<div class=\"bbcode_code\">\n<div class=\"bbcode_code_head\">" . $lang . " Code: </div>\n<div class=\"bbcode_code_body\">" . ($ext == 'php' ? !$lineNumbers ? highlight_string($content, true) : $content : $content) . "</div>\n</div>\n"; }