* This method is important for correct XHTML nesting. It returns * one of the following values: *
** The $aState parameter gives the type of pattern * which triggered the call to this method: *
** The method checks for the given $aFormat and returns * FALSE when a format isn't supported. $aRenderer * contains a reference to the renderer object which is currently * handling the rendering. The contents of $aData is the * return value of the handle() method. *
* @param $mode String The output format to generate. * @param &$renderer Doku_Renderer A reference to the renderer object. * @param $data Array The data created by the handle() method. * @return Boolean * TRUE if rendered successfully, or * FALSE otherwise. * @public * @see handle() */ public function render($mode, Doku_Renderer &$renderer, $data) { global $ID; list($state, $todotitle, $todoindex, $todouser, $checked) = $data; if($mode == 'xhtml') { /** @var $renderer Doku_Renderer_xhtml */ if($state == DOKU_LEXER_UNMATCHED) { #Output our result $renderer->doc .= $this->_createTodoItem($renderer, $todotitle, $todoindex, $todouser, $checked, $ID); return true; } } elseif($mode == 'metadata') { /** @var $renderer Doku_Renderer_metadata */ if($state == DOKU_LEXER_UNMATCHED) { $id = $this->_composePageid($todotitle); $renderer->internallink($id, $todotitle); } } return false; } /** * Parse the arguments of todotag * * @param string $todoargs * @return array(bool, false|string) with checked and user */ public function _parseTodoArgs($todoargs) { $checked = $todouser = false; if(strpos($todoargs, '#') !== false) { $checked = true; } if(($userStartPos = strpos($todoargs, '@')) !== false) { $userraw = substr($todoargs, $userStartPos); $x = preg_match('%@([-.\w]+)%i', $userraw, $usermatch); if($x) { $todouser = $usermatch[1]; } } return array($checked, $todouser); } /** * @param Doku_Renderer_xhtml &$renderer * @param string $todotitle Title of todoitem * @param int $todoindex which number the todoitem has, null is when not at the page * @param string $todouser User assigned to todoitem * @param bool $checked whether item is done * @param string $id of page * @return string html of an item */ public function _createTodoItem(&$renderer, $todotitle, $todoindex, $todouser, $checked, $id) { //set correct context global $ID; $oldID = $ID; $ID = $id; $return = ' '; if($todouser) { $return .= '[' . hsc($todouser) . ']'; } $spanclass = 'todotext'; if($this->getConf("CheckboxText") && !$this->getConf("AllowLinks")) { $spanclass .= ' clickabletodo todohlght'; } $return .= ''; if($checked && $this->getConf("Strikethrough")) { $return .= '| ' . $page . ' | |
|---|---|
| '; // in case of integration with searchpattern there is no chance to find the index of an element $renderer->doc .= $this->_createTodoItem($renderer, $todotitle, $todoindex, $todouser, $checked, $page); $renderer->doc .= ' |
'.$value.''; break; case 'intable:count': //$renderer->doc .= 'normal count on page '.$page.':
'.$value.''; break; case 'intable:suffix': //$renderer->doc .= 'End on Page '.$page.''; break; default: break; } // false means, that this handler method does not output anything. all should be done by searchpattern plugin return false; } } //Setup VIM: ex: et ts=4 enc=utf-8 :