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 render($mode, Doku_Renderer $renderer, $data) 37 { 38 if ($mode !== 'xhtml') { 39 return false; 40 } 41 42 $renderer->info['cache'] = false; 43 44 $renderer->doc .= '<div class="plugin-acknowledge-listing">'; 45 $renderer->doc .= $this->getListing(); 46 $renderer->doc .= '</div>'; 47 return true; 48 } 49 50 /** 51 * Returns the list of pages to be acknowledged by the user 52 * 53 * @return string 54 */ 55 protected function getListing() 56 { 57 global $INPUT; 58 $user = $INPUT->server->str('REMOTE_USER'); 59 if ($user === '') return ''; 60 61 /** @var helper_plugin_acknowledge $helper */ 62 $helper = plugin_load('helper', 'acknowledge'); 63 $all = $helper->getUserAssignments($user); 64 $pending = $helper->filterAcknowledged($user, $all); 65 66 $html = $this->getLang('ackNotFound'); 67 68 if (!empty($pending)) { 69 $html = '<ul>'; 70 foreach ($pending as $item) { 71 $html .= sprintf('<li><a href="%s">%s</a></li>', wl($item['page']), $item['page']); 72 } 73 $html .= '</ul>'; 74 } 75 76 return $html; 77 } 78} 79 80