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(); } }
while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); $fileName = $fileURL; if(ereg("[^/]+\.java", $fileURL, $matches)){ $fileName = $matches[0]; } include_once 'geshi/geshi.php'; $geshi = new GeSHi($contents, 'java'); $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->set_numbers_highlighting(false); $geshi->set_overall_style('color: rgb(0,0,0); border: 1px solid #d0d0d0; background-color: #f0f0f0;', true); // Note the use of set_code_style to revert colours... $geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: black;', 'font-weight: bold; color: blue;', true); //for methods $geshi->set_methods_style(1, "color: black;", false); //for multi-line comments /**/ $geshi->set_comments_style('MULTI','color: rgb(63,127,95); font-style: code;', false); //for 'import' keyword // $geshi->set_comments_style(2,'color: rgb(127,0,85); font-weight: bold;', false); //for string constants $geshi->set_strings_style('color: rgb(42,0,255);', true);