Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| dev:grapher-php [2020/10/06 12:55] – commented all output options bab | dev:grapher-php [2020/11/01 15:59] (current) – bab | ||
|---|---|---|---|
| Line 30: | Line 30: | ||
| "graph with graphviz. The ' | "graph with graphviz. The ' | ||
| "about the found nodes and can be loaded in Gephi. Default: dot", | "about the found nodes and can be loaded in Gephi. Default: dot", | ||
| - | ' | + | ' |
| $options-> | $options-> | ||
| ' | ' | ||
| Line 58: | Line 58: | ||
| } | } | ||
| $format = $options-> | $format = $options-> | ||
| - | if(!in_array($format, | + | if(!in_array($format, |
| $this-> | $this-> | ||
| } | } | ||
| Line 75: | Line 75: | ||
| } elseif($format == ' | } elseif($format == ' | ||
| $this-> | $this-> | ||
| - | } | + | } elseif($format == ' |
| + | | ||
| + | } | ||
| fclose($fh); | fclose($fh); | ||
| } | } | ||
| Line 238: | Line 239: | ||
| $pages[$pid][' | $pages[$pid][' | ||
| } | } | ||
| - | // | ||
| return array(' | return array(' | ||
| Line 256: | Line 256: | ||
| fwrite($fh, " | fwrite($fh, " | ||
| - | fwrite($fh, "// | + | fwrite($fh, "labelloc=\" |
| - | // | + | |
| - | // | + | |
| - | // | + | |
| - | // | + | |
| - | labelURL=\" | + | |
| - | // | + | |
| - | // | + | |
| - | // | + | |
| - | // | + | |
| - | // | + | |
| - | // | + | |
| - | rankdir=TB; | + | |
| - | // | + | |
| - | dpi=100; | + | |
| - | bgcolor=\" | + | |
| node [shape = \" | node [shape = \" | ||
| edge [arrowsize=2, | edge [arrowsize=2, | ||
| + | root=\" | ||
| + | |||
| + | subgraph corporations { | ||
| + | \" | ||
| + | \" | ||
| + | \" | ||
| + | \" | ||
| + | \" | ||
| + | } | ||
| + | |||
| + | subgraph leaks { | ||
| + | \" | ||
| + | \" | ||
| + | \" | ||
| + | } | ||
| + | |||
| + | subgraph countries { | ||
| + | \" | ||
| + | \" | ||
| + | \" | ||
| + | \" | ||
| + | |||
| + | } | ||
| \n"); | \n"); | ||
| Line 308: | Line 317: | ||
| // now create all the links | // now create all the links | ||
| foreach($pages as $id => $page) { | foreach($pages as $id => $page) { | ||
| - | foreach($page[' | + | for($n=0;$n<count($page[' |
| - | foreach($page[' | + | { |
| - | fwrite($fh, " | + | fwrite($fh, " |
| - | } | + | |
| } | } | ||
| - | /* | ||
| - | foreach($page[' | ||
| - | fwrite($fh, " | ||
| - | } | ||
| - | */ | ||
| } | } | ||
| fwrite($fh, " | fwrite($fh, " | ||
| Line 407: | Line 410: | ||
| fwrite($fh, " | fwrite($fh, " | ||
| fwrite($fh, "</ | fwrite($fh, "</ | ||
| + | | ||
| + | } | ||
| + | |||
| + | /* Create a JSON representation | ||
| + | */ | ||
| + | protected function create_json(& | ||
| + | | ||
| + | $pages =& $data[' | ||
| + | $media =& $data[' | ||
| + | $root_name = array_values($pages)[0][" | ||
| + | |||
| + | $output = '{ | ||
| + | " | ||
| + | " | ||
| + | $i=0; | ||
| + | // create all nodes first | ||
| + | foreach($pages as $id => $item){ | ||
| + | $i++; | ||
| + | $title = htmlspecialchars($item[' | ||
| + | $lang = htmlspecialchars($item[' | ||
| + | $output .= " | ||
| + | $output .= '" | ||
| + | $output .= '" | ||
| + | $output .= '" | ||
| + | $output .= '" | ||
| + | if (!empty( $item[' | ||
| + | { | ||
| + | $path = explode (":", | ||
| + | $file = count($path ); | ||
| + | $folder=""; | ||
| + | for($n=0 ; $n < $file-1 ; $n++) | ||
| + | { | ||
| + | $folder = $folder . $path[$n] . "/"; | ||
| + | } | ||
| + | $output .= '," | ||
| + | } | ||
| + | // $output .= '" | ||
| + | // $output .= '" | ||
| + | $output .= " | ||
| + | if ($i <= count($pages)-1) $output .= ','; | ||
| + | | ||
| + | } | ||
| + | |||
| + | // now create all the edges | ||
| + | | ||
| + | " | ||
| + | |||
| + | $cnt = 0; | ||
| + | foreach($pages as $id => $page){ | ||
| + | |||
| + | foreach($page[' | ||
| + | if ($cnt > 0) $output .= ','; | ||
| + | |||
| + | $output .= '{ | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }'; | ||
| + | $cnt++; | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | | ||
| + | $output .= " ] }"; | ||
| + | | ||
| + | fwrite($fh, | ||
| } | } | ||
| Line 413: | Line 483: | ||
| $grapher = new Grapher(); | $grapher = new Grapher(); | ||
| $grapher-> | $grapher-> | ||
| + | |||
| </ | </ | ||