From: Maxious Date: Fri, 19 Oct 2012 04:28:26 +0000 Subject: add RTK import X-Git-Url: https://maxious.lambdacomplex.org/git/?p=disclosr.git&a=commitdiff&h=ea98ff7e7ea32119120d7998429482e488bb5ec9 --- add RTK import Former-commit-id: a6b6a0a350cf467915ec023c9e41421df3fcb83d --- --- a/about.php +++ b/about.php @@ -10,10 +10,8 @@ Disclo.gs is a project to monitor Australian Federal Government agencies compliance with their "proactive disclosure requirements" to make a transparency league table as suggested by gov2 taskforce http://gov2.net.au/blog/2009/09/19/a-league-ladder-of-psi-openness/.

Attributions

-National Archives of Australia, Australian Governments’ Interactive Functions Thesaurus, 2nd edition, September 2005, published at http://www.naa.gov.au/recordkeeping/thesaurus/index.htm
-data.gov.au http://data.gov.au/dataset/directory-gov-au-full-data-export/
-directory.gov.au
-australia.gov.au http://australia.gov.au/about/copyright
+National Archives of Australia, Australian Governments’ Interactive Functions Thesaurus, 2nd edition, September 2005, published at http://www.naa.gov.au/recordkeeping/thesaurus/index.htm. +

Open everything

All documents released CC-BY 3 AU Open source git @ --- /dev/null +++ b/admin/importRTKbodies.php @@ -1,1 +1,56 @@ +get_db('disclosr-agencies'); +$rows = $db->get_view("app", "byName")->rows; +$nametoid = Array(); +$accounts = Array(); +foreach ($rows as $row) { + $nametoid[trim($row->key)] = $row->value; +} + +function extractCSVAccounts($url, $nameField, $accountField, $filter) { + global $accounts, $nametoid; + $request = Requests::get($url); + echo $url; + $Data = str_getcsv($request->body, "\n"); //parse the rows + $headers = Array(); + foreach ($Data as $num => $line) { + $Row = str_getcsv($line, ","); + if ($num == 0) { + $headers = $Row; + print_r($headers); + } else { + if (isset($Row[array_search($nameField, $headers)])) { + $agencyName = $Row[array_search($nameField, $headers)]; + if (!in_array(trim($agencyName), array_keys($nametoid))) { + echo "$agencyName missing" . PHP_EOL; + } else { + echo $Row[array_search($nameField, $headers)] . PHP_EOL; + $accounts[$nametoid[trim($agencyName)]]["rtkURLs"][$agencyName] = 'http://www.righttoknow.org.au/body/'.$Row[array_search($accountField, $headers)]; + } + } else { + echo "error finding any agency" . $line . PHP_EOL; + } + } + } +} + +extractCSVAccounts("http://www.righttoknow.org.au/body/all-authorities.csv","Agency","URL name"); +print_r($accounts); +/* foreach ($accounts as $id => $accountTypes) { + echo $id . "
" . 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); +}*/ +?> + --- a/alaveteli/exportAgencies.csv.php +++ b/alaveteli/exportAgencies.csv.php @@ -1,6 +1,20 @@ id; $row["name"] = trim($agency->value->name); - $row["request_email"] = (isset($agency->value->foiEmail) ? $agency->value->foiEmail : ""); - $row["short_name"] = (isset($agency->value->shortName) ? $agency->value->shortName : ""); - $row["notes"] = (isset($agency->value->description) ? $agency->value->description : ""); - - $otherBodies = Array(); - if (isset($agency->value->foiBodies)) { - $otherBodies = array_merge($otherBodies, $agency->value->foiBodies); + if (isset($agency->value->foiEmail)) { + $row["request_email"] = $agency->value->foiEmail; + } else { + if ($agency->value->orgType == "FMA-DepartmentOfState") { + $row["request_email"] = "foi@" . GetDomain($agency->value->website); + } else { + $row["request_email"] = $foiEmail[$agency->value->parentOrg]; + } } - if (isset($agency->value->positions)) { - $otherBodies = array_merge($otherBodies, $agency->value->positions); + if (isset($agency->value->shortName)) { + $row["short_name"] = $agency->value->shortName; + } else { + $row["short_name"] = shortName($agency->value->name); } - if (count($otherBodies) > 0) { - $row["notes"] .= "
This department also responds to requests for information held by ".implode(",",$otherBodies); - } - + $row["notes"] = ""; $row["publication_scheme"] = (isset($agency->value->infoPublicationSchemeURL) ? $agency->value->infoPublicationSchemeURL : ""); $row["home_page"] = (isset($agency->value->website) ? $agency->value->website : ""); if ($agency->value->orgType == "FMA-DepartmentOfState") { - $row["tag_string"] = $tag[$agency->value->_id]; + $row["tag_string"] = $tag[$agency->value->_id] . " " . $agency->value->orgType; } else { - $row["tag_string"] = $tag[$agency->value->parentOrg]; + $row["tag_string"] = $tag[$agency->value->parentOrg] . " " . $agency->value->orgType; } - $row["tag_string"] .= " " . $agency->value->orgType; - $row["tag_string"] .= " federal"; + fputcsv($fp, array_values($row)); - - + if (isset($agency->value->foiBodies)) { + foreach ($agency->value->foiBodies as $foiBody) { + $row['name'] = iconv("UTF-8", "ASCII//TRANSLIT",$foiBody); + $row["short_name"] = shortName($foiBody); + fputcsv($fp, array_values($row)); + } + } + if (isset($agency->value->positions)) { + foreach ($agency->value->positions as $position) { + $row['name'] = iconv("UTF-8", "ASCII//TRANSLIT",$position); + $row["short_name"] = shortName($position); + fputcsv($fp, array_values($row)); + } + } } } } catch (SetteeRestClientException $e) {