当前位置: 首页>>代码示例>>PHP>>正文


PHP GeSHi::set_link_target方法代码示例

本文整理汇总了PHP中GeSHi::set_link_target方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::set_link_target方法的具体用法?PHP GeSHi::set_link_target怎么用?PHP GeSHi::set_link_target使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeSHi的用法示例。


在下文中一共展示了GeSHi::set_link_target方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>';
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:25,代码来源:Base.php

示例2: textsanitizer_geshi_css_highlight

/**
 * Highlights the passed source code as css
 *
 * @param $source
 */
function textsanitizer_geshi_css_highlight($source)
{
    if (!@(include_once ICMS_LIBRARIES_PATH . '/geshi/geshi.php')) {
        return false;
    }
    $source = icms_core_DataFilter::undoHtmlSpecialChars($source);
    // Create the new GeSHi object, passing relevant stuff
    $geshi = new GeSHi($source, 'css');
    // Enclose the code in a <div>
    $geshi->set_header_type(GESHI_HEADER_NONE);
    // Sets the proper encoding charset other than "ISO-8859-1"
    $geshi->set_encoding(_CHARSET);
    $geshi->set_link_target("_blank");
    // Parse the code
    $code = $geshi->parse_code();
    $code = "<div class=\"icmsCodeCss\"><code>" . $code . "</code></div>";
    return $code;
}
开发者ID:LeeGlendenning,项目名称:formulize,代码行数:23,代码来源:syntaxhighlightcss.php

示例3: p_xhtml_cached_geshi

/**
 * Wrapper for GeSHi Code Highlighter, provides caching of its output
 *
 * @param  string   $code       source code to be highlighted
 * @param  string   $language   language to provide highlighting
 * @param  string   $wrapper    html element to wrap the returned highlighted text
 *
 * @author Christopher Smith <chris@jalakai.co.uk>
 * @author Andreas Gohr <andi@splitbrain.org>
 */
function p_xhtml_cached_geshi($code, $language, $wrapper = 'pre')
{
    global $conf, $config_cascade, $INPUT;
    $language = strtolower($language);
    // remove any leading or trailing blank lines
    $code = preg_replace('/^\\s*?\\n|\\s*?\\n$/', '', $code);
    $cache = getCacheName($language . $code, ".code");
    $ctime = @filemtime($cache);
    if ($ctime && !$INPUT->bool('purge') && $ctime > filemtime(DOKU_INC . 'inc/geshi.php') && $ctime > @filemtime(DOKU_INC . 'inc/geshi/' . $language . '.php') && $ctime > filemtime(reset($config_cascade['main']['default']))) {
        // dokuwiki changed
        $highlighted_code = io_readFile($cache, false);
    } else {
        $geshi = new GeSHi($code, $language, DOKU_INC . 'inc/geshi');
        $geshi->set_encoding('utf-8');
        $geshi->enable_classes();
        $geshi->set_header_type(GESHI_HEADER_PRE);
        $geshi->set_link_target($conf['target']['extern']);
        // remove GeSHi's wrapper element (we'll replace it with our own later)
        // we need to use a GeSHi wrapper to avoid <BR> throughout the highlighted text
        $highlighted_code = trim(preg_replace('!^<pre[^>]*>|</pre>$!', '', $geshi->parse_code()), "\n\r");
        io_saveFile($cache, $highlighted_code);
    }
    // add a wrapper element if required
    if ($wrapper) {
        return "<{$wrapper} class=\"code {$language}\">{$highlighted_code}</{$wrapper}>";
    } else {
        return $highlighted_code;
    }
}
开发者ID:nextghost,项目名称:dokuwiki,代码行数:39,代码来源:parserutils.php

示例4: p_xhtml_cached_geshi

/**
 * Wrapper for GeSHi Code Highlighter, provides caching of its output
 *
 * @author Christopher Smith <chris@jalakai.co.uk>
 */
