Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dev:grapher-php [2020/10/21 15:35] editor42dev:grapher-php [2020/11/01 15:59] (current) bab
Line 419: Line 419:
         $pages =& $data['pages'];         $pages =& $data['pages'];
         $media =& $data['media'];         $media =& $data['media'];
- $root_name = $data['namespaces'];       + $root_name = array_values($pages)[0]["ns"];   
         $output = '{         $output = '{
    "root": "'. $root_name .'",    "root": "'. $root_name .'",
Line 433: Line 434:
             $output .= '"name" : "'. $title .'",'."\n";             $output .= '"name" : "'. $title .'",'."\n";
             $output .= '"value" : "'. $item['size'] .'",'."\n";             $output .= '"value" : "'. $item['size'] .'",'."\n";
-            $output .= '"type" : "'. substr($item['ns'],4) .'",'."\n"; +            $output .= '"type" : "'. substr($item['ns'],4) .'"'."\n"; 
-            $output .= '"numcn" : "3"'."\n";+            if (!empty( $item['media'][0])) 
 +            { 
 + $path = explode (":", $item['media'][0]); 
 + $file = count($path ); 
 + $folder=""; 
 + for($n=0 ; $n < $file-1 ; $n++) 
 +
 + $folder = $folder . $path[$n] . "/"; 
 +
 + $output .= ',"img" : "'. DOKU_INC. "data/media/" . $folder . "300x300-" . $path[$file-1] .'"'."\n"; 
 + }
            // $output .= '"has_conflict" : "'.$id.'"'."\n";            // $output .= '"has_conflict" : "'.$id.'"'."\n";
            // $output .= '"description" : "'.$id.'"'."\n";            // $output .= '"description" : "'.$id.'"'."\n";
             $output .= "}\n";             $output .= "}\n";
-            if ($i < count($pages)) $output .= ',';+            if ($i <count($pages)-1) $output .= ',';
                  
         }         }
Line 453: Line 464:
  
  $output .= '{  $output .= '{
-   "from": "'. $id . '", +   "source": "'. $id . '", 
-   "to": "'. $link . '", +   "target": "'. $link . '", 
-   "value": 2+   "value": "'. $page["linklabel"][$cnt] .'"
  }';  }';
                 $cnt++;                 $cnt++;
Line 461: Line 472:
  
         }         }
 +       
                  
         $output .= " ] }";         $output .= " ] }";
Line 471: Line 483:
 $grapher = new Grapher(); $grapher = new Grapher();
 $grapher->run(); $grapher->run();
 +
 +
  
  
 </file> </file>
  • dev/grapher-php.1603294530.txt.gz
  • Last modified: 2020/10/21 15:35
  • by editor42