graph/ranking fixes
graph/ranking fixes


Former-commit-id: c08fb5bb63762d6d850ae16d8fc7ad947b845078

file:a/graph.php -> file:b/graph.php
--- a/graph.php
+++ b/graph.php
@@ -9,13 +9,13 @@
 function add_node($id, $label, $parent="") {
     global $format;
     if ($format == "html") {
-       // echo "nodes[\"$id\"] = graph.newNode({label: \"$label\"});" . PHP_EOL;
+      //  echo "nodes[\"$id\"] = graph.newNode({label: \"$label\"});" . PHP_EOL;
     }
      if ($format == "dot" && $label != "") {
-         echo "$id [label=\"$label\"];". PHP_EOL;
+         echo "\"$id\" [label=\"$label\", shape=plaintext];". PHP_EOL;
      }
       if ($format == "gexf") {
-          echo "<node id='$id' label=\"".htmlentities($label,ENT_XML1)."\" ".($parent != ""? "pid='$parent'><viz:size value='1'/>":"><viz:size value='2'/>")
+          echo "<node id='$id' label=\"".htmlentities($label)."\" ".($parent != ""? "pid='$parent'><viz:size value='1'/>":"><viz:size value='2'/>")
               ."<viz:color b='".rand(0,255)."' g='".rand(0,255)."' r='".rand(0,255)."'/>"
                   ."</node>". PHP_EOL;
       }
@@ -27,7 +27,7 @@
      //   echo "graph.newEdge(nodes[\"$from\"], nodes['$to'], {color: '$color'});" . PHP_EOL;
     }
     if ($format == "dot") {
-        echo "$from -> $to ".($color != ""? "[color=$color]":"").";". PHP_EOL;
+        echo "\"$from\" -> \"$to\" ".($color != ""? "[color=$color]":"").";". PHP_EOL;
     }
      if ($format == "gexf") {
           echo "<edge id='$from$to' source='$from' target='$to' />". PHP_EOL;
@@ -55,7 +55,7 @@
     $rows = $db->get_view("app", "byCanonicalName", null, true)->rows;
 //print_r($rows);
     foreach ($rows as $row) {
-        add_node($row->id, $row->key);
+        add_node($row->id, $row->value->name);
     }
 } catch (SetteeRestClientException $e) {
     setteErrorHandler($e);

--- a/ranking.php
+++ b/ranking.php
@@ -32,8 +32,12 @@
                 $columnKeys = array_unique(array_merge($columnKeys, array_keys($columns)));
                 //print_r($columnKeys);
                 $score = count($columns);
-                $scores[$score]++;
-                $scoredagencies[] = Array("id"=> $row->key, "website"=> $row->value->website, "name" => $row->value->name, "columns" => $columns, "score" => $score);
+                if (isset($scores[$score])){
+$scores[$score]++;
+} else {
+$scores[$score] =1;
+}
+                $scoredagencies[] = Array("id"=> $row->key, "website"=> (isset($row->value->website)?$row->value->website:""), "name" => $row->value->name, "columns" => $columns, "score" => $score);
             }
         }
 
@@ -74,7 +78,7 @@
                 } else {
                     $href = $value;
                 }
-                if ($href[0] == "@") {
+                if (isset($href[0]) && $href[0] == "@") {
                     $href = str_replace("@","https://twitter.com/",$href);
                 }
                 //$href= urlencode($href);