([^<\n\r]*)/", $line, $matches)){ if(strpos($matches[2], 'Corporate Timeline')===false){ //exclude corparate timelines new_node($matches[2], 'corp', 'MC'); //p_id is its name get_code_page($matches[1], $matches[2]); $p_id++; // string_to_file($try_catch . $node_declaration . // $add_to_panel . $edges . $try2_catch, $out_file); } } } string_to_file($node_declaration . $add_to_panel . $edges . '//done', $out_file); // $node_declaration=''; // $add_to_panel=''; // $edges=''; } function get_code_page($path, $name){ global $p_id, $n_id; print "$name
"; $stack = array(); array_push($stack, $p_id); //push the corp id on bottom $lines= file('whoowns/' . substr($path, 1)); foreach($lines as $line){ $stack = build_tree($line, $stack); } array_pop($stack); } function build_tree($line, $stack){ global $n_id; if( (preg_match("/

([^<\n\r]*)<\/h3>/", $line, $matches)) || (preg_match("/
  • ([^<\r\n]*)/", $line, $matches)) ){ //make the current node a parrent //and the last elemnt in the stack its parrent if($matches[1]!=' '){ $n_id++; array_push($stack, new_node(trim($matches[1]), 'normal', end($stack))); } }else if(preg_match("/
  • ([^<\r\n]*)/", $line, $matches)){ $n_id++; // new_node(trim($matches[1]), 'normal', end($stack)); }else if(!strpos($line, '')===false){ array_pop($stack); } return $stack; } function icon_lookup($node_name){ $num=0; switch ($node_name){ case 'Other': $num=0; break; case 'Television': $num=4; break; case 'Daily Newspapers': $num=1; break; case 'Weekly Newspapers': $num=1; break; case 'Business Journals and Perodicals': $num=2; break; case 'Multimedia': $num=6; break; default: $num=0; break; } return $num; } function new_node($node_name, $type, $parent){ //print "adding $node_name
    "; global $node_declaration, $add_to_panel, $edges, $p_id, $n_id; // Node mainNode = new Node("sc",Node.TYPE_ELLIPSE,new Color(255, 32, 20),"1Santa Cruz",imgList[0]); // tgPanel.addNode(child1); // tgPanel.addEdge(tgPanel.findNode("1"),tgPanel.findNode("2"),1); switch($type){ case 'normal': $node_declaration .= node_declaration($p_id . '_' . $n_id, $node_name, icon_lookup($node_name)); $add_to_panel.= add_to_panel($p_id . '_' . $n_id); $edges.= make_edges($p_id . '_' . $n_id, $parent); break; case 'corp': $node_declaration .= node_declaration($p_id, $node_name, 0); $add_to_panel.= add_to_panel($p_id); $edges.=make_edges($p_id, $parent); break; } return $p_id . '_' . $n_id; } function node_declaration($id, $node, $img_num){ $val = "\n"; $val .= 'Node child' . $id; $val .= ' = new Node("'. $id . '",Node.TYPE_ROUNDRECT,'; $val .= 'new Color(255, 32, 20), "'. $node . '",imgList['. $img_num .']);'; return $val; } function add_to_panel($id){ $val = "\n"; $val.= 'tgPanel.addNode(child' . $id . ');'; return $val; } function make_edges($n1, $n2){ global $ed_distance; $val = "\n"; $val .='tgPanel.addEdge(tgPanel.findNode("' . $n1 . '"),tgPanel.findNode("'. $n2 . '"),' . $ed_distance . ');'; $ed_distance=$ed_distance+10; if($ed_distance>150)$ed_distance=10; return $val; } function write_to_file($path){ global $url; //temporarly function to write all of the pages localy. $somecontent=''; $path = substr($path, 1); $filename="whoowns/$path"; $page = $url . $path; $lines= file($page); foreach($lines as $line){ $somecontent.= $line; } string_to_file($somecontent, $filename); } function string_to_file($string, $file){ $fp=fopen($file, 'a'); fwrite($fp,$string); fclose($fp); } ?>