*/ class syntax_plugin_aichat_chat extends SyntaxPlugin { /** @inheritDoc */ public function getType() { return 'substition'; } /** @inheritDoc */ public function getPType() { return 'block'; } /** @inheritDoc */ public function getSort() { return 155; } /** @inheritDoc */ public function connectTo($mode) { $this->Lexer->addSpecialPattern(']+)*>.*?(?:<\/aichat>)', $mode, 'plugin_aichat_chat'); } /** @inheritDoc */ public function handle($match, $state, $pos, Doku_Handler $handler) { $match = substr($match, 7, -9); [$params, $body] = explode('>', $match, 2); $params = explode(' ', $params); return ['params' => $params, 'body' => $body]; } /** @inheritDoc */ public function render($format, Doku_Renderer $renderer, $data) { if ($format !== 'xhtml') { return false; } if ($this->getConf('restricted')) $renderer->nocache(); $helper = plugin_load('helper', 'aichat'); if (!$helper->userMayAccess()) { return true; } $hello = trim((string)$data['body']); if (!$hello) $hello = $this->getLang('hello'); $opts = [ 'hello' => $hello, 'placeholder' => $this->getLang('placeholder'), 'url' => DOKU_BASE . 'lib/exe/ajax.php?call=aichat', 'title-send' => $this->getLang('send-button'), 'title-restart' => $this->getLang('restart-button'), 'title-pagecontext' => $this->getLang('pagecontext'), ]; $html = ''; if (in_array('button', $data['params'])) { $opts = [ 'label' => $this->getLang('title'), 'title-close' => $this->getLang('close-button'), 'title-fullscreen' => $this->getLang('fullscreen-button'), ]; if (in_array('float', $data['params'])) $opts['class'] = 'float'; $html = '' . $html . ''; } $renderer->doc .= $html; return true; } }