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


PHP GeSHi::set_overall_id方法代码示例

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


在下文中一共展示了GeSHi::set_overall_id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle_geshi

function handle_geshi($content, $language)
{
    $g = new GeSHi($content, $language);
    $g->enable_classes();
    $g->set_header_type(GESHI_HEADER_DIV);
    $g->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5);
    #$g->set_overall_style('color:black');
    $g->set_overall_id('source');
    $g->set_code_style('color:black;', "'Courier New', Courier, monospace");
    $g->set_line_style('color:#838383;', '', true);
    return $g->parse_code();
}
开发者ID:slepp,项目名称:pastebin.ca,代码行数:12,代码来源:handler.inc.php

示例2: format_code

 public function format_code($text, $post = null)
 {
     if (isset($post)) {
         $code = $text;
         if (preg_match("/\\[gist: ([0-9]+)\\]/i", $code, $matches)) {
             return '<script src="http://gist.github.com/' . $matches[1] . '.js"></script>';
         }
         $post->code_unformatted = $post->code;
         $languages = getLanguages();
         $geshi = new GeSHi($code, $languages[$post->language]);
         if ($geshi->error() !== false) {
             return "<pre id='geshi_code'>" . $geshi->error() . "</pre>";
         }
         $geshi->set_overall_id('geshi_code');
         $return = $geshi->parse_code();
         return $return;
     } else {
         return "<pre id='geshi_code'>" . $text . "</pre>";
     }
 }
开发者ID:stevestreza,项目名称:code-feather,代码行数:20,代码来源:code.php

示例3: onParseContentBlock

 function onParseContentBlock($page, $name, $text, $shortcut)
 {
     $output = NULL;
     if (!empty($name) && !$shortcut) {
         list($language, $lineNumber, $class, $id) = $this->getHighlightInfo($name);
         if (!empty($language)) {
             $geshi = new GeSHi(trim($text), $language);
             $geshi->set_language_path($this->yellow->config->get("pluginDir") . "/highlight/");
             $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
             $geshi->set_overall_class($class);
             $geshi->set_overall_id($id);
             $geshi->enable_line_numbers($lineNumber ? GESHI_NORMAL_LINE_NUMBERS : GESHI_NO_LINE_NUMBERS);
             $geshi->start_line_numbers_at($lineNumber);
             $geshi->enable_classes(true);
             $geshi->enable_keyword_links(false);
             $output = $geshi->parse_code();
             $output = preg_replace("#<pre(.*?)>(.+?)</pre>#s", "<pre\$1><code>\$2</code></pre>", $output);
         }
     }
     return $output;
 }
开发者ID:nogginfuel,项目名称:yellow-extensions,代码行数:21,代码来源:highlight.php

