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.
 
 
 
 
 

142 lines
3.7 KiB

  1. <?php
  2. /**
  3. * Renderer for XHTML output
  4. *
  5. * @author Pierre Spring <pierre.spring@liip.ch>
  6. * @author Myron Turner <turnermm02@shaw.ca>
  7. */
  8. // must be run within Dokuwiki
  9. if(!defined('DOKU_INC')) die();
  10. // we inherit from the XHTML renderer instead directly of the base renderer
  11. require_once DOKU_INC.'inc/parser/xhtml.php';
  12. /**
  13. * The Renderer
  14. */
  15. class renderer_plugin_ckgedit extends Doku_Renderer_xhtml
  16. {
  17. var $ver_anteater;
  18. var $dwiki_version;
  19. /**
  20. * Establish version in constructor
  21. * @author Myron Turner <turnermm02@shaw.ca>
  22. */
  23. function __construct() {
  24. global $conf;
  25. $this->ver_anteater = mktime(0,0,0,11,7,2010);
  26. $this->dwiki_version=mktime(0,0,0,01,01,2008);
  27. if(isset($conf['fnencode'])) {
  28. $this->ver_anteater = mktime(0,0,0,11,7,2010);
  29. $this->dwiki_version=mktime(0,0,0,11,7,2010);
  30. }
  31. else if(function_exists('getVersionData')) {
  32. $verdata= getVersionData();
  33. if(isset($verdata) && preg_match('/(\d+)-(\d+)-(\d+)/',$verdata['date'],$ver_date)) {
  34. if($ver_date[1] >= 2005 && ($ver_date[3] > 0 && $ver_date[3] < 31) && ($ver_date[2] > 0 && $ver_date[2] <= 12)) {
  35. // month day year
  36. $this->dwiki_version=@mktime(0, 0, 0, $ver_date[2],$ver_date[3], $ver_date[1]);
  37. if(!$this->dwiki_version) $this->dwiki_version = mktime(0,0,0,01,01,2008);
  38. $this->ver_anteater = mktime(0,0,0,11,7,2010);
  39. }
  40. }
  41. }
  42. }
  43. /**
  44. * the format we produce
  45. */
  46. function getFormat()
  47. {
  48. // this should be 'ckgedit' usally, but we inherit from the xhtml renderer
  49. // and produce XHTML as well, so we can gain magically compatibility
  50. // by saying we're the 'xhtml' renderer here.
  51. return 'xhtml';
  52. }
  53. /*
  54. * The standard xhtml renderer adds anchors we do not need.
  55. */
  56. function header($text, $level, $pos, $returnonly = false) {
  57. // write the header
  58. $this->doc .= DOKU_LF.'<h'.$level.'>';
  59. $this->doc .= $this->_xmlEntities($text);
  60. $this->doc .= "</h$level>".DOKU_LF;
  61. }
  62. /*
  63. * The FCKEditor prefers <b> over <strong>
  64. */
  65. function strong_open()
  66. {
  67. $this->doc .= '<b>';
  68. }
  69. function strong_close()
  70. {
  71. $this->doc .= '</b>';
  72. }
  73. /*
  74. * The FCKEditor prefers <strike> over <del>
  75. */
  76. function deleted_open()
  77. {
  78. $this->doc .= '<strike>';
  79. }
  80. function deleted_close()
  81. {
  82. $this->doc .= '</strike>';
  83. }
  84. /**
  85. * isolate table from bottom and top editor window margins
  86. * @author Myron Turner <turnermm02@shaw.ca>
  87. */
  88. function table_close($pos = NULL)
  89. {
  90. global $conf;
  91. $this->doc .= "</table>\n<span class='np_break'>&nbsp;</span>\n";
  92. if($this->dwiki_version >= $this->ver_anteater) {
  93. $this->doc .= "</div>";
  94. }
  95. }
  96. function table_open($maxcols = null, $numrows = null, $pos = null, $classes = NULL){
  97. $this->doc .= "\n<span class='np_break'>&nbsp;</span>\n";
  98. parent::table_open($maxcols, $numrows, $pos,$classes);
  99. }
  100. /*
  101. * Dokuwiki displays __underlines__ as follows
  102. * <em class="u">underlines</em>
  103. * in the fck editor this conflicts with
  104. * the //italic// style that is displayed as
  105. * <em>italic</em>
  106. * which makes the rathe obvious
  107. */
  108. function underline_open()
  109. {
  110. $this->doc .= '<u>';
  111. }
  112. function underline_close()
  113. {
  114. $this->doc .= '</u>';
  115. }
  116. function listcontent_open()
  117. {
  118. }
  119. function listcontent_close()
  120. {
  121. }
  122. }