本文整理汇总了PHP中GeSHi::set_tab_width方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::set_tab_width方法的具体用法?PHP GeSHi::set_tab_width怎么用?PHP GeSHi::set_tab_width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::set_tab_width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderTagCode
public function renderTagCode(array $tag, array $rendererStates)
{
if (strtolower(strval($tag['option'])) == 'html') {
$tag['option'] = 'html5';
}
if (!$tag['option']) {
$tag['option'] = 'text';
}
$content = $this->stringifyTree($tag['children']);
$content = XenForo_Helper_String::censorString($content);
$geshi = new GeSHi($content, $tag['option']);
if (XenForo_Application::get('options')->get('dpSyntaxHighlighterShowLines')) {
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
}
$geshi->set_link_target('_blank" rel="nofollow');
$geshi->set_header_type(GESHI_HEADER_NONE);
$geshi->set_tab_width(4);
$content = $geshi->parse_code();
if ($this->_view) {
$template = $this->_view->createTemplateObject('dp_bb_code_tag_code', array('content' => $content, 'language' => $geshi->get_language_name()));
return $template->render();
} else {
return '<div style="margin: 1em auto" title="Code">' . $content . '</div>';
}
}
示例2: smarty_block_code
function smarty_block_code($params, $content, Smarty_Internal_Template $template, $open)
{
if ($open) {
return '';
} else {
$language = isset($params['language']) ? (string) $params['language'] : null;
$classes = array();
if ($language) {
$classes[] = $language;
}
if (!empty($params['class'])) {
$classes[] = $params['class'];
}
$content = trim($content, "\n\r");
$content = rtrim($content);
$rows = preg_split("#[\n\r]#", $content);
preg_match('#^\\s+#', reset($rows), $matches);
if ($matches) {
$whitespace = $matches[0];
foreach ($rows as &$row) {
$row = preg_replace('#^' . $whitespace . '#', '', $row);
}
}
$content = implode(PHP_EOL, $rows);
$content = trim($content, "\n\r");
$geshi = new GeSHi($content, $language);
$geshi->keyword_links = false;
$geshi->set_tab_width(4);
$geshi->set_header_type(GESHI_HEADER_NONE);
return '<code class="' . implode(' ', $classes) . '">' . $geshi->parse_code() . '</code>';
}
}
示例3: codeReplace
public function codeReplace($text)
{
// check if geshi available
$geshiPath = dirname(__FILE__) . '/../vendor/geshi/geshi.php';
if (!file_exists($geshiPath)) {
return $text;
}
$regexp = '@<code class="(\\w+)">(.+?)<\\/code>@s';
// replace codes
if (preg_match_all($regexp, $text, $found)) {
require_once $geshiPath;
for ($index = 0; $index < count($found) - 1; $index++) {
if (!isset($found[1][$index])) {
continue;
}
$language = $found[1][$index];
$code = trim($found[2][$index]);
$geshi = new GeSHi($code, $language);
$geshi->set_header_type(GESHI_HEADER_NONE);
$geshi->enable_classes();
$geshi->set_tab_width(2);
$geshi->enable_keyword_links(false);
if (in_array($language, array('php', 'css', 'shell', 'ruby', 'python', 'bash', 'sql')) && String::numberOfLines($code) > 5) {
//$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
}
// replace image place holders
$text = str_replace($code, $geshi->parse_code(), $text);
}
}
return $text;
}
示例4: setTab
/**
* Величина табуляции
*
* @return Code
*/
protected function setTab()
{
if (isset($this->attributes['tab'])) {
$this->attributes['tab'] = (int) $this->attributes['tab'];
if ($this->attributes['tab']) {
$this->geshi->set_tab_width($this->attributes['tab']);
}
}
return $this;
}
示例5: highlight_syntax
function highlight_syntax($code, $langid)
{
$value = get_record('problemstatement_programming_language', 'id', $langid);
if ($value) {
$syntax = $value->geshi;
} else {
$syntax = '';
}
/*
switch ($langid) {
case '0': $syntax='cpp'; break;
case '1': $syntax='delphi'; break;
case '2': $syntax='java'; break;
case '3': $syntax='python'; break;
case '4': $syntax='csharp'; break;
}*/
$geshi = new GeSHi($code, $syntax);
$geshi->set_header_type(GESHI_HEADER_DIV);
// $geshi->enable_classes(true);
$geshi->set_overall_style('font-family: monospace;');
$linenumbers = 1;
if ($linenumbers) {
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5);
$geshi->set_line_style('color:#222;', 'color:#888;');
$geshi->set_overall_style('font-size: 14px;font-family: monospace;', true);
}
$urls = FALSE;
$indentsize = FALSE;
$inline = FALSE;
if (!$urls) {
for ($i = 0; $i < 5; $i++) {
$geshi->set_url_for_keyword_group($i, '');
}
}
if ($indentsize) {
$geshi->set_tab_width($indentsize);
}
$parsed = $geshi->parse_code();
if ($inline) {
$parsed = preg_replace('/^<div/', '<span', $parsed);
$parsed = preg_replace('/<\\/div>$/', '</span>', $parsed);
}
//return $geshi->parse_code().$syntax;
$lang = get_record('problemstatement_programming_language', 'id', $langid);
if (!$lang) {
$lang = '';
}
$comment = get_string("programwritten", "problemstatement") . $lang->language_name;
//get_string("lang_".$langid, "problemstatement");
return $parsed . $comment;
}
示例6: wp_syntax_highlight_mpdf
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;
}
示例7: bbcode_highlite
function bbcode_highlite($s, $language = false)
{
$s = base64_decode($s);
if (!$language) {
return '<code>' . htmlspecialchars($s, ENT_COMPAT, 'UTF-8') . '</code>';
}
$geshi = new GeSHi($s, $language);
$geshi->enable_classes(true);
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->enable_keyword_links(false);
$geshi->set_tab_width(4);
$output = $geshi->parse_code();
if ($geshi->error()) {
return false;
}
head('stylesheet', 'geshi/' . $language, 'screen');
return '<div class="geshi">' . $output . '</div>';
}
示例8: pretty_file
function pretty_file($file, $language, $startline = 0, $endline = 0, $number = false)
{
if (!$file) {
return false;
}
$s = read_file($file, $startline, $endline);
if (!$s) {
return false;
}
if (!$language) {
return $s;
}
$output = false;
switch ($language) {
case 'plain':
$s = preg_replace("/\\]\\=\\>\n(\\s+)/m", "] => ", $s);
$s = htmlentities($s, ENT_COMPAT, 'UTF-8');
$output = '<pre class="plain">' . PHP_EOL . $s . '</pre>' . PHP_EOL;
break;
default:
$geshi = new GeSHi($s, $language);
$geshi->enable_classes(true);
$geshi->set_header_type(GESHI_HEADER_DIV);
if ($number) {
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->start_line_numbers_at($startline > 0 ? $startline : 1);
}
$geshi->enable_keyword_links(false);
$geshi->set_tab_width(4);
// echo '<pre>' . PHP_EOL .$geshi->get_stylesheet( ). '</pre>' . PHP_EOL;
$output = $geshi->parse_code();
if ($geshi->error()) {
return false;
}
}
return $output;
}
示例9: dirname
<?php
error_reporting(1);
header('Content-Type:text/plain; charset=utf-8');
if (!empty($_POST['UGC']) && !empty($_POST['UGL'])) {
include_once dirname(__FILE__) . '/geshi.php';
if (get_magic_quotes_gpc()) {
$_POST['UGC'] = stripslashes($_POST['UGC']);
}
$_POST['UGC'] = stripslashes($_POST['UGC']);
$_POST['UGL'] = strtolower($_POST['UGL']);
$GeSHi = new GeSHi($_POST['UGC'], $_POST['UGL']);
//$GeSHi->enable_classes();
$GeSHi->set_header_type(GESHI_HEADER_NONE);
$GeSHi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$GeSHi->enable_keyword_links(false);
$GeSHi->set_overall_style('');
$GeSHi->set_tab_width(4);
echo $GeSHi->parse_code();
}
示例10: net2ftp_module_printBody
function net2ftp_module_printBody()
{
// --------------
// This function prints the login screen
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
// -------------------------------------------------------------------------
// Variables
// -------------------------------------------------------------------------
$filename_extension = get_filename_extension($net2ftp_globals["entry"]);
// ------------------------
// Set the state2 variable depending on the file extension !!!!!
// ------------------------
if (getFileType($net2ftp_globals["entry"]) == "IMAGE") {
$filetype = "image";
} elseif ($filename_extension == "swf") {
$filetype = "flash";
} else {
$filetype = "text";
}
// Form name, back and forward buttons
$formname = "ViewForm";
$back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
// Next screen
$nextscreen = 2;
// -------------------------------------------------------------------------
// Text
// -------------------------------------------------------------------------
if ($filetype == "text") {
// Title
$title = __("View file %1\$s", $net2ftp_globals["entry"]);
// ------------------------
// geshi_text
// ------------------------
setStatus(2, 10, __("Reading the file"));
$geshi_text = ftp_readfile("", $net2ftp_globals["directory"], $net2ftp_globals["entry"]);
if ($net2ftp_result["success"] == false) {
return false;
}
// ------------------------
// geshi_language
// ------------------------
$geshi_language = "";
$list_language_extensions = array('html4strict' => array('html', 'htm'), 'javascript' => array('js'), 'css' => array('css'), 'php' => array('php', 'php5', 'phtml', 'phps'), 'perl' => array('pl', 'pm', 'cgi'), 'sql' => array('sql'), 'java' => array('java'), 'actionscript' => array('as'), 'ada' => array('a', 'ada', 'adb', 'ads'), 'apache' => array('conf'), 'asm' => array('ash', 'asm'), 'asp' => array('asp'), 'bash' => array('sh'), 'c' => array('c', 'h'), 'c_mac' => array('c'), 'caddcl' => array(), 'cadlisp' => array(), 'cpp' => array('cpp'), 'csharp' => array(), 'd' => array(''), 'delphi' => array('dpk'), 'diff' => array(''), 'email' => array('eml', 'mbox'), 'lisp' => array('lisp'), 'lua' => array('lua'), 'matlab' => array(), 'mpasm' => array(), 'nsis' => array(), 'objc' => array(), 'oobas' => array(), 'oracle8' => array(), 'pascal' => array('pas'), 'python' => array('py'), 'qbasic' => array('bi'), 'smarty' => array('tpl'), 'vb' => array('bas'), 'vbnet' => array(), 'vhdl' => array(), 'visualfoxpro' => array(), 'xml' => array('xml'));
while (list($language, $extensions) = each($list_language_extensions)) {
if (in_array($filename_extension, $extensions)) {
$geshi_language = $language;
break;
}
}
// ------------------------
// geshi_path
// ------------------------
$geshi_path = NET2FTP_APPLICATION_ROOTDIR . "/plugins/geshi/geshi/";
// ------------------------
// Call geshi
// ------------------------
setStatus(4, 10, __("Parsing the file"));
$geshi = new GeSHi($geshi_text, $geshi_language, $geshi_path);
$geshi->set_encoding(__("iso-8859-1"));
$geshi->set_header_type(GESHI_HEADER_PRE);
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
// $geshi->enable_classes();
$geshi->set_overall_style('border: 2px solid #d0d0d0; background-color: #f6f6f6; color: #000066; padding: 10px;', true);
$geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
$geshi->set_tab_width(4);
$geshi_text = $geshi->parse_code();
} elseif ($filetype == "image") {
$title = __("View image %1\$s", htmlEncode2($net2ftp_globals["entry"]));
$image_url = printPHP_SELF("view");
$image_alt = __("Image") . $net2ftp_globals["entry"];
} elseif ($filetype == "flash") {
$title = __("View Macromedia ShockWave Flash movie %1\$s", htmlEncode2($net2ftp_globals["entry"]));
$flash_url = printPHP_SELF("view");
}
// -------------------------------------------------------------------------
// Print the output
// -------------------------------------------------------------------------
require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
示例11: getLiveInfo
Yii::app()->clientScript->registerCss('highlightcode2', $geshi->get_stylesheet());
echo $geshi->parse_code();
?>
<p> </p>
<p>Now we modify our function:<br>
</p>
<?php
$source = "\nvar counter = 0;\nvar reset_comment = false;\nvar comment_id = 0;\nvar subject_id = 0;\n\nfunction getLiveInfo(){\n\t\$.getJSON('http://samesub.com/api/v1/live/getall?callback=?',\n\t\t{subject_id:subject_id, coment_id:comment_id},\n\t\tfunction(data) {\n\t\t\t//If everything is ok(response_code == 200), let's print some LIVE information\n\t\t\tif(data.response_code == 200){\n\t\t\t\tcounter = data.time_remaining;\n\t\t\t\tif(data.new_sub != 0 || data.new_comment != 0 ){\n\t\t\t\t\tif(data.new_sub != 0) {\n\t\t\t\t\t\t//Every time there is a nuew sub, comments must be cleared\n\t\t\t\t\t\treset_comment=true;\n\t\t\t\t\t\tcomment_id = 0;\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t//Display subject\n\t\t\t\t\t\tsubject_id = data.subject_id;\n\t\t\t\t\t\t\$('#title').html(data.title);\n\t\t\t\t\t\t\$('#time_remaining').html(data.time_remaining + ' seconds.');\n\t\t\t\t\t}\n\t\t\t\t\tif(data.new_comment != 0){\n\t\t\t\t\t\tcomment_id = data.comment_id;\n\t\t\t\t\t\tshow_comments(data.comments);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\t//Otherwise alert data.response_message\t\t\t\t\n\t\t\t\talert(data.response_message);\n\t\t\t}\n\t\t}\n\t);\n\tvar aa = setTimeout('getLiveInfo()',8000);\n}\n\nfunction show_comments(comments){\n\tif(reset_comment == true) {\n\t\t\$('#comments_box').html('');//Clear all previous comments\n\t}\n\tfor(var i in comments) {\n\t\t\$('#comments_box').prepend(comments[i]['comment_text']+ '<br />');\n\t}\n}\n\nvar myInterval = setInterval(\n\tfunction(){\n\t\tcounter = counter - 1;\n\t\t\$('#time_remaining').html(counter + ' seconds.');\n\t}\n,1000);\n";
$language = 'Javascript';
$geshi = new GeSHi($source, $language);
$geshi->enable_classes();
$geshi->set_overall_class('myjs_no_lines');
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->set_overall_style("padding:1px 15px 1px 15px;border:1px solid #999999;background: #fcfcfc;font: normal normal 1em/1.2em monospace;");
$geshi->set_tab_width(2);
//$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
//$geshi->set_line_style('background: #fcfcfc;', true);
Yii::app()->clientScript->registerCss('highlightcode2', $geshi->get_stylesheet());
echo $geshi->parse_code();
?>
<p> </p>
<p>As you can see there are several changes: </p>
<ol>
<li>We have declared few global variables.</li>
<li>We have splitted our function in three main parts: the <b>getLiveInfo</b>
function itself, the <b>show_comments</b> function, and the interval
function.</li>
<li>Notice that now we are sending two data parameters to the <b>getJSON</b>
jquery function; the <b>subject_id</b> and <b>comment_id</b> parameters.</li>
<li>Notice that the values we are sending in the two parameters are the same
示例12: wp_codebox_highlight_geshi
function wp_codebox_highlight_geshi ($match)
{
global $codeid, $post;
$codeid ++;
//get option from DB
$cb_plain_txt = get_option("cb_plain_txt");
$cb_line = get_option("cb_line");
$cb_colla = get_option("cb_colla");
$cb_wrap_over = get_option("cb_wrap_over");
$cb_highlight = get_option("cb_highlight");
$cb_strict = get_option("cb_strict");
$cb_caps = get_option("cb_caps");
$cb_tab_width = intval(get_option("cb_tab_width"));
$cb_keywords_link = get_option("cb_keywords_link");
if ($match[1]) {
$language = strtolower(trim($match[1]));
} else {
$language = "text";
}
$line = trim($match[4]);
$file = trim($match[2]);
$colla = trim($match[3]);
$code = wp_codebox_code_trim($match[5]);
$is_windowsie = wp_codebox_is_windowsie();
$geshi = new GeSHi($code, $language);
$geshi->enable_keyword_links($cb_keywords_link);
$geshi->set_case_keywords($cb_caps);
$geshi->set_tab_width($cb_tab_width);
$geshi->enable_strict_mode($cb_strict);
do_action_ref_array('wp_codebox_init_geshi', array(&$geshi));
$output = "\n";
if (! ($cb_plain_txt)) {
$output .= "<div class=\"wp_codebox_msgheader";
if (($cb_colla && (! ($colla == "+"))) || ($colla == "-")) {
$output .= " wp_codebox_hide";
}
$output .= "\">";
$output .= "<span class=\"right\">";
$output .= "<sup><a href=\"http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples\" target=\"_blank\" title=\"WP-CodeBox HowTo?\"><span style=\"color: #99cc00\">?</span></a></sup>";
if ($is_windowsie) {
$output .= "<a href=\"javascript:;\" onclick=\"copycode('p" . $post->ID . "code" . $codeid . "');\">" . __('[Copy to clipboard]', 'wp-codebox') . "</a>";
}
/*
$output .= "<a href=\"javascript:;\" onclick=\"toggle_collapse('p".$post->ID.$codeid."');\">[<span id=\"p".$post->ID.$codeid."_symbol\">";
if (($cb_colla && (!($colla == "+"))) || ($colla == "-")){$output .= "+";} else {$output.= "-";}
$output .= "</span>]</a>";
*/
$output .= "</span>";
if ($file) {
$output .= "<span class=\"left2\">" . __('Download', 'wp-codebox') . ' <a href="' . get_bloginfo('wpurl') . '/wp-content/plugins/wp-codebox/wp-codebox.php?p=' . $post->ID . '&download=' . wp_specialchars($file) . '">' . wp_specialchars($file) . '</a>';
} else {
$output .= "<span class=\"left\">" . "<a href=\"javascript:;\" onclick=\"javascript:showCodeTxt('p" . $post->ID . "code" . $codeid . "'); return false;\">" . __('View Code', 'wp-codebox') . "</a> " . strtoupper($language);
}
$output .= "</span><div class=\"codebox_clear\"></div></div>";
}
$output .= "<div class=\"wp_codebox\">";
$output .= "<table>";
$output .= "<tr ";
$output .= "id=\"p" . $post->ID . $codeid . "\">";
if ($cb_line && (! ($line)))
$line = "1";
if (($line) && (! ($line == "n"))) {
$output .= "<td class=\"line_numbers\">";
$output .= wp_codebox_line_numbers($code, $line);
$output .= "</td>";
}
$output .= "<td class=\"code\" id=\"p" . $post->ID . "code" . $codeid . "\">";
$output .= $geshi->parse_code();
$output .= "</td></tr></table></div>\n";
return $output;
}
示例13: GeSHi
function ch_highlight_code($matches)
{
global $ch_options;
// undo nl and p formatting
$plancode = $matches[2];
$plancode = $this->entodec($plancode);
$geshi = new GeSHi($plancode, strtolower($matches[1]));
$geshi->set_encoding('utf-8');
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->enable_classes(true);
$language = $geshi->get_language_name();
if ($language == 'PHP') {
$geshi->add_keyword(2, 'protected');
$geshi->add_keyword(2, 'private');
$geshi->add_keyword(2, 'abstract');
$geshi->add_keyword(2, 'static');
$geshi->add_keyword(2, 'final');
$geshi->add_keyword(2, 'implements');
} elseif ($language == 'Bash') {
$geshi->add_keyword(2, 'convert');
$geshi->add_keyword(2, 'git');
} elseif ($language == 'Vim Script') {
$geshi->add_keyword(1, 'endfunction');
}
if (ch_go('ch_b_linenumber')) {
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
}
$geshi->enable_strict_mode(ch_go('ch_b_strict_mode'));
$geshi->set_tab_width(ch_go('ch_in_tab_width'));
$geshi->set_overall_class('dean_ch');
$overall_style = '';
if (!ch_go("ch_b_wrap_text")) {
$overall_style .= 'white-space: nowrap;';
} else {
$overall_style .= 'white-space: wrap;';
}
if ($overall_style != '') {
$geshi->set_overall_style($overall_style, false);
}
return $geshi->parse_code();
}
示例14: GeSHi
<?php
/* @var $this yii\web\View */
/* @var $language common\models\Language */
/* @var $snippet common\models\Snippet */
use yii\helpers\Html;
use cebe\markdown\GithubMarkdown;
use common\models\SnippetComment;
use common\models\Bookmark;
use yii\bootstrap\ActiveForm;
$this->title = $snippet->name;
$geshi = new GeSHi($snippet->code, $language->renderCode);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->set_tab_width(4);
$geshiCode = $geshi->parse_code();
$markdown = new GithubMarkdown();
$markdown->html5 = true;
$markdown->enableNewlines = true;
$comments = SnippetComment::find()->where(['snippetId' => $snippet->id])->with('member')->orderBy('createdTime ASC')->all();
$hasBookmarked = false;
if ($this->context->member) {
$hasBookmarked = Bookmark::find()->where(['memberId' => $this->context->member->id, 'snippetId' => $snippet->id])->count();
}
if (!$this->context->member && $this->context->params['registrationsOpen']) {
?>
<span class="bookmark">
<a href="/login?r=<?php
echo $_SERVER['REQUEST_URI'];
?>
" title="Login and return here">Login</a>
示例15: fox_code
function fox_code($atts, $thing)
{
global $file_base_path, $thisfile, $fox_code_prefs;
if (isset($fox_code_prefs)) {
foreach (array('fileid', 'filename', 'language', 'lines', 'startline', 'overallclass', 'tabs', 'css', 'keywordslinks', 'encoding', 'fromline', 'toline') as $value) {
${$value} = $fox_code_prefs[$value];
}
} else {
extract(lAtts(array('fileid' => '', 'filename' => '', 'language' => 'php', 'lines' => '1', 'startline' => '1', 'overallclass' => '', 'tabs' => '2', 'css' => '0', 'keywordslinks' => '0', 'encoding' => 'UTF-8', 'fromline' => '', 'toline' => ''), $atts));
}
if (!$thisfile) {
if ($fileid) {
$thisfile = fileDownloadFetchInfo('id = ' . intval($fileid));
} else {
if ($filename) {
$thisfile = fileDownloadFetchInfo("filename = '" . $filename . "'");
} else {
$local_notfile = false;
}
}
}
if (!empty($thisfile)) {
$filename = $thisfile['filename'];
$fileid = $thisfile['id'];
if (!empty($fromline) || !empty($toline)) {
$handle = fopen($file_base_path . '/' . $filename, "r");
$fromline = !empty($fromline) ? intval($fromline) : intval(1);
$toline = !empty($toline) ? intval($toline) : intval(-1);
$currentLine = 0;
$code = "";
while (!feof($handle)) {
$currentLine++;
if ($currentLine >= $fromline && ($toline < 0 || $currentLine <= $toline)) {
$code .= fgets($handle);
} else {
fgets($handle);
}
}
fclose($handle);
$startline = $fromline;
} else {
$code = file_get_contents($file_base_path . '/' . $filename);
}
} else {
if (strlen($fox_code_prefs['code']) > 0) {
$code = $fox_code_prefs['code'];
} else {
$code = $thing;
}
}
if (!$overallclass) {
$overallclass = $language;
}
require_once 'geshi.php';
$geshi = new GeSHi(trim($code, "\r\n"), $language);
if ((bool) $css) {
$geshi->enable_classes();
$geshi->set_overall_class($overallclass);
}
$geshi->start_line_numbers_at($startline);
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->set_encoding($encoding);
$geshi->set_tab_width(intval($tabs));
$geshi->enable_keyword_links((bool) $keywordslinks);
$geshi->enable_line_numbers((bool) $lines);
if (!isset($local_notfile)) {
$thisfile = NULL;
}
return $geshi->parse_code();
}