本文整理汇总了PHP中GeSHi::get_time方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::get_time方法的具体用法?PHP GeSHi::get_time怎么用?PHP GeSHi::get_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::get_time方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: syntaxhighlighting
/**
* Highlights the content parts marked as source code using the GeSHi
* class.
* @author Björn Detert <b.detert@mittwald.de>
* @version 20. 9. 2006
* @param string $content The text to be parsed
* @param object $parent The calling object (regulary of type tx_mmforum_pi1), so this
* object inherits all configuration and language options from the
* calling object.
* @param array $conf The calling plugin's configuration vars
* @return string The parsed string
*/
function syntaxhighlighting($content, $parent, $conf)
{
/* Path to Geshi Syntax-Highlighting files. */
$path = GeneralUtility::getFileAbsFileName('EXT:mm_forum/res/geshi/geshi/', $onlyRelative = 1, $relToTYPO3_mainDir = 0);
$conf['postparser.']['tsrefUrl'] ? define('GESHI_TS_REF', $conf['postparser.']['tsrefUrl']) : define('GESHI_TS_REF', 'www.typo3.net');
$res = $this->databaseHandle->exec_SELECTquery('lang_title,lang_pattern,lang_code', 'tx_mmforum_syntaxhl', 'deleted=0');
while ($data = $this->databaseHandle->sql_fetch_assoc($res)) {
preg_match_all($data['lang_pattern'], $content, $source_arr);
while (list($key, $value) = each($source_arr[1])) {
$value = trim($this->decode_entities($value));
if ($data['lang_title'] == 'php') {
if (!preg_match("/<\\?/", trim(substr($value, 0, 6)))) {
$value = "<?\n" . $value . "\n?>";
}
}
$geshi = new GeSHi($value, $data['lang_code'], $path);
$geshi->set_header_type(GESHI_HEADER_PRE);
#$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->set_line_style('background: ' . $conf['postparser.']['sh_linestyle_bg'] . ';', 'background: ' . $conf['postparser.']['sh_linestyle_bg2'] . ';', true);
$geshi->set_overall_style('margin:0px;', true);
$geshi->enable_classes();
$style = '<style type="text/css"><!--';
$style .= $geshi->get_stylesheet();
$style .= '--></style>';
$geshi->enable_strict_mode('FALSE');
$replace = $geshi->parse_code();
$time = $geshi->get_time();
$CodeHead = '<div class="tx-mmforum-pi1-codeheader">' . strtoupper($data['lang_title']) . '</div>';
// $code_header , check this out?? I get confused ^^
$replace = '###DONT_PARSE_AGAIN_START###' . $CodeHead . '<div class="tx-mmforum-pi1-codeblock">' . $style . $replace . '</div>###DONT_PARSE_AGAIN_ENDE###';
$content = str_replace($source_arr[0][$key], $replace, $content);
}
}
return $content;
}
示例2: jx_show_file
/**
* 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 />';
}
示例3: execAction
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
}