function p_xhtml_cached_geshi($code, $language)
{
    $cache = getCacheName($language . $code, ".code");
    if (@file_exists($cache) && !$_REQUEST['purge'] && filemtime($cache) > filemtime(DOKU_INC . 'inc/geshi.php')) {
        $highlighted_code = io_readFile($cache, false);
        @touch($cache);
    } else {
        require_once DOKU_INC . 'inc/geshi.php';
        $geshi = new GeSHi($code, strtolower($language), DOKU_INC . 'inc/geshi');
        $geshi->set_encoding('utf-8');
        $geshi->enable_classes();
        $geshi->set_header_type(GESHI_HEADER_PRE);
        $geshi->set_overall_class("code {$language}");
        $geshi->set_link_target($conf['target']['extern']);
        $highlighted_code = $geshi->parse_code();
        io_saveFile($cache, $highlighted_code);
    }
    return $highlighted_code;
}
开发者ID:canneverbe,项目名称:flyspray,代码行数:24,代码来源:parserutils.php

示例5: code

 /**
  * Callback for code text
  *
  * Uses GeSHi to highlight language syntax
  *
  * @author Andreas Gohr <andi@splitbrain.org>
  */
 function code($text, $language = NULL)
 {
     global $conf;
     if (is_null($language)) {
         $this->preformatted($text);
     } else {
         //strip leading blank line
         $text = preg_replace('/^\\s*?\\n/', '', $text);
         // Handle with Geshi here
         require_once DOKU_INC . 'inc/geshi.php';
         $geshi = new GeSHi($text, strtolower($language), DOKU_INC . 'inc/geshi');
         $geshi->set_encoding('utf-8');
         $geshi->enable_classes();
         $geshi->set_header_type(GESHI_HEADER_PRE);
         $geshi->set_overall_class("code {$language}");
         $geshi->set_link_target($conf['target']['extern']);
         $text = $geshi->parse_code();
         $this->doc .= $text;
     }
 }
开发者ID:BackupTheBerlios,项目名称:sitebe-svn,代码行数:27,代码来源:xhtml.php

