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


PHP GeSHi::get_language_name方法代码示例

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


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

示例1: load

 function load()
 {
     if ($this->exists() == true) {
         $this->import();
         $this->lng = $this->data['language'];
         $this->source = $this->data['source'];
     } else {
         if (!class_exists('GeSHi')) {
             include_once 'classes/class.geshi.php';
         }
         global $lang;
         $language = $this->hasLanguage() ? $this->lng : 'text';
         $geshi = new GeSHi($this->source, $language, 'classes/geshi');
         $geshi->set_encoding($lang->charset());
         $geshi->enable_classes(false);
         $geshi->set_header_type(GESHI_HEADER_DIV);
         $geshi->enable_keyword_links(true);
         $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5);
         if (!$this->hasLanguage()) {
             $geshi->enable_highlighting(false);
             $geshi->set_numbers_highlighting(false);
             $geshi->set_brackets_highlighting(false);
             $language = '';
         } else {
             $language = $geshi->get_language_name();
         }
         $this->data = array('language' => $language, 'parsed' => $geshi->parse_code(), 'source' => $this->source);
         $this->export();
     }
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:30,代码来源:UniversalCodeCache.inc.php

示例2: 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

示例3: getHeader

 /**
  * Получаем заголовок
  *
  * @return string
  */
 protected function getHeader()
 {
     if (isset($this->attributes['title'])) {
         $title = $this->attributes['title'];
     } else {
         $title = $this->geshi->get_language_name();
     }
     return '<div class="bb_code_header"><span class="bb_code_lang">' . htmlspecialchars($title, ENT_NOQUOTES) . '</span></div>';
 }
开发者ID:thunder-spb,项目名称:xBBCode,代码行数:14,代码来源:Code.php

示例4: getPostedValue

$selectedValue = getPostedValue('selectedValue');
// Create a GeSHi instance.
$geshi = new GeSHi();
// Build a list of all the language php files located in the language
// directory
$languages = array();
if ($handle = opendir($geshi->language_path)) {
    while (($file = readdir($handle)) !== false) {
        $pos = strpos($file, '.');
        if ($pos > 0 && substr($file, $pos) == '.php') {
            $languages[] = substr($file, 0, $pos);
        }
    }
    closedir($handle);
}
// Sort the languages alphabetically
sort($languages);
// Output the start of the select block
echo '<select name="codeType" id="codeType">' . "\n";
// Output an option for each language and set the selected
// attribute if we were provided with a selectedValue
foreach ($languages as $lang) {
    $geshi->set_language($lang);
    $selected = ' ';
    if ($selectedValue == $lang) {
        $selected = ' selected="selected"';
    }
    echo '<option value="' . $lang . '"' . $selected . '>' . $geshi->get_language_name() . '</option>' . "\n";
}
// Output the end of the select block
echo '</select>' . "\n";
开发者ID:shaunfreeman,项目名称:Uthando-CMS,代码行数:31,代码来源:rj_get_lang_select.php

