/** * loadDocument - Loads the current document into a new GeSHi instance * used for syntax highlighting using the [code][/code] block. * * @param $code - The code to be parsed through GeSHi * @param $lang - The language the code falls under * * @return void */ public function loadDocument($code, $lang) { $this->_language = $lang; // Set language of CodeDocument $this->_geshi = new GeSHi($code, strtolower($lang)); // Create new GeSHi instance using code and lang provided $this->_geshi->set_header_type(GESHI_HEADER_PRE); // Set header type | For display type $this->_geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); // Enable line numbers $this->_geshi->enable_keyword_links(false); // Disable keyword links in code $this->_geshi->set_tab_width(4); // Set the tab width of code $this->_geshi->set_overall_class('codeBlock'); // Class for custom styling $this->_geshi->set_code_style('font-family: dejavu, monospace; font-size: 11px;', true); }
public function add($d) { global $LANGUAGES_FILES; if (!$this->check($d)) { return false; } require_once b1n_PATH_GESHI . '/geshi.php'; $geshi = new GeSHI($d['source'], $LANGUAGES_FILES[$d['language']], b1n_PATH_GESHI . '/geshi'); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10); $geshi->set_header_type(GESHI_HEADER_DIV); $highlight = $geshi->parse_code(); $this->sql->query("BEGIN TRANSACTION"); $query = "\n INSERT INTO paste (\n lan_id,\n pas_author,\n pas_title,\n pas_source,\n pas_source_text,\n pas_length,\n pas_md5,\n pas_usr_ip\n )\n VALUES (\n " . Data::inBd($d['language']) . ",\n " . Data::inBd($d['author']) . ",\n " . Data::inBd($d['title']) . ",\n " . Data::inBd($highlight) . ",\n " . Data::inBd($d['source']) . ",\n " . Data::inBd(strlen(trim($d['source']))) . ",\n md5(" . Data::inBd($d['source']) . "),\n " . Data::inBd($_SERVER['REMOTE_ADDR']) . "\n )"; if ($this->sql->query($query)) { $id = $this->sql->singleQuery("\n SELECT CURRVAL('paste_pas_id_seq') AS id"); $id['id'] = base_convert($id['id'], 10, b1n_CODE_BASE); $this->sql->query("COMMIT TRANSACTION"); return $id; } Error::msg("Erro inesperado", __METHOD__); }