function _codemirrorHighlight($content, $language = '') { $objPage = Core_Classes_coreObj::getPage(); if (is_empty($content)) { return false; } $objPage->addCSSFile(array('href' => '/' . root() . 'assets/styles/codemirror-min.css', 'priority' => LOW)); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror-min.js', 'priority' => LOW), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror-langs-min.js', 'priority' => LOW), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror/highlighter.js', 'priority' => LOW), 'footer'); $language = grabLangInfo($language, 'mime'); $content = trim($content); $content = html_entity_decode($content, ENT_NOQUOTES); $content = str_replace('<?php', '<?php', $content); //return $content; return dump($content) . "\n<pre><span data-lang=\"" . $language . "\" data-codemir3ror=\"true\">" . $content . "</span></pre>\n"; }
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"; }