class.wiki2xhtml.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__FILE__).'/class.wiki2xhtml.basic.php';
  23. class wiki2xhtml extends wiki2xhtmlBasic
  24. {
  25. function wiki2xhtml()
  26. {
  27. parent::wiki2xhtml();
  28. # Mise en place des options
  29. $this->setOpt('active_title',1);
  30. $this->setOpt('active_setext_title',0);
  31. $this->setOpt('active_hr',1);
  32. $this->setOpt('active_lists',1);
  33. $this->setOpt('active_quote',1);
  34. $this->setOpt('active_pre',1);
  35. $this->setOpt('active_empty',1);
  36. $this->setOpt('active_auto_urls',0);
  37. $this->setOpt('active_urls',1);
  38. $this->setOpt('active_auto_img',0);
  39. $this->setOpt('active_img',1);
  40. $this->setOpt('active_anchor',1);
  41. $this->setOpt('active_em',1);
  42. $this->setOpt('active_strong',1);
  43. $this->setOpt('active_br',1);
  44. $this->setOpt('active_q',1);
  45. $this->setOpt('active_code',1);
  46. $this->setOpt('active_acronym',1);
  47. $this->setOpt('active_ins',1);
  48. $this->setOpt('active_del',1);
  49. $this->setOpt('active_footnotes',1);
  50. $this->setOpt('active_wikiwords',0);
  51. $this->setOpt('active_macros',1);
  52. $this->setOpt('parse_pre',1);
  53. $this->setOpt('active_fix_word_entities',0);
  54. $this->setOpt('active_fr_syntax',0);
  55. $this->setOpt('first_title_level',3);
  56. $this->setOpt('note_prefix','wiki-footnote');
  57. $this->setOpt('note_str','<div class="footnotes"><h4>Notes</h4>%s</div>');
  58. $this->setOpt('words_pattern','((?<![A-Za-z0-9µÀ-ÖØ-öø-ÿ])([A-ZÀ-ÖØ-Þ][a-zµß-öø-ÿ]+){2,}(?![A-Za-z0-9µÀ-ÖØ-öø-ÿ]))');
  59. $this->foot_notes = array();
  60. $share_dir = dirname(__FILE__).'/../../share/';
  61. $acro_file = $share_dir.'wiki-acronyms.txt';
  62. $acro_user = $share_dir.'wiki-acronyms-user.txt';
  63. if (file_exists($acro_user)) {
  64. $acro_file = $acro_user;
  65. }
  66. $this->setOpt('acronyms_file',$acro_file);
  67. $this->acro_table = $this->__getAcronyms();
  68. $this->registerFunction('url:post',array('wiki2xhtml','postLink'));
  69. }
  70. function postLink($url,$content)
  71. {
  72. if (!isset($GLOBALS['blog'])) {
  73. return null;
  74. }
  75. $id = substr($url,5);
  76. $post = $GLOBALS['blog']->getPostByID($id);
  77. if ($post === false || $post->isEmpty()) {
  78. return false;
  79. }
  80. $res['url'] = $post->getPermURL();
  81. if ($url == $content) {
  82. $res['content'] = $post->f('post_titre');
  83. } else {
  84. $res['content'] = $content;
  85. $res['title'] = $post->f('post_titre');
  86. }
  87. if ($post->f('post_lang')) {
  88. $res['lang'] = $post->f('post_lang');
  89. }
  90. return $res;
  91. }
  92. }
  93. # Wiki2xhtml pour les commentaires
  94. class wiki2xhtmlComment extends wiki2xhtmlBasic
  95. {
  96. function wiki2xhtmlComment()
  97. {
  98. parent::wiki2xhtml();
  99. $this->setOpt('active_title',0);
  100. $this->setOpt('active_setext_title',0);
  101. $this->setOpt('active_hr',0);
  102. $this->setOpt('active_lists',1);
  103. $this->setOpt('active_quote',0);
  104. $this->setOpt('active_pre',1);
  105. $this->setOpt('active_empty',0);
  106. $this->setOpt('active_auto_urls',0);
  107. $this->setOpt('active_urls',1);
  108. $this->setOpt('active_auto_img',0);
  109. $this->setOpt('active_img',0);
  110. $this->setOpt('active_anchor',0);
  111. $this->setOpt('active_em',1);
  112. $this->setOpt('active_strong',1);
  113. $this->setOpt('active_br',1);
  114. $this->setOpt('active_q',1);
  115. $this->setOpt('active_code',1);
  116. $this->setOpt('active_acronym',1);
  117. $this->setOpt('active_ins',1);
  118. $this->setOpt('active_del',1);
  119. $this->setOpt('active_footnotes',0);
  120. $this->setOpt('active_wikiwords',0);
  121. $this->setOpt('active_macros',0);
  122. $this->setOpt('parse_pre',0);
  123. $this->setOpt('active_fix_word_entities',0);
  124. $this->setOpt('active_fr_syntax',0);
  125. }
  126. }
  127. ?>