1. registerFunction( 'onPrepareContent', 'botGeshi' ); 18. 19. /** 20. * Code Highlighting Mambot 21. * 22. * Replaces
...tags with highlighted text 23. */ 24. function botGeshi( $published, &$row, &$params, $page=0 ) { 25. require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/domit/xml_saxy_shared.php' ); 26. 27. // simple performance check to determine whether bot should process further 28. if ( strpos( $row->text, 'pre>' ) === false ) { 29. return true; 30. } 31. 32. // define the regular expression for the bot 33. $regex = "#
(.*?)#s"; 34. 35. // check whether mambot has been unpublished 36. if ( !$published ) { 37. return true; 38. } 39. 40. $GLOBALS['_MAMBOT_GESHI_PARAMS'] =& $params; 41. 42. // perform the replacement 43. $row->text = preg_replace_callback( $regex, 'botGeshi_replacer', $row->text ); 44. 45. return true; 46. } 47. /** 48. * Replaces the matched tags an image 49. * @param array An array of matches (see preg_match_all) 50. * @return string 51. */ 52. function botGeshi_replacer( &$matches ) { 53. $params =& $GLOBALS['_MAMBOT_GESHI_PARAMS']; 54. include_once( dirname( __FILE__ ) . '/geshi/geshi.php' ); 55. 56. $args = SAXY_Parser_Base::parseAttributes( $matches[1] ); 57. $text = $matches[2]; 58. 59. $lang = mosGetParam( $args, 'lang', 'php' ); 60. $lines = mosGetParam( $args, 'lines', 'false' ); 61. 62. 63. $html_entities_match = array( "|\