Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. function run_geshi_filter(array $params = array())
  2.     {
  3.       //If line numbers is explicitely turned on
  4.         if (in_array('line_numbers_on', $params))
  5.             $this->line_numbers_on = TRUE;
  6.            
  7.         //If line numbers is explicitely turned off (this one wins, if both defined)
  8.     if (in_array('line_numbers_off', $params))
  9.       $this->line_numbers_on = FALSE;
  10.        
  11.     //Get the output from CI
  12.         $ci_output = $this->ci->output->get_output();
  13.        
  14.         //If there are <sourcecode>..</sourcecode> tags, process them
  15.         if (strpos($ci_output, "<sourcecode"))
  16.         {
  17.             //Tried to use REGEX, but there were bugs!  Arg!
  18.             $begin_searching_at = 0;
  19.             while (strpos($ci_output, "<sourcecode", $begin_searching_at))
  20.             {
  21.                 $begin = strpos($ci_output, "<sourcecode", $begin_searching_at);
  22.                 $end = strpos($ci_output, "</sourcecode>", $begin_searching_at) + strlen("</sourcecode>");
  23.                
  24.                 //Test
  25.                 $ci_output = substr($ci_output, 0, $begin) . @$this->_set_geshi_content(substr($ci_output, $begin, $end-$begin)) . substr($ci_output, $end);
  26.                
  27.                 $begin_searching_at = $end;
  28.             }
  29.            
  30.             echo $ci_output;
  31.         }
  32.         else
  33.           echo $ci_output; 
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement