Lexer->addSpecialPattern('\',$mode,'plugin_dirtylittlehelper_'.$this->getPluginComponent()); $this->Lexer->addSpecialPattern('\',$mode,'plugin_dirtylittlehelper_'.$this->getPluginComponent()); $this->Lexer->addSpecialPattern('\',$mode,'plugin_dirtylittlehelper_'.$this->getPluginComponent()); } /** * Handle matches of the DLH syntax * * @param string $match The match of the syntax * @param int $state The state of the handler * @param int $pos The position in the document * @param Doku_Handler $handler The handler * * @return array Data for the renderer */ public function handle($match, $state, $pos, Doku_Handler $handler) { switch ($state) { case DOKU_LEXER_SPECIAL: if ($match == ''){ return array( $state, 'TREE',$match); }elseif( $match == ''){ $this->dlh_tree_no = true; return array($state, 'NOTREE',$match); }elseif( $match == ''){ $this->dlh_tree_no = true; $this->dlh_tree_force = true; return array($state, 'FORCETREE',$match); } break; } return false; } //handle /** * Render xhtml output or metadata * * @param string $mode Renderer mode (supported modes: xhtml) * @param Doku_Renderer $renderer The renderer * @param array $data The data from the handler() function * * @return bool If rendering was successful. */ public function render($mode, Doku_Renderer $renderer, $data) { if ($mode == 'xhtml') { if( $data[1]=='TREE' || $data[1] == 'FORCETREE' ){ // if the tree is not build yet - do it if( $this->dlh_tree_html == ''){ $this->dlh_dokubook_tree( substr($_SERVER['PATH_INFO'],1) ); $this->dlh_tree_html .= ' ' .' '; }// build tree? //normal tree if( $data[1] == 'TREE' ){ if( $this->dlh_tree_no == false && $this->dlh_tree_force == false){ if( $this->dlh_tree_count == 0){ $renderer->doc .= $this->dlh_tree_html; $this->dlh_tree_count =1; return true; }else{ $renderer->doc .= '
! one tree only !
'; return true; }//count==0? }else{ //no tree to build... return true; }//notree & forcetree are false }//normal tree if( $data[1] == 'FORCETREE'){ if( $this->dlh_tree_count == 0){ $renderer->doc .= $this->dlh_tree_html; $this->dlh_tree_count =1; return true; }else{ $renderer->doc .= '
! one tree only !
'; return true; }//count==0? } }elseif($data[1]=='NOTREE'){ $renderer->doc .= ''; return true; } return false; } //mode xhtml return false; } //function render function dlh_dokubook_p_index_xhtml($ns) { require_once(DOKU_INC.'inc/search.php'); global $conf; global $ID; $dir = $conf['datadir']; $ns = cleanID($ns); #fixme use appropriate function if(empty($ns)){ $ns = dirname(str_replace(':','/',$ID)); if($ns == '.') $ns =''; } $ns = utf8_encodeFN(str_replace(':','/',$ns)); // only extract headline preg_match('/

.*?<\/h1>/', p_locale_xhtml('index'), $match); $this->dlh_tree_html .= $match[0]; $data = array(); search($data,$conf['datadir'],'search_index',array('ns' => $ns)); $this->dlh_tree_html .= '
' . DOKU_LF; $this->dlh_tree_html .= html_buildlist($data,'idx','html_list_index','html_li_index'); $this->dlh_tree_html .= '
' . DOKU_LF; } //dlh_dokubook_p_index_xhtml function dlh_dokubook_tree( $dlh_target=false ){ global $lang; global $ID; global $INFO; if( $dlh_target !== false){ $svID = cleanID($dlh_target); }else{ $svID = cleanID(':'); } $this->dlh_tree_html .= '' . $lang['navigation'] . '' . DOKU_LF; $this->dlh_tree_html .= '' . DOKU_LF; } //function dlh_dokubook_tree } //class