locallink.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Include plugin (locallink component)
  4. *
  5. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  6. * @author Michael Hamann <michael@content-space.de>
  7. */
  8. class syntax_plugin_include_locallink extends DokuWiki_Syntax_Plugin {
  9. function getType() {
  10. return 'formatting';
  11. }
  12. function getSort() {
  13. return 50;
  14. }
  15. function handle($match, $state, $pos, Doku_Handler $handler) {
  16. // this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
  17. }
  18. /**
  19. * Displays a local link to an included page
  20. *
  21. * @author Michael Hamann <michael@content-space.de>
  22. */
  23. function render($mode, Doku_Renderer $renderer, $data) {
  24. global $ID;
  25. if ($mode == 'xhtml') {
  26. /** @var Doku_Renderer_xhtml $renderer */
  27. list($hash, $name, $id) = $data;
  28. // construct title in the same way it would be done for internal links
  29. $default = $renderer->_simpleTitle($id);
  30. $name = $renderer->_getLinkTitle($name, $default, $isImage, $id);
  31. $title = $ID.' ↵';
  32. $renderer->doc .= '<a href="#'.$hash.'" title="'.$title.'" class="wikilink1">';
  33. $renderer->doc .= $name;
  34. $renderer->doc .= '</a>';
  35. return true;
  36. }
  37. return false;
  38. }
  39. }
  40. // vim:ts=4:sw=4:et: