--- a/alaveteli/exportAgencies.csv.php +++ b/alaveteli/exportAgencies.csv.php @@ -1,20 +1,6 @@ <?php include_once("../include/common.inc.php"); - -function shortName($name) { - $name = trim($name); - if (strstr($name,"Minister ") || strstr($name,"Treasurer") || strstr($name,"Parliamentary Secretary")) { - $badWords = Array ("Assisting the Prime Minister on","Assisting on"," the "," of "," for "," on "," and "," to ",","," ","'","`"); - return str_replace($badWords,"",$name); - } - - else { - $out = Array(); - preg_match_all('/[A-Z]/', $name, $out); - return implode("", $out[0]); - } -} setlocale(LC_CTYPE, 'C'); @@ -63,38 +49,34 @@ $row = Array(); $row["#id"] = $agency->id; $row["name"] = trim($agency->value->name); - 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]; - } + $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->shortName)) { - $row["short_name"] = $agency->value->shortName; - } else { - $row["short_name"] = shortName($agency->value->name); + if (isset($agency->value->positions)) { + $otherBodies = array_merge($otherBodies, $agency->value->positions); } - $row["notes"] = ""; + if (count($otherBodies) > 0) { + $row["notes"] .= "<br/> 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") { - $row["tag_string"] = $tag[$agency->value->_id] . " " . $agency->value->orgType; + $row["tag_string"] = $tag[$agency->value->_id]; } else { - $row["tag_string"] = $tag[$agency->value->parentOrg] . " " . $agency->value->orgType; + $row["tag_string"] = $tag[$agency->value->parentOrg]; } - + $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)); - } - } + + } } } catch (SetteeRestClientException $e) {