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_listing 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('~~ACKNOWLEDGE~~', $mode, 'plugin_acknowledge_listing'); 33 } 34 35 /** @inheritDoc */ 36 public function handle($match, $state, $pos, Doku_Handler $handler) 37 { 38 } 39 40 /** @inheritDoc */ 41 public function render($mode, Doku_Renderer $renderer, $data) 42 { 43 if ($mode !== 'xhtml') { 44 return false; 45 } 46 47 $renderer->info['cache'] = false; 48 49 $renderer->doc .= '<div class="plugin-acknowledge-listing">'; 50 $renderer->doc .= $this->getListing(); 51 $renderer->doc .= '</div>'; 52 return true; 53 } 54 55 /** 56 * Returns the list of pages to be acknowledged by the user 57 * 58 * @return string 59 */ 60 protected function getListing() 61 { 62 global $INPUT; 63 global $USERINFO; 64 65 $user = $INPUT->server->str('REMOTE_USER'); 66 if ($user === '') return ''; 67 68 $groups = $USERINFO['grps']; 69 70 /** @var helper_plugin_acknowledge $helper */ 71 $helper = plugin_load('helper', 'acknowledge'); 72 $pending = $helper->getUserAssignments($user, $groups); 73 74 $html = $this->getLang('ackNotFound'); 75 76 if (!empty($pending)) { 77 $html = '<ul>'; 78 foreach ($pending as $item) { 79 $html .= '<li>' . html_wikilink(':' . $item['page']) . '</li>'; 80 } 81 $html .= '</ul>'; 82 } 83 84 return $html; 85 } 86} 87 88