示例5: date

        viscacha_header('Content-Disposition: attachment; filename="' . date('d-m-Y_H-i') . '.txt"');
        echo $sourcecode['source'];
        $slog->updatelogged();
        $db->close();
        exit;
    } else {
        require_once 'classes/class.geshi.php';
        $geshi = new GeSHi($sourcecode['source'], strtolower($sourcecode['language']), 'classes/geshi');
        $geshi->set_encoding($lang->phrase('charset'));
        // Use classes for colouring
        $geshi->enable_classes();
        // Output in a div instead in a pre-element
        $geshi->set_header_type(GESHI_HEADER_DIV);
        // Linenumbers on  - each 5th element is bold
        $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5);
        $lang_name = $geshi->get_language_name();
        // Print Stylesheet
        $htmlhead .= '<style type="text/css"><!-- ' . $geshi->get_stylesheet() . ' --></style>';
        echo $tpl->parse("popup/header");
        ($code = $plugins->load('popup_hlcode_initialized')) ? eval($code) : null;
        $sourcecode['hl'] = $geshi->parse_code();
        echo $tpl->parse("popup/hlcode");
        ($code = $plugins->load('popup_hlcode_end')) ? eval($code) : null;
    }
} elseif ($_GET['action'] == "filetypes") {
    ($code = $plugins->load('popup_filetypes_query')) ? eval($code) : null;
    if (empty($_GET['type'])) {
        error($lang->phrase('query_string_error'), 'javascript:self.close();');
    }
    $result = $db->query("SELECT * FROM {$db->pre}filetypes WHERE extension LIKE '%{$_GET['type']}%'", __LINE__, __FILE__);
    $nr = $db->num_rows($result);
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:31,代码来源:popup.php

示例6: lang_name

/**
 * added function lang_name, returns human-readable Language (for proper work with my blogsystem)
 * by BadBoy_, 05/23/2008, http://badboy.pytalhost.de
 */
function lang_name($language, $path = null)
{
    $geshi = new GeSHi(null, $language, $path);
    return $geshi->get_language_name();
}
开发者ID:badboy,项目名称:devbird,代码行数:9,代码来源:geshi.php

示例7: array

        $search = array("\\", "&quot;", "&#39;", "&#92;", "&quot;", "&#39;", "&lt;", "&gt;", "&amp;");
        $replace = array("\\\\", "\"", "'", "\\", "\"", "\\'", "<", ">", "&");
        $input = str_replace($search, $replace, $input);
        $geshi = new GeSHi($input, $matches[1][$i]);
        $geshi->set_header_type(GESHI_HEADER_PRE);
        $geshi->set_overall_style('font-family:\'Courier New\', Courier; font-size:12px;');
        $geshi->set_link_styles(GESHI_LINK, 'font-weight:bold;');
        $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
        $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
        $geshi->set_footer_content($locale['bb_geshi_info']);
        $geshi->set_footer_content_style('font-family:Verdana,Arial,sans-serif;color:#808080;font-size:9px;font-weight:bold;background-color:#f0f0ff;border-top: 1px solid #d0d0d0;padding:2px;width:400px');
        if (preg_match("/\\/forum\\//i", FUSION_REQUEST) && isset($data['post_id'])) {
            $geshi_save = "<a href='" . INCLUDES . "bbcodes/geshi_bbcode_save.php?thread_id=" . $_GET['thread_id'] . "&amp;post_id=" . $data['post_id'] . "&amp;code_id=" . $i . "'><img src='" . INCLUDES . "bbcodes/images/geshi_save.png' alt='" . $locale['bb_geshi_save'] . "' title='" . $locale['bb_geshi_save'] . "' style='border:none' /></a>&nbsp;&nbsp;";
        } else {
            $geshi_save = "";
        }
        $text = preg_replace("#\\[geshi=(.*?)\\](.*?)\\[/geshi\\]#si", '$2', $text);
        $text = str_replace($matches[2][$i], "<div class='tbl-border tbl2' style='width:400px'>" . $geshi_save . "<strong>GeSHi: " . $geshi->get_language_name() . "</strong></div><div class='tbl-border tbl1' style='width:400px;height:auto;white-space:nowrap;overflow:auto;background-color:#ffffff;'><code style='white-space:nowrap'>" . $geshi->parse_code() . "</code></div>", $text);
    } else {
        $ccount = substr_count($text, "[geshi=");
        for ($i = 0; $i < $ccount; $i++) {
            if (preg_match("/\\/forum\\//i", FUSION_REQUEST) && isset($data['post_id'])) {
                $geshi_save = "<a href=\\'" . INCLUDES . "bbcodes/geshi_bbcode_save.php?thread_id=" . $_GET['thread_id'] . "&amp;post_id=" . $data['post_id'] . "&amp;code_id=" . $i . "\\'><img src=\\'" . INCLUDES . "bbcodes/images/geshi_save.png\\' alt=\\'" . $locale['bb_geshi_save'] . "\\' title=\\'" . $locale['bb_geshi_save'] . "\\' style=\\'border:none\\' /></a>&nbsp;&nbsp;";
            } else {
                $geshi_save = "";
            }
            $text = preg_replace("#\\[geshi=(.*?)\\](.*?)\\[/geshi\\]#sie", "'<div class=\\'tbl-border tbl2\\' style=\\'width:400px\\'>" . $geshi_save . "<strong><i><u>" . $locale['bb_geshi_parser1'] . ":</u></i> " . $locale['bb_geshi_parser2'] . ":</strong></div><div class=\\'tbl-border tbl1\\' style=\\'width:400px;white-space:nowrap;overflow:auto\\'><code style=\\'white-space:nowrap\\'>'.formatcode('\\2').'<br /><br /><br /></code></div>'", $text);
        }
    }
    unset($lines);
}
开发者ID:MichaelFichtner,项目名称:RadioLaFamilia,代码行数:31,代码来源:geshi_bbcode_include.php

示例8: exit

if (!file_exists($path)) {
    exit("File not found ({$path}).");
}
// Prepare GeSHi instance
$geshi = new GeSHi();
$geshi->set_language('text');
$geshi->load_from_file($path);
$geshi->set_header_type(GESHI_HEADER_PRE);
$geshi->enable_classes();
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
$geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true);
$geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true);
$geshi->set_code_style('color: #000020;', 'color: #000020;');
$geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
$geshi->set_header_content('Source code viewer - ' . $path . ' - ' . $geshi->get_language_name());
$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
$geshi->set_footer_content('Parsed in <TIME> seconds,  using GeSHi <VERSION>');
$geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Source code viewer - <?php 
echo $path;
?>
 - <?php 
$geshi->get_language_name();
?>
</title>
开发者ID:LanceSandino,项目名称:Stikked,代码行数:31,代码来源:aliased.php

示例9: 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();
 }
开发者ID:senseb,项目名称:solr-vs-elasticsearch,代码行数:41,代码来源:deans_code_highlighter.php

示例10: getAvailableLanguages

 /**
  * List of available languages.
  *
  * @return array
  *   An array mapping language code to array with the language path and
  *   full language name.
  */
 public static function getAvailableLanguages()
 {
     // Try to get it from cache (database actually).
     $cache = \Drupal::cache();
     $available_languages = $cache->get('geshifilter_available_languages_cache');
     if (!$available_languages) {
         // Not in cache: build the array of available_languages.
         $geshi_library = libraries_load('geshi');
         $available_languages = array();
         if ($geshi_library['loaded']) {
             $dirs = array($geshi_library['library path'] . '/geshi', drupal_get_path('module', 'geshifilter') . '/geshi-extra');
             foreach ($dirs as $dir) {
                 foreach (file_scan_directory($dir, '/.[pP][hH][pP]$/i') as $filename => $fileinfo) {
                     // Short name.
                     $name = $fileinfo->name;
                     // Get full name.
                     $geshi = new \GeSHi('', $name);
                     $geshi->set_language_path($dir);
                     $fullname = $geshi->get_language_name();
                     unset($geshi);
                     // Store.
                     $available_languages[$name] = array('language_path' => $dir, 'fullname' => $fullname);
                 }
             }
             ksort($available_languages);
             // Save array to database.
             $cache->set('geshifilter_available_languages_cache', $available_languages);
         }
     } else {
         $available_languages = $available_languages->data;
     }
     return $available_languages;
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:40,代码来源:GeshiFilter.php


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