Former-commit-id: 174e97ffdeaeded56d2cc86d961d05b6f1a0c427
--- a/admin/importGov2RegisterRSSFacebookTwitter.php
+++ b/admin/importGov2RegisterRSSFacebookTwitter.php
@@ -1,7 +1,7 @@
<?php
require_once '../include/common.inc.php';
-require($basePath.'lib/phpquery/phpQuery/phpQuery.php');
+require($basePath . 'lib/phpquery/phpQuery/phpQuery.php');
$db = $server->get_db('disclosr-agencies');
$rows = $db->get_view("app", "byName")->rows;
@@ -10,41 +10,40 @@
foreach ($rows as $row) {
$nametoid[trim($row->key)] = $row->value;
}
+
function extractHTMLAccounts($url, $accountType) {
global $accounts, $nametoid;
$request = Requests::get($url);
$doc = phpQuery::newDocumentHTML($request->body);
phpQuery::selectDocument($doc);
foreach (pq('tr')->elements as $tr) {
- //echo $tr->nodeValue.PHP_EOL;
- $agency = "";
- $url = "";
- foreach ($tr->childNodes as $td) {
- $class = $td->getAttribute("class");
- //echo "cccc $class ".$td->nodeValue.PHP_EOL;
- if ($class == "s11" || $class == "s10" || $class == "s7") {
- $agency = $td->nodeValue;
- } else if ($class == "s6" || $class == "s9"){
- $url = $td->nodeValue;
- foreach($td->childNodes as $a) {
- $href = $a->getAttribute("href");
- if ($href != "") {
- $url = $href;
- }
- }
- }
- }
- if ($agency != "" && $url != "") {
- if (!in_array(trim($agency), array_keys($nametoid))) {
- echo trim($agency)." missing" . PHP_EOL;
- } else {
- // echo $agency." = ".$url.PHP_EOL;
- $accounts[$nametoid[trim($agency)]][$accountType][] = $url;
+ //echo $tr->nodeValue.PHP_EOL;
+ $agency = "";
+ $url = "";
+ foreach ($tr->childNodes as $td) {
+ $class = $td->getAttribute("class");
+ //echo "cccc $class ".$td->nodeValue.PHP_EOL;
+ if ($class == "s11" || $class == "s10" || $class == "s7") {
+ $agency = $td->nodeValue;
+ } else if ($class == "s6" || $class == "s9") {
+ $url = $td->nodeValue;
+ foreach ($td->childNodes as $a) {
+ $href = $a->getAttribute("href");
+ if ($href != "") {
+ $url = $href;
}
-
- }
+ }
+ }
+ }
+ if ($agency != "" && $url != "") {
+ if (!in_array(trim($agency), array_keys($nametoid))) {
+ echo trim($agency) . " missing" . PHP_EOL;
+ } else {
+ // echo $agency." = ".$url.PHP_EOL;
+ $accounts[$nametoid[trim($agency)]][$accountType][] = $url;
+ }
+ }
}
-
}
function extractCSVAccounts($url, $accountType, $nameField, $accountField, $filter) {
@@ -53,7 +52,7 @@
$Data = str_getcsv($request->body, "\n"); //parse the rows
$headers = Array();
foreach ($Data as $num => $line) {
- $Row = str_getcsv($line, ",",'"');
+ $Row = str_getcsv($line, ",", '"');
if ($num == 0) {
} else if ($num == 1) {
@@ -64,7 +63,7 @@
$agencyName = $Row[array_search($nameField, $headers)];
if (!$filter || $Row[array_search("State", $headers)] == "NAT") {
if (!in_array(trim($agencyName), array_keys($nametoid))) {
- echo trim($agencyName)." missing" . PHP_EOL;
+ echo trim($agencyName) . " missing" . PHP_EOL;
} else {
// echo $Row[array_search($nameField, $headers)] . PHP_EOL;
$accounts[$nametoid[trim($agencyName)]][$accountType][] = $Row[array_search($accountField, $headers)];
@@ -84,6 +83,18 @@
extractHTMLAccounts("https://docs.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0Ah41IAK0HzSTdGJxandJREhLSGlWWUZfZ2xKOTNHZ0E&output=html", "RSS");
// facebook
extractHTMLAccounts("https://docs.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0Ah41IAK0HzSTdGtjcW9vOXdyZ3pOV21vQU51VmhzQnc&single=true&gid=0&output=html", "Facebook");
+foreach ($accounts as $id => $accountTypes) {
+ echo $id . "<br>" . PHP_EOL;
+ $doc = object_to_array($db->get($id));
+ // print_r($doc);
+ foreach ($accountTypes as $accountType => $accounts) {
+ if (!isset($doc["has" . $accountType]) || !is_array($doc["has" . $accountType])) {
+ $doc["has" . $accountType] = Array();
+ }
+ $doc["has" . $accountType] = array_unique(array_merge($doc["has" . $accountType], $accounts));
+ }
+ $db->save($doc);
+}
?>
--- /dev/null
+++ b/admin/naa-agift-tree.php
@@ -1,1 +1,2504 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <title>Demo of the tree layout in D3.js</title>
+<!-- source: http://blog.pixelingene.com/demos/d3_tree/
+http://javadude.wordpress.com/2012/06/20/d3-js-from-tree-to-cluster-and-radial-projection/
+http://bl.ocks.org/1249394-->
+ <style>
+ g.node {
+ font-family: Verdana, Helvetica;
+ font-size: 12px;
+ font-weight: bold;
+ }
+ circle.node-dot {
+ fill: lightsalmon;
+ stroke: red;
+ stroke-width: 1px;
+ }
+
+ path.link {
+ fill: none;
+ stroke: gray;
+ }
+
+ </style>
+</head>
+<body>
+
+<div id="tree-container"></div>
+ <div id="viz"></div>
+
+<script type="text/javascript" src="../javascripts/jquery-1.6.2.min.js"></script>
+<script type="text/javascript" src="../javascripts/d3.min.js"></script>
+<script type="text/javascript" src="../javascripts/d3.layout.min.js"></script>
+
+<script>
+ /**
+ * Created by JetBrains RubyMine.
+ * User: pavanpodila
+ * Date: 7/17/11
+ * Time: 4:30 PM
+ * To change this template use File | Settings | File Templates.
+ */
+
+var treeData =
+ <?php
+ // $json = file_get_children('naa-agift.json');
+ // $raw = json_decode($json);
+ // echo $json;
+ // print_r($raw);
+ $raw = json_decode('[
+ "Home",
+ "index.htm",
+ [
+ "BUSINESS SUPPORT AND REGULATION",
+ "000411.htm",
+ [
+ "Association registration",
+ "000396.htm"
+ ],
+ [
+ "Business process auditing",
+ "000413.htm"
+ ],
+ [
+ "Business registration and licensing",
+ "000414.htm"
+ ],
+ [
+ "Business sponsorship",
+ "001371.htm"
+ ],
+ [
+ "Consumer protection",
+ "000439.htm"
+ ],
+ [
+ "Fair trading compliance",
+ "000482.htm",
+ [
+ "Prices surveillance",
+ "000533.htm"
+ ],
+ [
+ "Product safety",
+ "000534.htm"
+ ],
+ [
+ "Trade practices compliance",
+ "000583.htm"
+ ]
+ ],
+ [
+ "Financial institutions regulation",
+ "000485.htm"
+ ],
+ [
+ "Government procurement regulation",
+ "000491.htm"
+ ],
+ [
+ "Industry assistance schemes",
+ "000499.htm"
+ ],
+ [
+ "Industry development",
+ "000500.htm"
+ ],
+ [
+ "Insurance regulation",
+ "000501.htm",
+ [
+ "General insurance",
+ "000489.htm"
+ ],
+ [
+ "Life insurance",
+ "000505.htm"
+ ]
+ ],
+ [
+ "Professional accreditation",
+ "000535.htm"
+ ],
+ [
+ "Small business services",
+ "000565.htm",
+ [
+ "Small business advocacy",
+ "000563.htm"
+ ],
+ [
+ "Small business development",
+ "000564.htm"
+ ]
+ ],
+ [
+ "Stock market regulation",
+ "000572.htm"
+ ]
+ ],
+ [
+ "CIVIC INFRASTRUCTURE",
+ "000424.htm",
+ [
+ "Civic management",
+ "000425.htm",
+ [
+ "Architectural services",
+ "000387.htm"
+ ],
+ [
+ "Building approval services",
+ "000406.htm"
+ ],
+ [
+ "Building regulations and standards",
+ "000408.htm"
+ ],
+ [
+ "Engineering services",
+ "000477.htm"
+ ],
+ [
+ "Town planning",
+ "000582.htm"
+ ]
+ ],
+ [
+ "Energy supply",
+ "000476.htm"
+ ],
+ [
+ "Integrated services planning",
+ "000503.htm"
+ ],
+ [
+ "Public housing",
+ "000536.htm",
+ [
+ "Public housing construction",
+ "000537.htm"
+ ],
+ [
+ "Public housing design",
+ "000538.htm"
+ ],
+ [
+ "Public housing maintenance",
+ "000540.htm"
+ ]
+ ],
+ [
+ "Public land management",
+ "000541.htm",
+ [
+ "Burial ground management",
+ "000410.htm"
+ ],
+ [
+ "Cultural centre management",
+ "000444.htm"
+ ],
+ [
+ "Garden management",
+ "000488.htm"
+ ],
+ [
+ "Memorial maintenance",
+ "000509.htm"
+ ],
+ [
+ "Recreational park management",
+ "000549.htm"
+ ],
+ [
+ "Sporting facilities management",
+ "000571.htm"
+ ]
+ ],
+ [
+ "Regional development",
+ "000552.htm"
+ ],
+ [
+ "Transport network maintenance",
+ "000586.htm"
+ ],
+ [
+ "Waste management",
+ "001349.htm"
+ ]
+ ],
+ [
+ "COMMUNICATIONS",
+ "000433.htm",
+ [
+ "Advertising standards",
+ "000381.htm"
+ ],
+ [
+ "Broadcasting",
+ "000403.htm",
+ [
+ "Broadcasting standards",
+ "000404.htm"
+ ],
+ [
+ "Radio broadcasting",
+ "000546.htm"
+ ],
+ [
+ "Television broadcasting",
+ "000580.htm"
+ ]
+ ],
+ [
+ "Call centre administration",
+ "000417.htm"
+ ],
+ [
+ "Electronic commerce",
+ "000468.htm",
+ [
+ "Authentication",
+ "000399.htm"
+ ],
+ [
+ "Online transaction standards",
+ "000526.htm"
+ ]
+ ],
+ [
+ "Government media",
+ "000490.htm"
+ ],
+ [
+ "Information management standards",
+ "000283.htm",
+ [
+ "Data management",
+ "000448.htm"
+ ],
+ [
+ "Information dissemination",
+ "000502.htm"
+ ],
+ [
+ "Information technology standards",
+ "000282.htm"
+ ]
+ ],
+ [
+ "Media ownership regulation",
+ "000508.htm"
+ ],
+ [
+ "Postal services",
+ "000530.htm",
+ [
+ "Courier services",
+ "000441.htm"
+ ],
+ [
+ "Electronic postal services",
+ "000469.htm"
+ ],
+ [
+ "Retail postal services",
+ "000554.htm"
+ ]
+ ],
+ [
+ "Publishing",
+ "000543.htm",
+ [
+ "Electronic publishing",
+ "000470.htm"
+ ],
+ [
+ "Publishing standards",
+ "000544.htm"
+ ],
+ [
+ "Website development",
+ "000591.htm"
+ ]
+ ],
+ [
+ "Radio communication",
+ "000547.htm",
+ [
+ "Apparatus licensing",
+ "000385.htm"
+ ],
+ [
+ "Spectrum management",
+ "000570.htm"
+ ]
+ ],
+ [
+ "Satellite communication",
+ "000560.htm"
+ ],
+ [
+ "Telecommunications",
+ "000578.htm",
+ [
+ "Carriage service providers",
+ "000420.htm"
+ ],
+ [
+ "Carrier licensing",
+ "000421.htm"
+ ],
+ [
+ "Equipment licensing",
+ "000480.htm"
+ ],
+ [
+ "Mobile telephone services",
+ "000516.htm"
+ ],
+ [
+ "Telephone services",
+ "000579.htm"
+ ]
+ ]
+ ],
+ [
+ "COMMUNITY SERVICES",
+ "000435.htm",
+ [
+ "Accommodation services",
+ "000377.htm",
+ [
+ "Defence housing",
+ "000458.htm"
+ ],
+ [
+ "Emergency accommodation",
+ "000471.htm"
+ ],
+ [
+ "Public housing entitlements",
+ "000539.htm"
+ ],
+ [
+ "Refuge support",
+ "000551.htm"
+ ]
+ ],
+ [
+ "Community support",
+ "000436.htm",
+ [
+ "Adoption services",
+ "000378.htm"
+ ],
+ [
+ "Aged care services",
+ "000382.htm"
+ ],
+ [
+ "Child and youth support",
+ "000422.htm"
+ ],
+ [
+ "Child-care services",
+ "000423.htm"
+ ],
+ [
+ "Defence community programs",
+ "000452.htm"
+ ],
+ [
+ "Family reunion programs",
+ "000483.htm"
+ ],
+ [
+ "Veterans\" entitlements",
+ "000587.htm"
+ ]
+ ],
+ [
+ "Counselling services",
+ "000440.htm"
+ ],
+ [
+ "Emergency services",
+ "000474.htm",
+ [
+ "Ambulance services",
+ "000384.htm"
+ ],
+ [
+ "Emergency funding",
+ "000472.htm"
+ ],
+ [
+ "Firefighting services",
+ "000487.htm"
+ ]
+ ],
+ [
+ "Financial assistance",
+ "000484.htm",
+ [
+ "Benefits",
+ "000402.htm"
+