1<?php 2 3use dokuwiki\Extension\SyntaxPlugin; 4 5/** 6 * DokuWiki Plugin lms (Syntax Component) 7 * 8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 9 * @author Andreas Gohr <dokuwiki@cosmocode.de> 10 */ 11class syntax_plugin_lms_include extends SyntaxPlugin 12{ 13 /** @var helper_plugin_lms */ 14 protected $hlp; 15 16 /** @var string current user */ 17 protected $user; 18 19 /** 20 * Constructor 21 */ 22 public function __construct() 23 { 24 global $INPUT; 25 $this->hlp = $this->loadHelper('lms'); 26 $this->user = $INPUT->server->str('REMOTE_USER'); 27 } 28 29 /** @inheritDoc */ 30 public function getType() 31 { 32 return 'substition'; 33 } 34 35 /** @inheritDoc */ 36 public function getPType() 37 { 38 return 'normal'; 39 } 40 41 /** @inheritDoc */ 42 public function getSort() 43 { 44 return 150; 45 } 46 47 /** @inheritDoc */ 48 public function connectTo($mode) 49 { 50 $this->Lexer->addSpecialPattern('~~LMSINCLUDE~~', $mode, 'plugin_lms_include'); 51 } 52 53 /** @inheritDoc */ 54 public function handle($match, $state, $pos, Doku_Handler $handler) 55 { 56 $data = []; 57 58 return $data; 59 } 60 61 /** @inheritDoc */ 62 public function render($mode, Doku_Renderer $renderer, $data) 63 { 64 if ($mode !== 'xhtml') { 65 return false; 66 } 67 $renderer->nocache(); 68 if (!$this->user) return true; 69 70 global $INFO; 71 $seen = $this->hlp->getLesson($INFO['id'], $this->user); 72 if ($seen === false) return true; // we're not on a lesson page 73 74 $cp = $this->hlp->getControlPage(); 75 if (!$cp) return true; 76 77 $renderer->doc .= tpl_include_page($cp, false); 78 79 return true; 80 } 81} 82