--- a/ranking.php +++ b/ranking.php @@ -1,1 +1,213 @@ - +get_db('disclosr-agencies'); +?> +
+

Open Government Rankings

+

+
+ + get_db('disclosr-agencies'); + //$docsdb = $server->get_db('disclosr-documents'); + $scoredagencies = Array(); + $scores = Array(); + $columnKeys = Array(); + + try { + $rows = $agenciesdb->get_view("app", "all", null, true)->rows; + + + if ($rows) { + foreach ($rows as $row) { + $columns = Array(); + foreach ($row->value as $key => $value) { + if ((strstr($key, "has") || strstr($key, "URL")) && $key != "rtkURLs") { + //echo "$key
"; + $columns[$key] = $value; + } + } + //print_r(array_keys($columns)); + $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); + } + } + + } catch (SetteeRestClientException $e) { + setteErrorHandler($e); + } + function cmp($a, $b) + { + if ($a['score'] == $b['score']) { + return strcmp($a['name'], $b['name']); + } + return ($a['score'] > $b['score']) ? -1 : 1; + } + + usort($scoredagencies, "cmp"); + echo ""; + echo ""; + echo ""; + foreach ($columnKeys as $columnID) { + echo ""; + } + echo ""; + foreach ($scoredagencies as $scoredagency) { + echo ""; + echo ""; + echo ""; + foreach ($columnKeys as $key) { + echo ""; + } + echo "\n"; + } + ?> +
Agency NameScore" . (isset($schemas['agency']["properties"][$columnID]['x-title']) ? $schemas['agency']["properties"][$columnID]['x-title'] : "$columnID") . "
". $scoredagency['name'] . "" . $scoredagency['score'] . ""; + if (isset($scoredagency['columns'][$key])) { + $value = $scoredagency['columns'][$key]; + if (is_array($value)) { + if (count($value) == 1) { + $href = $value[0]; + } else { + $href = $value[0]; + } + + } else { + $href = $value; + } + if ($href[0] == "@") { + $href = str_replace("@","https://twitter.com/",$href); + } + //$href= urlencode($href); + + echo ""; + + if (strstr($href, "http")) { + echo ""; + } else { + echo "✓"; + } + + echo ""; + } else { + echo ""; + } + echo "

+
+
+ + +