#!/usr/bin/php parser = &new parser_XML(); $this->parser->data = implode("",file($this->file)); $this->parser->skip_empty =1; $this->parser->expat_parse(); //$this->add_to_books(); $this->build_tree(); } function build_tree() { $tree_filename = "{$this->basedir}/{$this->book}_tree.dbm"; $pages_filename = "{$this->basedir}/{$this->book}_pages.dbm"; $funcs_filename = "{$this->basedir}/{$this->book}_funcs.dbm"; @unlink($tree_filename); @unlink($pages_filename); @unlink($funcs_filename); echo "SAVING TO $tree_filename\n$pages_filename\n$funcs_filename\n"; $this->dbtree = dba_open($tree_filename ,"c",$this->dbm_handler); $this->dbpages = dba_open($pages_filename ,"c",$this->dbm_handler); $this->dbfuncs = dba_open($funcs_filename ,"c",$this->dbm_handler); $i = 0; $this->parent=0; $this->add_to_tree($i); dba_close($this->dbtree); dba_close($this->dbpages); } function add_to_tree($i) { $item = &$this->parser->htmltree[$i]; switch ($item->title) { case "SUB": if ($item->children) dba_replace($i, implode(",",$item->children),$this->dbtree); dba_replace($i, $item->attributes["NAME"] . "\t" . $item->attributes["LINK"] , $this->dbpages ); break; case "BOOK": dba_replace($i, implode(",",$item->children),$this->dbtree); if (!$item->attributes["DEFAULT_URL"]) $item->attributes["DEFAULT_URL"] = $item->attributes["BASE"]; dba_replace($i, $item->attributes["TITLE"] . "\t" . $item->attributes["DEFAULT_URL"] , $this->dbpages ); $this->book_id = $i; break; case "FUNCTION": dba_replace($item->attributes["NAME"] , $item->attributes["LINK"] , $this->dbfuncs ); break; case "CHAPTERS": dba_replace($this->book_id, implode(",",$item->children),$this->dbtree); break; } foreach($this->parser->htmltree[$i]->children as $k) $this->add_to_tree($k); } function read_books() { $this->basedir = dirname(__FILE__)."/../help"; $dir = "{$this->basedir}/specs"; $dh = opendir($dir); while (($this->book = readdir($dh)) !== FALSE) { if ($this->book{0} == ".") continue; $this->file = $dir . "/". $this->book; $this->parse_file(); } } } $t = &new devhelp_to_dbm(); $t->read_books(); ?>