1<?php 2/** 3 * DokuWiki Plugin acknowledge (Syntax Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Andreas Gohr, Anna Dabrowska <dokuwiki@cosmocode.de> 7 */ 8 9class syntax_plugin_acknowledge_assign extends DokuWiki_Syntax_Plugin 10{ 11 /** @inheritDoc */ 12 public function getType() 13 { 14 return 'substition'; 15 } 16 17 /** @inheritDoc */ 18 public function getPType() 19 { 20 return 'block'; 21 } 22 23 /** @inheritDoc */ 24 public function getSort() 25 { 26 return 155; 27 } 28 29 /** @inheritDoc */ 30 public function connectTo($mode) 31 { 32 $this->Lexer->addSpecialPattern('~~ACK:.*?~~', $mode, 'plugin_acknowledge_assign'); 33 } 34 35 36 /** @inheritDoc */ 37 public function handle($match, $state, $pos, Doku_Handler $handler) 38 { 39 $match = substr($match, 6, -2); 40 return ['assignees' => $match]; 41 } 42 43 /** @inheritDoc */ 44 public function render($mode, Doku_Renderer $renderer, $data) 45 { 46 global $ID; 47 48 if ($mode === 'metadata') { 49 /** @var helper_plugin_acknowledge $helper */ 50 $helper = plugin_load('helper', 'acknowledge'); 51 $helper->setAssignees($ID, $data['assignees']); 52 return true; 53 } 54 55 if ($mode !== 'xhtml') { 56 return false; 57 } 58 59 // a canvas to render the output to 60 $renderer->doc .= '<div class="plugin-acknowledge-assign">…</div>'; 61 return true; 62 } 63} 64 65