本文整理汇总了PHP中Engine::highlightSyntax方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine::highlightSyntax方法的具体用法?PHP Engine::highlightSyntax怎么用?PHP Engine::highlightSyntax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine::highlightSyntax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderTag
static function renderTag($input, $params, $parser, $frame)
{
global $extr;
try {
$darr = array_diff_key($params, self::$allowedAttr);
if (!empty($darr)) {
throw new Exception('Engine.php: unknown attribute(s) "' . implode('", "', array_keys($darr)) . '"');
}
if (!array_key_exists('output', $params)) {
$params['output'] = 'text';
}
if (!in_array($params['output'], Engine::$allowedOutput)) {
throw new Exception('Engine.php: unknown value "' . $params['output'] . '" for attribute "output"');
}
$wiki = array_key_exists('wiki', $params) || strcmp($params['output'], 'wiki') == 0;
$sha1 = $extr->hashtxt($extr->R_DTS . $input . serialize($params));
$name = array_key_exists('name', $params) ? $params['name'] : (array_key_exists('label', $params) ? $params['label'] : $sha1);
$direct = !array_key_exists('iframe', $params);
if ($wiki && (!$direct || array_key_exists('echo', $params))) {
throw new Exception('Engine.php: You can not use output="wiki" and use "echo" or "iframe"');
}
$params['geshi'] = $extr->options['usegeshi'] && array_key_exists('echo', $params) && strcmp($params['echo'], 'nogeshi');
$workhorse = array_key_exists('engine', $params) ? Engine::engineIndex($params['engine']) : 0;
Engine::check($extr->engine[$workhorse]->banned, $input);
$params['engine'] = $extr->engine[$workhorse]->name;
$params['sha1'] = $sha1;
$params['input'] = trim($input);
if (array_key_exists('name', $params) && !$direct) {
$params['name'] = rawurlencode($parser->getTitle() . '_' . $params['name']);
file_put_contents(R_DIR . $params['name'] . '.param', serialize($params));
}
$fn = $extr->engine[$workhorse]->render($params);
if (array_key_exists('iframe', $params)) {
$iframe = Engine::makeStyle($params['iframe'], array('width' => '100%', 'height' => '250px'));
$ret = '<iframe name="' . $name . '" style="' . $iframe . '" src="' . $extr->engine[$workhorse]->url($fn) . '">Sorry, your browser does not support <iframe...>... </iframe> !</iframe>';
} else {
$ret = file_get_contents($fn);
}
if ($wiki) {
$ret = $parser->recursiveTagParse($ret, $frame);
}
$category = array_key_exists('category', $params) ? $params['category'] : $extr->engine[$workhorse]->category;
if (!empty($category)) {
$ret .= $parser->recursiveTagParse(sprintf('[[Category:%s]]', $category), $frame);
}
if ($extr->engine[$workhorse]->security > 0) {
Engine::checkJavaScriptAndPHP($extr->engine[$workhorse], $ret);
}
if ($params['geshi']) {
$ret = Engine::highlightSyntax($extr->engine[$workhorse]->lang, $ret, $parser, $frame);
}
return $ret;
} catch (Exception $e) {
$extr->exception_log($e);
return '<pre style="color:red">' . htmlentities($e->getMessage()) . '</pre>in<pre>' . htmlentities($input) . '</pre>';
}
}