示例4: LoadData

 /**
  * 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));
 }
开发者ID:hmcclungiii,项目名称:gitphp,代码行数:63,代码来源:Controller_Blob.class.php

示例5: prepare

 /**
  * Initialise a GeSHi object to format some code, performing
  * common setup for all our uses of it
  *
  * @param string $text
  * @param string $lang
  * @return GeSHi
  */
 public static function prepare($text, $lang)
 {
     global $wgTitle, $wgOut;
     self::initialise();
     $geshi = new GeSHi($text, $lang);
     if ($geshi->error() == GESHI_ERROR_NO_SUCH_LANG) {
         return null;
     }
     $geshi->set_encoding('UTF-8');
     $geshi->enable_classes();
     $geshi->set_overall_class("source-{$lang}");
     $geshi->enable_keyword_links(false);
     // Wikia change start
     if ($wgTitle instanceof Title && EditPageLayoutHelper::isCodeSyntaxHighlightingEnabled($wgTitle)) {
         $theme = 'solarized-light';
         if (SassUtil::isThemeDark()) {
             $theme = 'solarized-dark';
         }
         $geshi->set_language_path(GESHI_ROOT . $theme . DIRECTORY_SEPARATOR);
         $geshi->set_overall_id('theme-' . $theme);
         $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/SyntaxHighlight_GeSHi/styles/solarized.scss'));
     }
     // Wikia change end
     return $geshi;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:33,代码来源:SyntaxHighlight_GeSHi.class.php

示例6: dirname


//.........这里部分代码省略.........
                     } else {
                         $error = TRUE;
                     }
                 } else {
                     // use GeSHi 1.0
                     include_once dirname(__FILE__) . '/geshi-1.0/geshi.php';
                     // highlight code according to type setting, default to php
                     $geshi = new GeSHi($not_geshified, $match['type'] !== NULL ? $match['type'] : $this->settings['default_type']);
                     $str_error = $geshi->error();
                     if (empty($str_error)) {
                         // enable line numbers
                         $number_style = !empty($match['line']) ? $match['line'] : $this->settings['default_line'];
                         switch (strtolower(preg_replace('/\\d+/', '', $number_style))) {
                             case 'normal':
                                 $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                                 break;
                             case 'fancy':
                                 $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, (int) preg_replace('/[^\\d]*/', '', $number_style));
                                 break;
                             case 'none':
                                 $geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
                                 break;
                         }
                         // set first line number
                         if ($match['start']) {
                             $geshi->start_line_numbers_at($match['start']);
                         }
                         // set strict mode
                         if ($match['strict']) {
                             $geshi->enable_strict_mode(TRUE);
                         }
                         // enable or disable keyword links
                         $geshi->enable_keyword_links((bool) ($match['keyword_links'] !== NULL) ? $match['keyword_links'] : $this->settings['keyword_links']);
                         // set overall class name
                         if ($match['overall_class'] != NULL) {
                             $geshi->set_overall_class($match['overall_class']);
                         }
                         // set overall id
                         if ($match['overall_id'] != NULL) {
                             $geshi->set_overall_id($match['overall_id']);
                         }
                         // set header type
                         switch ($this->settings['geshi_header_type']) {
                             case 'div':
                                 $geshi->set_header_type(GESHI_HEADER_DIV);
                                 break;
                             case 'pre':
                                 $geshi->set_header_type(GESHI_HEADER_PRE);
                                 break;
                             case 'pre-valid':
                                 $geshi->set_header_type(GESHI_HEADER_PRE_VALID);
                                 break;
                             case 'pre-table':
                                 $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                                 break;
                             case 'none':
                                 $geshi->set_header_type(GESHI_HEADER_NONE);
                                 break;
                         }
                         // set encoding (for legacy reasons afaik)
                         $geshi->set_encoding($this->settings['geshi_encoding']);
                         // parse the source code
                         $geshified = $geshi->parse_code();
                     } else {
                         $error = TRUE;
                     }
                 }
                 if (!file_exists($cache_dir . $md5) && is_writable($cache_dir) || file_exists($cache_dir . $md5) && is_writable($cache_dir . $md5)) {
                     if (!$error) {
                         // we can write to the cache file
                         if (is_callable('file_put_contents')) {
                             file_put_contents($cache_dir . $md5, $geshified);
                             @chmod($cache_dir . $md5, 0777);
                         } else {
                             // when will you guys finally drop PHP4 support?
                             $f = fopen($cache_dir . $md5, 'w');
                             fwrite($f, $geshified);
                             fclose($f);
                             @chmod($cache_dir . $md5, 0777);
                         }
                     }
                 } else {
                     // We could ignore that, but for performance reasons better warn the user.
                     print '<b>Warning</b>: Your <i>' . $this->name . '</i> cache directory <b>' . $cache_dir . '</b> is not writable! This will cause severe performance problems, so I suggest you chmod that dir.';
                 }
             }
             // save replacement to cache and mark location with an identifier for later replacement
             if (!isset($_SESSION['cache']['ext.geshify'])) {
                 $_SESSION['cache']['ext.geshify'] = array();
             }
             if (!$error) {
                 $_SESSION['cache']['ext.geshify'][$md5] = $geshified;
                 $str = substr($str, 0, $code_pos) . $md5 . substr($str, $code_end_pos + $rllen);
             }
         }
         // unset used variables, so we don't get messed up
         unset($code_pos, $code_end_pos, $md5, $geshified, $not_geshified, $geshi, $match, $ident, $error);
     }
     return $str;
 }
开发者ID:neverpanic,项目名称:GeSHify,代码行数:101,代码来源:ext.geshify.php

示例7: getGeSHI

 /**
  * 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;
 }
开发者ID:GitHubTianPeng,项目名称:101worker,代码行数:43,代码来源:megalib_leftover.php

示例8: LoadData

 /**
  * 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));
 }
开发者ID:sandassha,项目名称:gitstack,代码行数:62,代码来源:Controller_Blob.class.php


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