1<?php 2/** 3 * DokuWiki Plugin localexplorer (Syntax Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Leonard Heyman <lenehey@gmail.com> 7 */ 8class syntax_plugin_localexplorer extends \dokuwiki\Extension\SyntaxPlugin 9{ 10 /** @inheritDoc */ 11 public function getType() 12 { 13 return 'substition'; 14 } 15 16 /** @inheritDoc */ 17 public function getPType() 18 { 19 return 'normal'; 20 } 21 22 /** @inheritDoc */ 23 public function getSort() 24 { 25 return 299; // Adjust the sorting value as needed 26 } 27 28 /** @inheritDoc */ 29 public function connectTo($mode) 30 { 31 $this->Lexer->addSpecialPattern('\[\[localexplorer>[^|\]]+\|[^]]+\]\]', $mode, 'plugin_localexplorer'); 32 } 33 34 /** @inheritDoc */ 35 public function handle($match, $state, $pos, Doku_Handler $handler) 36 { 37 // Extract path and title from the match 38 preg_match('/\[\[localexplorer>([^|]+)\|([^]]+)\]\]/i', $match, $matches); 39 $path = $matches[1]; 40 $title = $matches[2]; 41 42 // Construct the HTML link 43 $html = '<a href="localexplorer:' . str_replace('\\', '/', $path) . '">' . $title . '</a>'; 44 45 return $html; 46 } 47 48 /** @inheritDoc */ 49 public function render($mode, Doku_Renderer $renderer, $data) 50 { 51 if ($mode === 'xhtml') { 52 $renderer->doc .= $data; 53 return true; 54 } 55 return false; 56 } 57}