[submodule "couchdb/couchdb-lucene"] | [submodule "couchdb/couchdb-lucene"] |
path = couchdb/couchdb-lucene | path = couchdb/couchdb-lucene |
url = https://github.com/rnewson/couchdb-lucene.git | url = https://github.com/rnewson/couchdb-lucene.git |
[submodule "couchdb/settee"] | [submodule "couchdb/settee"] |
path = couchdb/settee | path = couchdb/settee |
url = https://github.com/inadarei/settee.git | url = https://github.com/inadarei/settee.git |
[submodule "lib/springy"] | [submodule "lib/springy"] |
path = lib/springy | path = lib/springy |
url = https://github.com/dhotson/springy.git | url = https://github.com/dhotson/springy.git |
[submodule "lib/php-diff"] | |
path = lib/php-diff | |
url = https://github.com/chrisboulton/php-diff.git | |
<?php | <?php |
require_once 'include/common.inc.php'; | require_once '../include/common.inc.php'; |
try { | try { |
$server->create_db('disclosr-agencies'); | $server->create_db('disclosr-agencies'); |
} catch (SetteeRestClientException $e) { | } catch (SetteeRestClientException $e) { |
setteErrorHandler($e); | setteErrorHandler($e); |
} | } |
$db = $server->get_db('disclosr-agencies'); | $db = $server->get_db('disclosr-agencies'); |
createAgencyDesignDoc(); | createAgencyDesignDoc(); |
$conn = new PDO("pgsql:dbname=contractDashboard;user=postgres;password=snmc;host=localhost"); | $conn = new PDO("pgsql:dbname=contractDashboard;user=postgres;password=snmc;host=localhost"); |
$namesQ = 'select agency.abn, string_agg("agencyName",\'|\') as names from agency inner join agency_nametoabn on agency.abn::text = agency_nametoabn.abn group by agency.abn;'; | $namesQ = 'select agency.abn, string_agg("agencyName",\'|\') as names from agency inner join agency_nametoabn on agency.abn::text = agency_nametoabn.abn group by agency.abn;'; |
$abntonames = Array(); | $abntonames = Array(); |
foreach ($conn->query($namesQ) as $row) { | foreach ($conn->query($namesQ) as $row) { |
$abntonames[$row['abn']] = explode("|", $row['names']); | $abntonames[$row['abn']] = explode("|", $row['names']); |
} | } |
$result = $conn->query("select * from agency"); | $result = $conn->query("select * from agency"); |
while ($agency = $result->fetch(PDO::FETCH_ASSOC)) { | while ($agency = $result->fetch(PDO::FETCH_ASSOC)) { |
$agency['_id'] = md5($agency['abn']); | $agency['_id'] = md5($agency['abn']); |
$agency['otherNames'] = $abntonames[$agency['abn']]; | $agency['otherNames'] = $abntonames[$agency['abn']]; |
if (sizeof($abntonames[$agency['abn']]) == 1) | if (sizeof($abntonames[$agency['abn']]) == 1) |
$agency['name'] = $abntonames[$agency['abn']][0]; | $agency['name'] = $abntonames[$agency['abn']][0]; |
$agency["lastScraped"] = "1/1/1970"; | $agency["lastScraped"] = "1/1/1970"; |
$agency["scrapeDepth"] = 1; | $agency["scrapeDepth"] = 1; |
try { | try { |
$doc = $db->save($agency); | $doc = $db->save($agency); |
//print_r($doc); | //print_r($doc); |
echo $agency['abn'] . " imported \n<br>"; | echo $agency['abn'] . " imported \n<br>"; |
} catch (SetteeRestClientException $e) { | } catch (SetteeRestClientException $e) { |
setteErrorHandler($e); | setteErrorHandler($e); |
} | } |
} | } |
?> | ?> |
<?php | |
include_once('../include/common.inc.php'); | |
include_header(); | |
// Include the diff class | |
echo '<STYLE TYPE="text/css"> | |
<!-- | |
@import url(../lib/php-diff/example/styles.css); | |
--> | |
</STYLE> | |
'; | |
require_once dirname(__FILE__) . '/../lib/php-diff/lib/Diff.php'; | |
// Generate a side by side diff | |
require_once dirname(__FILE__) . '/../lib/php-diff/lib/Diff/Renderer/Html/SideBySide.php'; | |
$renderer = new Diff_Renderer_Html_SideBySide; | |
$db = $server->get_db('disclosr-agencies'); | |
$docs = Array(); | |
try { | |
$rows = $db->get_view("app", "getConflicts")->rows; | |
//print_r($rows); | |
foreach ($rows as $row) { | |
echo '<h2>' . $row->id . '</h2>'; | |
echo "Comparing " . $row->value[0] . " and " . $row->value[1]; | |
$docA = explode(",", json_encode($db->get($row->id . "?rev=" . $row->value[0]))); | |
$docB = explode(",", json_encode($db->get($row->id . "?rev=" . $row->value[1]))); | |
// Options for generating the diff | |
$options = array( | |
//'ignoreWhitespace' => true, | |
//'ignoreCase' => true, | |
); | |
// Initialize the diff class | |
$diff = new Diff($docA, $docB, $options); | |
echo $diff->Render($renderer); | |
} | |
} catch (SetteeRestClientException $e) { | |
setteErrorHandler($e); | |
} | |
include_footer(); | |
?> |
<?php | <?php |
include_once('include/common.inc.php'); | include_once('../include/common.inc.php'); |
include_header(); | include_header(); |
$db = $server->get_db('disclosr-agencies'); | $db = $server->get_db('disclosr-agencies'); |
$docs = Array(); | $docs = Array(); |
try { | try { |
$rows = $db->get_view("app", "byABN")->rows; | $rows = $db->get_view("app", "byABN")->rows; |
//print_r($rows); | //print_r($rows); |
foreach ($rows as $row) { | foreach ($rows as $row) { |
$docs["a" . $row->key] = $row->value; | $docs["a" . $row->key] = $row->value; |
} | } |
} catch (SetteeRestClientException $e) { | } catch (SetteeRestClientException $e) { |
setteErrorHandler($e); | setteErrorHandler($e); |
} | } |
//print_r($docs); | //print_r($docs); |
$row = 1; | $row = 1; |
if (($handle = fopen("cacfma.csv", "r")) !== FALSE) { | if (($handle = fopen("cacfma.csv", "r")) !== FALSE) { |
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { |
$row++; | $row++; |
echo $data[0] . " " . str_replace("?", "", $data[1]) . "<br />\n"; | echo $data[0] . " " . str_replace("?", "", $data[1]) . "<br />\n"; |
$name = $data[0]; | $name = $data[0]; |
$abn = trim(str_replace("?", "", $data[1])); | $abn = trim(str_replace("?", "", $data[1])); |
$aabn = "a".$abn; | $aabn = "a".$abn; |
if (isset($docs[$aabn])) { | if (isset($docs[$aabn])) { |
echo "Existing agency ABN detected<br>"; | echo "Existing agency ABN detected<br>"; |
if (!in_array($name, object_to_array($docs[$aabn]->otherNames)) && $name != $docs[$aabn]->name) { | if (!in_array($name, object_to_array($docs[$aabn]->otherNames)) && $name != $docs[$aabn]->name) { |
$docs[$aabn]->otherNames[] = $name; | $docs[$aabn]->otherNames[] = $name; |
try { | try { |
$docs[$aabn] = $db->save($docs[$aabn]); | $docs[$aabn] = $db->save($docs[$aabn]); |
//print_r($doc); | //print_r($doc); |
echo $abn . " additional names imported \n<br>"; | echo $abn . " additional names imported \n<br>"; |
} catch (SetteeRestClientException $e) { | } catch (SetteeRestClientException $e) { |
setteErrorHandler($e); | setteErrorHandler($e); |
} | } |
} | } |
} else { | } else { |
echo "New agency ABN detected<br>"; | echo "New agency ABN detected<br>"; |
$agency['_id'] = md5($aabn); | $agency['_id'] = md5($aabn); |
$agency['name'] = $name; | $agency['name'] = $name; |
$agency["abn"] = $abn; | $agency["abn"] = $abn; |
try { | try { |
$doc = $db->save($agency); | $doc = $db->save($agency); |
print_r($doc); | print_r($doc); |
echo $abn . " imported \n<br>"; | echo $abn . " imported \n<br>"; |
} catch (SetteeRestClientException $e) { | } catch (SetteeRestClientException $e) { |
setteErrorHandler($e); | setteErrorHandler($e); |
} | } |
} | } |
echo "<hr>"; | echo "<hr>"; |
} | } |
fclose($handle); | fclose($handle); |
} | } |
include_footer(); | include_footer(); |
?> | ?> |
<?php | |
include_once("../include/common.inc.php"); | |
setlocale(LC_CTYPE, 'C'); | |
$headers = Array("#id", "name", "request_email", "short_name", "notes", "publication_scheme", "home_page", "tag_string"); | |
$db = $server->get_db('disclosr-agencies'); | |
$tag = Array(); | |
try { | |
$rows = $db->get_view("app", "byDeptStateName", null, true)->rows; | |
//print_r($rows); | |
foreach ($rows as $row) { | |
$tag[$row->value] = phrase_to_tag(dept_to_portfolio($row->key)); | |
} | |
} catch (SetteeRestClientException $e) { | |
setteErrorHandler($e); | |
} | |
$fp = fopen('php://output', 'w'); | |
if ($fp && $db) { | |
header('Content-Type: text/csv'); | |
header('Content-Disposition: attachment; filename="export.' . date("c") . '.csv"'); | |
header('Pragma: no-cache'); | |
header('Expires: 0'); | |
fputcsv($fp, $headers); | |
try { | |
$agencies = $db->get_view("app", "byCanonicalName", null, true)->rows; | |
//print_r($rows); | |
foreach ($agencies as $agency) { | |
// print_r($agency); | |
$row = Array(); | |
$row["#id"] = $agency->value->_id; | |
$row["name"] = $agency->value->name; | |
if (isset($agency->value->foi_email)) { | |
$row["request_email"] = $agency->value->foi_email; | |
} else { | |
$row["request_email"] = "foi@".GetDomain($agency->value->website); | |
// | |
} | |
if (isset($agency->value->short_name)) { | |
$row["short_name"] = $agency->value->short_name; | |
} else { | |
$out = Array(); | |
preg_match_all('/[A-Z]/', $agency->value->name, $out); | |
$row["short_name"] = implode("",$out[0]); | |
} | |
$row["notes"] = ""; | |
$row["publication_scheme"] = $agency->value->infoPublicationSchemeURL; | |
$row["home_page"] = $agency->value->website; | |
if ($agency->value->orgType == "FMA-DepartmentOfState") { | |
$row["tag_string"] = $tag[$agency->value->_id]; | |
} else { | |
$row["tag_string"] = $tag[$agency->value->parentOrg];; | |
} | |
fputcsv($fp, array_values($row)); | |
if (isset($agency->value->foiBodies)) { | |
foreach ($agency->value->foiBodies as $foiBody) { | |
$row['name'] = $foiBody; | |
$row['short_name'] = ""; | |
fputcsv($fp, array_values($row)); | |
} | |
} | |
} | |
} catch (SetteeRestClientException $e) { | |
setteErrorHandler($e); | |
} | |
die; | |
} | |
?> | |
<?php | |
include_once("../include/common.inc.php"); | |
setlocale(LC_CTYPE, 'C'); | |
header('Content-Type: text/csv'); | |
header('Content-Disposition: attachment; filename="public_body_categories_en.rb"'); | |
header('Pragma: no-cache'); | |
header('Expires: 0'); | |
echo 'PublicBodyCategories.add(:en, ['.PHP_EOL; | |
echo ' "Portfolios",'.PHP_EOL; | |
$db = $server->get_db('disclosr-agencies'); | |
try { | |
$rows = $db->get_view("app", "byDeptStateName", null, true)->rows; | |
//print_r($rows); | |
foreach ($rows as $row) { | |
echo ' [ "'.phrase_to_tag(dept_to_portfolio($row->key)).'","'. dept_to_portfolio($row->key).'","'.dept_to_portfolio($row->key).'" ],'.PHP_EOL; | |
} | |
} catch (SetteeRestClientException $e) { | |
setteErrorHandler($e); | |
} | |
echo '])'; | |
?> | |
<?php | <?php |
include_once('include/common.inc.php'); | include_once('include/common.inc.php'); |
//include_header(); | //include_header(); |
?> | ?> |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> |
<script src="lib/springy/springy.js"></script> | <script src="lib/springy/springy.js"></script> |
<script src="lib/springy/springyui.js"></script> | <script src="lib/springy/springyui.js"></script> |
<script> | <script> |
var graph = new Graph(); | var graph = new Graph(); |
var nodes = []; | var nodes = []; |
<?php | <?php |
$db = $server->get_db('disclosr-agencies'); | $db = $server->get_db('disclosr-agencies'); |
echo "nodes[\"fedg\"] = graph.newNode({label: \"Federal Government - Commonwealth of Australia\"});" . PHP_EOL; | echo "nodes[\"fedg\"] = graph.newNode({label: \"Federal Government - Commonwealth of Australia\"});" . PHP_EOL; |
try { | try { |
$rows = $db->get_view("app", "byCanonicalName", null, true)->rows; | $rows = $db->get_view("app", "byCanonicalName", null, true)->rows; |
//print_r($rows); | //print_r($rows); |
foreach ($rows as $row) { | foreach ($rows as $row) { |
echo "nodes[\"{$row->value}\"] = graph.newNode({label: \"{$row->key}\"});" . PHP_EOL; | echo "nodes[\"{$row->value->_id}\"] = graph.newNode({label: \"{$row->key}\"});" . PHP_EOL; |
} | } |
} catch (SetteeRestClientException $e) { | } catch (SetteeRestClientException $e) { |
setteErrorHandler($e); | setteErrorHandler($e); |
} | } |
try { | try { |
$rows = $db->get_view("app", "byDeptStateName", null, true)->rows; | $rows = $db->get_view("app", "byDeptStateName", null, true)->rows; |
//print_r($rows); | //print_r($rows); |
foreach ($rows as $row) { | foreach ($rows as $row) { |
echo "graph.newEdge(nodes[\"fedg\"], nodes['{$row->value}'], {color: '#00A0B0'});" . PHP_EOL; | echo "graph.newEdge(nodes[\"fedg\"], nodes['{$row->value}'], {color: '#00A0B0'});" . PHP_EOL; |
} | } |
} catch (SetteeRestClientException $e) { | } catch (SetteeRestClientException $e) { |
setteErrorHandler($e); | setteErrorHandler($e); |
} | } |
try { | try { |
$rows = $db->get_view("app", "parentOrgs", null, true)->rows; | $rows = $db->get_view("app", "parentOrgs", null, true)->rows; |
// print_r($rows); | // print_r($rows); |
foreach ($rows as $row) { | foreach ($rows as $row) { |
echo "graph.newEdge(nodes[\"{$row->key}\"], nodes['{$row->value}'], {color: '#FFA0B0'});" . PHP_EOL; | echo "graph.newEdge(nodes[\"{$row->key}\"], nodes['{$row->value}'], {color: '#FFA0B0'});" . PHP_EOL; |
} | } |
} catch (SetteeRestClientException $e) { | } catch (SetteeRestClientException $e) { |
setteErrorHandler($e); | setteErrorHandler($e); |
} | } |
?> | ?> |
window.onload = function() { | window.onload = function() { |
$(document).ready(function() { | $(document).ready(function() { |
var springy = $('#springydemo').springy({ | var springy = $('#springydemo').springy({ |
graph: graph | graph: graph |
}); | }); |
}); | }); |
}; | }; |
</script> | </script> |
<canvas id="springydemo" width="1260" height="680" /> | <canvas id="springydemo" width="1260" height="680" /> |
<?php | <?php |
//include_footer(); | //include_footer(); |
?> | ?> |
<?php | <?php |
date_default_timezone_set("Australia/Sydney"); | |
$basePath = ""; | |
if (strstr($_SERVER['PHP_SELF'], "alaveteli/") | |
|| strstr($_SERVER['PHP_SELF'], "admin/") | |
|| strstr($_SERVER['PHP_SELF'], "lib/") | |
|| strstr($_SERVER['PHP_SELF'], "include/")) | |
$basePath = "../"; | |
include_once ('couchdb.inc.php'); | include_once ('couchdb.inc.php'); |
include_once ('template.inc.php'); | include_once ('template.inc.php'); |
# Convert a stdClass to an Array. http://www.php.net/manual/en/language.types.object.php#102735 | # Convert a stdClass to an Array. http://www.php.net/manual/en/language.types.object.php#102735 |
function object_to_array(stdClass $Class) { | function object_to_array(stdClass $Class) { |
# Typecast to (array) automatically converts stdClass -> array. | # Typecast to (array) automatically converts stdClass -> array. |
$Class = (array) $Class; | $Class = (array) $Class; |
# Iterate through the former properties looking for any stdClass properties. | # Iterate through the former properties looking for any stdClass properties. |
# Recursively apply (array). | # Recursively apply (array). |
foreach ($Class as $key => $value) { | foreach ($Class as $key => $value) { |
if (is_object($value) && get_class($value) === 'stdClass') { | if (is_object($value) && get_class($value) === 'stdClass') { |
$Class[$key] = object_to_array($value); | $Class[$key] = object_to_array($value); |
} | } |
} | } |
return $Class; | return $Class; |
} | } |
# Convert an Array to stdClass. http://www.php.net/manual/en/language.types.object.php#102735 | # Convert an Array to stdClass. http://www.php.net/manual/en/language.types.object.php#102735 |
function array_to_object(array $array) { | function array_to_object(array $array) { |
# Iterate through our array looking for array values. | # Iterate through our array looking for array values. |
# If found recurvisely call itself. |