' ) === false) { return $text; } $regex = "#
(.*?)
#s"; $text = preg_replace_callback ( $regex, array ('self', 'match' ), $text ); return $text; } public function match(&$matches) { $args = Dominoo_GeshiFilter::parseAttribs ( $matches [1] ); $text = $matches [2]; $lang = $args ["lang"]; $lines = $args ["lines"]; $header = $args ["header"]; $geshi = new GeSHi ( $text, $lang ); $geshi->enable_line_numbers ( (($lines == "none") ? GESHI_NORMAL_LINE_NUMBERS : GESHI_FANCY_LINE_NUMBERS) ); $geshi->enable_keyword_links ( false ); $geshi->set_header_type(GESHI_HEADER_DIV); if ($header) { $geshi->set_header_content($header); } if($lines == "none") { $geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS); } $geshi->enable_classes (); $text = $geshi->parse_code (); return "
$text
"; } static function parseAttribs($attribs) { $attr = explode(" ", $attribs ); $attributes = array (); foreach ( $attr as $attribute ) { $a = explode ( "=", $attribute ); $regex = '/\"(.*)\"/'; preg_match( $regex, $a[1], $m ); $attributes[$a[0]] = $m[1]; } return $attributes; } } ?>