From: Maxious Date: Fri, 19 Oct 2012 04:28:52 +0000 Subject: Merge branch 'master' of ssh://maxious.lambdacomplex.org/git/disclosr X-Git-Url: https://maxious.lambdacomplex.org/git/?p=disclosr.git&a=commitdiff&h=fbd515fec0f4a50212c05695b6a40d23f2f58544 --- Merge branch 'master' of ssh://maxious.lambdacomplex.org/git/disclosr Former-commit-id: fc4448d27e936bc92eabb21c8f2897cdd184b544 --- --- /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 @@ -52,18 +52,23 @@ $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->positions)) { - $otherBodies = array_merge($otherBodies, $agency->value->positions); + $positions = Array(); + foreach ($agency->value->positions as $position) { + $positions[] = "Office of the ".$position; + } + $otherBodies = array_merge($otherBodies, $positions); } + sort($otherBodies); if (count($otherBodies) > 0) { - $row["notes"] .= "
This department also responds to requests for information held by ".implode(",",$otherBodies); + $row["notes"] .= "
This department also responds to requests for information held by " . implode(", ", $otherBodies); } - + $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") { @@ -74,9 +79,6 @@ $row["tag_string"] .= " " . $agency->value->orgType; $row["tag_string"] .= " federal"; fputcsv($fp, array_values($row)); - - - } } } catch (SetteeRestClientException $e) { --- a/getAgency.php +++ b/getAgency.php @@ -9,7 +9,11 @@ if (strpos($key, "_") === 0 || $key== "metadata") return; echo ""; - echo "" . $schemas['agency']["properties"][$key]['x-title'] . "
" . $schemas['agency']["properties"][$key]['description'] . ""; + echo ""; + if (isset($schemas['agency']["properties"][$key])) { + echo $schemas['agency']["properties"][$key]['x-title'] . "
" . $schemas['agency']["properties"][$key]['description'].""; + } + echo ""; if (is_array($value)) { echo "
    "; foreach ($value as $subkey => $subvalue) { --- a/include/common.inc.php +++ b/include/common.inc.php @@ -14,10 +14,10 @@ require_once $basePath.'lib/Requests/library/Requests.php'; Requests::register_autoloader(); -require $basePath."/lib/amon-php/amon.php"; -Amon::config(array('address'=> 'http://127.0.0.1:2465', +require $basePath."lib/amon-php/amon.php"; +Amon::config(array('address'=> 'http://127.0.0.1:2464', 'protocol' => 'http', - 'secret_key' => "g99127n3lkzigg8ob2rllth97d1pb4sj")); + 'secret_key' => "I2LJ6dOMmlnXgVAkTPFXd5M3ejkga8Gd2FbBt6iqZdw")); Amon::setup_exception_handler(); # Convert a stdClass to an Array. http://www.php.net/manual/en/language.types.object.php#102735