You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

124 lines
3.9 KiB

  1. <?php
  2. /**
  3. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  4. *
  5. * class plugin_ckgedit_specials
  6. * @author Myron Turner <turnermm02@shaw.ca>
  7. */
  8. // must be run within Dokuwiki
  9. if(!defined('DOKU_INC')) die();
  10. if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
  11. require_once(DOKU_PLUGIN.'syntax.php');
  12. //define ('CKGEDIT_IMAGES', DOKU_URL . 'lib/plugins/ckgedit/images/');
  13. //define ('CK_IMG_PATH',DOKU_INC . 'lib/plugins/ckgedit/images/');
  14. if(!defined('DOKU_LF')) define ('DOKU_LF',"\n");
  15. if(!defined('DOKU_TAB')) define ('DOKU_TAB',"\t");
  16. /**
  17. * All DokuWiki plugins to extend the parser/rendering mechanism
  18. * need to inherit from this class
  19. */
  20. class syntax_plugin_ckgedit_specials extends DokuWiki_Syntax_Plugin {
  21. /**
  22. * What kind of syntax are we?
  23. */
  24. function getType(){
  25. return 'substition';
  26. }
  27. /**
  28. * What about paragraphs?
  29. */
  30. function getPType(){
  31. // return 'stack';
  32. return 'block';
  33. }
  34. /**
  35. * Where to sort in?
  36. */
  37. function getSort(){
  38. return 155;
  39. }
  40. /**
  41. * Connect pattern to lexer
  42. */
  43. function connectTo($mode) {
  44. $this->Lexer->addSpecialPattern('~~MULTI_PLUGIN_OPEN~~',$mode,'plugin_ckgedit_specials');
  45. $this->Lexer->addSpecialPattern('~~MULTI_PLUGIN_CLOSE~~',$mode,'plugin_ckgedit_specials');
  46. $this->Lexer->addSpecialPattern('~~COMPLEX_TABLES~~',$mode,'plugin_ckgedit_specials');
  47. $this->Lexer->addSpecialPattern('~~NO_STYLING~~',$mode,'plugin_ckgedit_specials');
  48. $this->Lexer->addEntryPattern('~~START_HTML_BLOCK~~(?=.*?~~CLOSE_HTML_BLOCK~~)',$mode,'plugin_ckgedit_specials');
  49. $this->Lexer->addSpecialPattern('~~AUTO_INTERNAL_LINKS~~',$mode,'plugin_ckgedit_specials');
  50. }
  51. function postConnect() { $this->Lexer->addExitPattern('~~CLOSE_HTML_BLOCK~~','plugin_ckgedit_specials'); }
  52. /**
  53. * Handle the match
  54. */
  55. function handle($match, $state, $pos, Doku_Handler $handler){
  56. $class = "";
  57. $xhtml = "";
  58. switch($state) {
  59. case DOKU_LEXER_SPECIAL:
  60. if(preg_match('/OPEN/', $match)) {
  61. return array($state, "<span class='multi_p_open'></span>" );
  62. }
  63. elseif(preg_match('/CLOSE/', $match)) {
  64. return array($state, "<span class='multi_p_close'></span>" );
  65. }
  66. elseif(preg_match('/(TABLES|STYLING|AUTO_INTERNAL)/', $match)) {
  67. return array($state, "" );
  68. }
  69. case DOKU_LEXER_ENTER : return array($state, '');
  70. case DOKU_LEXER_UNMATCHED :
  71. $match = str_replace('<div class="table">',"",$match);
  72. $match = preg_replace('/<\/?code>/ms',"",$match);
  73. return array($state, $match);
  74. case DOKU_LEXER_EXIT : return array($state, '');
  75. }
  76. return array($state, "" );
  77. }
  78. /**
  79. * Create output
  80. */
  81. function render($mode, Doku_Renderer $renderer, $data) {
  82. if($mode == 'xhtml'){
  83. list($state, $xhtml) = $data;
  84. switch ($state) {
  85. case DOKU_LEXER_SPECIAL:
  86. $renderer->doc .= DOKU_LF . $xhtml . DOKU_LF;
  87. return true;
  88. case DOKU_LEXER_ENTER : $renderer->doc .= ""; break;
  89. case DOKU_LEXER_UNMATCHED :
  90. $renderer->doc .= $xhtml; break;
  91. case DOKU_LEXER_EXIT : $renderer->doc .= ""; break;
  92. }
  93. return true;
  94. }
  95. return false;
  96. }
  97. function write_debug($what) {
  98. $handle = fopen("blog_pats.txt", "a");
  99. fwrite($handle,"$what\n");
  100. fclose($handle);
  101. }
  102. }