本文整理汇总了PHP中GeSHi::get_supported_languages方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::get_supported_languages方法的具体用法?PHP GeSHi::get_supported_languages怎么用?PHP GeSHi::get_supported_languages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::get_supported_languages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
if (false === Common::isFile(GWF_GESHI_PATH)) {
return '';
// FIXME: {gizmore} log it? GESHI_PATH is may not readable
}
require_once GWF_GESHI_PATH;
$geshi = new GeSHi();
$langs = $geshi->get_supported_languages(false);
$key = htmlspecialchars(Common::getGetString('key', ''), ENT_QUOTES);
sort($langs);
// $this->niceArray($langs, false, '-------')
$this->niceArray($langs, 'python', 'Python');
$this->niceArray($langs, 'perl', 'Perl');
$this->niceArray($langs, 'cpp', 'CPP');
$this->niceArray($langs, 'php', 'PHP');
$back = $this->module->lang('th_lang') . ':' . PHP_EOL;
$back .= '<select id="bb_code_lang_sel_' . $key . '">' . PHP_EOL;
$back .= '<option value="0">' . $this->module->lang('th_lang') . '</option>' . PHP_EOL;
foreach ($langs as $lang) {
$back .= sprintf('<option value="%s">%s</option>', $lang, $lang) . PHP_EOL;
}
$back .= '</select>' . PHP_EOL;
$back .= $this->module->lang('th_title') . ': <input type="text" id="bb_code_title_' . $key . '" size="20" value="" />' . PHP_EOL;
$back .= '<input type="submit" value="' . $this->module->lang('btn_code') . '" onclick="return bbInsertCodeNow(\'' . $key . '\');" />' . PHP_EOL;
return $back;
}
示例2: onExtra
function onExtra($name)
{
$output = NULL;
if ($name == "header") {
if (!$this->yellow->config->get("highlightStylesheetDefault")) {
$locationStylesheet = $this->yellow->config->get("serverBase") . $this->yellow->config->get("pluginLocation") . "highlight.css";
$fileNameStylesheet = $this->yellow->config->get("pluginDir") . "highlight.css";
if (is_file($fileNameStylesheet)) {
$output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$locationStylesheet}\" />\n";
}
} else {
$geshi = new GeSHi();
$geshi->set_language_path($this->yellow->config->get("pluginDir") . "/highlight/");
foreach ($geshi->get_supported_languages() as $language) {
if ($language == "geshi") {
continue;
}
$geshi->set_language($language);
$output .= $geshi->get_stylesheet(false);
}
$output = "<style type=\"text/css\">\n{$output}</style>";
}
}
return $output;
}
示例3: execute
public function execute()
{
global $IP;
$geshi = new GeSHi();
$header = '// Generated by ' . basename(__FILE__) . ' on ' . date(DATE_RFC2822) . "\n";
$langs = array_values(array_filter($geshi->get_supported_languages(false), 'ctype_alnum'));
sort($langs);
$replace = array('[' => "array(\n\t", ']' => "\n);\n", '",' => "\",\n\t");
$code = "<?php\n" . $header . "global \$wgGeSHiSupportedLanguages;\n" . '$wgGeSHiSupportedLanguages = ' . strtr(json_encode($langs), $replace);
file_put_contents(__DIR__ . '/../SyntaxHighlight_GeSHi.langs.php', $code);
$this->output("Updated language list written to SyntaxHighlight_GeSHi.langs.php\n");
}
示例4: setFormDef_ViewHelper
public function setFormDef_ViewHelper()
{
require_once 'geshi/geshi.php';
$geshi = new GeSHi();
$supported = $geshi->get_supported_languages();
$option = array();
foreach ($supported as $sl) {
$option[$sl] = ucfirst($sl);
}
$sl = asort($option);
$ct = $this->getDef('content_type');
$ct['option'] = array('text' => 'Text', 'php' => 'PHP', 'diff' => 'Diff', '-' => '------') + $option;
$this->setDef('content_type', $ct);
}
示例5: execute
public function execute(GWF_Module $module)
{
require_once GWF_GESHI_PATH;
$geshi = new GeSHi();
$langs = $geshi->get_supported_languages(false);
sort($langs);
// $this->niceArray($langs, false, '-------')
$this->niceArray($langs, 'python', 'Python');
$this->niceArray($langs, 'perl', 'Perl');
$this->niceArray($langs, 'cpp', 'CPP');
$this->niceArray($langs, 'php', 'PHP');
$back = $module->lang('th_lang') . ':' . PHP_EOL;
$back .= '<select id="bb_code_lang_sel">' . PHP_EOL;
$back .= '<option value="0">' . $module->lang('th_lang') . '</option>' . PHP_EOL;
foreach ($langs as $lang) {
$back .= sprintf('<option value="%s">%s</option>', $lang, $lang) . PHP_EOL;
}
$back .= '</select>' . PHP_EOL;
$back .= $module->lang('th_title') . ': <input type="text" name="bb_code_title" id="bb_code_title" size="20" value="" />' . PHP_EOL;
$back .= '<input type="submit" name="bb_code_insert" value="' . $module->lang('btn_code') . '" onclick="return bbInsertCodeNow();" />' . PHP_EOL;
return $back;
}
示例6: dirname
/**
* Returns a list of valid languages from GeSHi
* @return DatObjectSet
*/
static function get_valid_languages()
{
require_once dirname(__DIR__) . '/thirdparty/geshi/geshi.php';
$g = new GeSHi();
$languages = new DataObjectSet();
foreach ($g->get_supported_languages(false) as $language) {
$languages->push(new ArrayData(array('ID' => $language, 'Name' => $language)));
}
$languages->sort('Name');
return $languages;
}
示例7: DoCode
function DoCode($bbcode, $action, $name, $default, $params, $content) {
static $enabled = false;
static $languages = array();
if ($action == BBCODE_CHECK)
return true;
$type = isset ( $params ["type"] ) ? $params ["type"] : "php";
if ($type == 'js') {
$type = 'javascript';
} elseif ($type == 'html') {
$type = 'html4strict';
}
if ($enabled === false && KunenaFactory::getConfig ()->highlightcode) {
$enabled = true;
if (version_compare(JVERSION, '1.6','>')) {
// Joomla 1.6+
// TODO: use the content plugin instead
require_once JPATH_ROOT.'/plugins/content/geshi/geshi/geshi.php';
} else {
// Joomla 1.5
jimport ( 'geshi.geshi' );
}
$languages = GeSHi::get_supported_languages();
}
if ($enabled && in_array ( $type, $languages )) {
$geshi = new GeSHi ( $bbcode->UnHTMLEncode($content), $type );
$geshi->enable_keyword_links ( false );
$code = $geshi->parse_code ();
} else {
$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);
$code = '<pre xml:'.$type.'>'.$content.'</pre>';
}
return '<div class="highlight">'.$code.'</div>';
}