示例6: switch

 /**
  * Style language
  *
  * @param array $subjects
  */
 function _styleSubjects($subjects)
 {
     // set overall style
     if (isset($subjects['view'])) {
         $this->geshi->set_overall_style($subjects['view'], $this->_invertOverwrite($subjects['view.']['overwrite']));
     }
     if (isset($subjects['view.']['container'])) {
         switch ($subjects['view.']['container']) {
             case 'none':
             case 'NONE':
             case 'None':
                 $this->geshi->set_header_type(GESHI_HEADER_NONE);
                 break;
             case 'div':
             case 'Div':
             case 'DIV':
                 $this->geshi->set_header_type(GESHI_HEADER_DIV);
                 break;
             case 'pre':
             case 'Pre':
             case 'PRE':
             default:
                 $this->geshi->set_header_type(GESHI_HEADER_PRE);
                 break;
         }
     }
     if (isset($subjects['view.']['tabwidth'])) {
         $this->geshi->set_tab_width(intval($subjects['view.']['tabwidth']));
     }
     // configure linenumbers
     if (isset($subjects['linenumbers'])) {
         $this->geshi->set_line_style($subjects['linenumbers'], isset($subjects['linenumbers.']['fancy']) ? $subjects['linenumbers.']['fancy'] : '', $this->_invertOverwrite($subjects['linenumbers.']['overwrite']));
     }
     // enable / disable linenumbers
     if (isset($subjects['linenumbers.']['enable'])) {
         $this->geshi->enable_line_numbers($subjects['linenumbers.']['enable']);
     }
     // configure code style
     if (isset($subjects['code'])) {
         $this->geshi->set_code_style($subjects['code'], $this->_invertOverwrite($subjects['code.']['overwrite']));
     }
     // configure escape
     if (isset($subjects['escape'])) {
         $this->geshi->set_escape_characters_style($subjects['escape'], $this->_invertOverwrite($subjects['escape.']['overwrite']));
     }
     // configure symbols
     if (isset($subjects['symbols'])) {
         $this->geshi->set_symbols_style($subjects['symbols'], $this->_invertOverwrite($subjects['symbols.']['overwrite']));
     }
     // configure strings
     if (isset($subjects['strings'])) {
         $this->geshi->set_strings_style($subjects['strings'], $this->_invertOverwrite($subjects['strings.']['overwrite']));
     }
     // configure numbers
     if (isset($subjects['numbers'])) {
         $this->geshi->set_numbers_style($subjects['numbers'], $this->_invertOverwrite($subjects['numbers.']['overwrite']));
     }
     // configure comment style
     if (isset($subjects['comments.'])) {
         foreach ($subjects['comments.'] as $key => $value) {
             if (strstr($key, '.') == false) {
                 $this->geshi->set_comments_style($key, $value, $this->_invertOverwrite($subjects['comments.'][$key . '.']['overwrite']));
             }
         }
     }
     // configure keywords style
     if (isset($subjects['keywords.'])) {
         foreach ($subjects['keywords.'] as $key => $value) {
             if (strstr($key, '.') == false) {
                 $this->geshi->set_keyword_group_style($key, $value, $this->_invertOverwrite($subjects['keywords.'][$key . '.']['overwrite']));
             }
         }
     }
     // enable / disable keyword links
     if (isset($subjects['keyword.']['links.']['enable'])) {
         $this->geshi->enable_keyword_links($subjects['keyword.']['links.']['enable']);
     }
     // configure keyword link styles
     if (isset($subjects['keyword.']['links'])) {
         $this->geshi->set_link_styles(GESHI_LINK, $subjects['keyword.']['links']);
     }
     if (isset($subjects['keyword.']['links.']['hover'])) {
         $this->geshi->set_link_styles(GESHI_HOVER, $subjects['keyword.']['links.']['hover']);
     }
     if (isset($subjects['keyword.']['links.']['active'])) {
         $this->geshi->set_link_styles(GESHI_ACTIVE, $subjects['keyword.']['links.']['active']);
     }
     if (isset($subjects['keyword.']['links.']['visited'])) {
         $this->geshi->set_link_styles(GESHI_VISITED, $subjects['keyword.']['links.']['visited']);
     }
     // configure keyword link target
     if (isset($subjects['keyword.']['links.']['target'])) {
         $this->geshi->set_link_target($subjects['keyword.']['links.']['target']);
     }
     // configure method styles
//.........这里部分代码省略.........
开发者ID:sema,项目名称:typo3-source-code-highlighter,代码行数:101,代码来源:class.tx_semasourcecode_pi1.php

示例7: textsanitizer_geshi_highlight

 /**
  * Syntaxhighlight the code using Geshi highlight
  *
  * @param	 string	$text	 The text to highlight
  * @return	string	$code	 the highlighted text
  */
 public static function textsanitizer_geshi_highlight($text)
 {
     global $icmsConfigPlugins;
     if (!@(include_once ICMS_LIBRARIES_PATH . '/geshi/geshi.php')) {
         return false;
     }
     $language = str_replace('.php', '', $icmsConfigPlugins['geshi_default']);
     // Create the new GeSHi object, passing relevant stuff
     $geshi = new GeSHi($text, $language);
     // Enclose the code in a <div>
     $geshi->set_header_type(GESHI_HEADER_NONE);
     // Sets the proper encoding charset other than "ISO-8859-1"
     $geshi->set_encoding(_CHARSET);
     $geshi->set_link_target('_blank');
     // Parse the code
     $code = $geshi->parse_code();
     return $code;
 }
开发者ID:LeeGlendenning,项目名称:formulize,代码行数:24,代码来源:DataFilter.php

示例8: getCacheName

 /**
  * Wrapper for GeSHi Code Highlighter, provides caching of its output
  * Modified to calculate cache from URL so we don't have to re-download time and again
  *
  * @author Christopher Smith <chris@jalakai.co.uk>
  * @author Esther Brunner <wikidesign@gmail.com>
  */
 function _cached_geshi($url, $refresh)
 {
     global $conf;
     $cache = getCacheName($url, '.code');
     $mtime = @filemtime($cache);
     // 0 if it doesn't exist
     if ($mtime != 0 && !$_REQUEST['purge'] && $mtime > time() - $refresh && $mtime > filemtime(DOKU_INC . 'inc/geshi.php')) {
         $hi_code = io_readFile($cache, false);
         if ($conf['allowdebug']) {
             $hi_code .= "\n<!-- cachefile {$cache} used -->\n";
         }
     } else {
         require_once DOKU_INC . 'inc/geshi.php';
         // get the source code language first
         $search = array('/^htm/', '/^js$/');
         $replace = array('html4strict', 'javascript');
         $lang = preg_replace($search, $replace, substr(strrchr($url, '.'), 1));
         // download external file
         $http = new DokuHTTPClient();
         $http->timeout = 25;
         //max. 25 sec
         $code = $http->get($url);
         $geshi = new GeSHi($code, strtolower($lang), DOKU_INC . 'inc/geshi');
         $geshi->set_encoding('utf-8');
         $geshi->enable_classes();
         $geshi->set_header_type(GESHI_HEADER_PRE);
         $geshi->set_overall_class("code {$language}");
         $geshi->set_link_target($conf['target']['extern']);
         $hi_code = $geshi->parse_code();
         io_saveFile($cache, $hi_code);
         if ($conf['allowdebug']) {
             $hi_code .= "\n<!-- no cachefile used, but created -->\n";
         }
     }
     return $hi_code;
 }
开发者ID:samiaa71,项目名称:repo-plugin,代码行数:43,代码来源:syntax.php

示例9: main


//.........这里部分代码省略.........



		$content[]= '
			  <br />
		      <table>
			    	<tr>
				  		<td>
				    		<input type="hidden" name="fname" value="'.$item.'">
				  		</td>
		          		<td>
				    		<input type="submit" name="savenow" value="'.$LANG->getLL("message.btnsave").'" >
				  		</td>
				  		<td>
		            <input type="button" value="'.$LANG->getLL("message.btnclose").'" onclick="closeDoc()">
				  		</td></tr></table><br />';





			$fileT3s = $fname;
			if(@is_file($fileT3s)){
			require_once (t3lib_extMgm::extPath("t3quixplorer")."mod1/geshi.php");

			  $inputCode = file_get_contents($fileT3s);



				switch($ext){
					case 'php':
					case 'php3':
					case 'inc':
						$hl = 'php';
						break;

					case 'html':
					case 'htm':
					case 'tmpl':
						$hl = 'html4strict';
						break;

					case 'js':
						$hl = 'javascript';
						break;

					case 'pl':
						$hl = 'perl';
						break;

					default:
						$hl = $ext;
						break;
				}

            if($item == 'setup.txt' || $item == 'config.txt'|| $item == 'constants.txt'){
            	$hl = 'ts';
            }
			switch($hl){
				case 'php':
				case 'xml':
				case 'sql':
				case 'html4strict':
				case 'javascript':
				case 'perl':
				case 'css':
				case 'smarty':
					$geshi = new GeSHi($inputCode,$hl,'geshi/');
					$geshi->use_classes = true;
					$geshi->set_tab_width(4);
					$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
					$geshi->set_link_target('_blank');
					$geshi->set_line_style("font-family:'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font-size:12px;");

					$content[] = '
					<style type="text/css">

					.'.$hl.' *{font-size:11px;}

					'.$geshi->get_stylesheet().'
					</style>
					';

					$content[] = '<strong>T3S-File: '.$fileT3s.'</strong></br><hr />'.$geshi->parse_code();

					break;
				case 'ts':
					require_once(PATH_t3lib.'class.t3lib_tsparser.php');
					$tsparser = t3lib_div::makeInstance("t3lib_TSparser");
					$tsparser->lineNumberOffset=1;
					$formattedContent = $tsparser->doSyntaxHighlight($inputCode, array($tsparser->lineNumberOffset), 0);
					$content[]='<strong>T3S-File: '.$fileT3s.'</strong></br><hr />'.$formattedContent;
					break;
				default:
					break;
			}
			}

		return implode("",$content);
	}
开发者ID:blumenbach,项目名称:blumenbach-online.de,代码行数:101,代码来源:ux_t3quixplorer_edit.php

示例10: GeSHi

<?php

include_once 'geshi.php';
$source = file_get_contents('sample.ino');
$language = "arduino";
$target = "_blank";
$geshi = new GeSHi($source, $language);
$geshi->set_line_style('background: #FCFCFC;');
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->set_link_target($target);
$code = $geshi->parse_code();
// Display highlighted code
echo $code;
// Write highlighted code to cache...
//$destination = "sample.html";
//file_put_contents( $destination, $code );
开发者ID:jlbirccyn,项目名称:geshi-arduino,代码行数:16,代码来源:test_arduino.php


注:本文中的GeSHi::set_link_target方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。