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; }
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; }
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"); }
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); }
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; }
/** * 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; }
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>'; }