PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/geshi/actions.php

http://0byte.googlecode.com/
PHP | 35 lines | 31 code | 4 blank | 0 comment | 6 complexity | 5a479d97c34927f63b036fe1799b67eb MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. $txt = str_replace("[code]", '[code=]', $txt);
  3. preg_match_all('/\[code([^\]]*?)\]/is',$txt, $lang);
  4. $arr = preg_split("/\[(.?)code(.*?)\]/",$txt);
  5. $q = 1;
  6. $txt = "";
  7. $replace = array('<br />' => "\n", '&lt;' => '<', '&gt;' => '>', '&#39;' => "'", '&#34;' => '"','&amp;'=>'&');
  8. foreach ($arr as $i) {
  9. if ($q % 2 == 0) {
  10. require_once 'lib/geshi/geshi.php';
  11. $i = str_replace(array_keys($replace), array_values($replace), $i);
  12. $lang[$q / 2 - 1] = preg_replace('/\[code\=(.*?)\]/is', "$1", $lang[$q / 2 - 1]);
  13. $i = geshi_highlight($i, $lang[0][$q / 2 - 1], null, true);
  14. $i = str_replace(array('[code', '[/code]'), '', $i);
  15. $cnt = substr_count($i, "<br />");
  16. $ln = "";
  17. if ($cnt != 0) {
  18. for ($e = 2; $e <= ($cnt+1); $e++) {
  19. $ln .= $e . "<br />";
  20. }
  21. $i = render_util('code_lines', array('lang' => $lang[0][$q / 2 - 1], 'code' => $i, 'lines' => $ln));
  22. } else {
  23. $i = render_util('code_utils', array('lang' => $lang[0][$q / 2 - 1], 'code' => $i));
  24. }
  25. }
  26. $txt .= $i;
  27. $q++;
  28. }
  29. $txt = str_replace("<a href", "<a rel='nofollow' href", $txt);
  30. $text=$txt;
  31. ?>