add prefix for positions
add prefix for positions


Former-commit-id: 2eb28a3a36f76484db67773b1c6df6f238257aad

--- a/.gitmodules
+++ b/.gitmodules
@@ -25,4 +25,7 @@
 [submodule "lib/querypath"]
 	path = lib/querypath
 	url = https://github.com/technosophos/querypath.git
+[submodule "lib/amon-php"]
+	path = lib/amon-php
+	url = https://github.com/martinrusev/amon-php.git
 

file:a/about.php -> file:b/about.php
--- a/about.php
+++ b/about.php
@@ -10,8 +10,10 @@
 Disclo.gs is a project to monitor Australian Federal Government agencies 
 compliance with their <a href="http://www.oaic.gov.au/publications/other_operational/foi_policy_frequently_asked_questions.html#_Toc291837571">"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/</a>.
 <h2> Attributions </h2>
-National Archives of Australia, Australian Governments’ Interactive Functions Thesaurus, 2nd edition, September 2005, published at http://www.naa.gov.au/recordkeeping/thesaurus/index.htm.
-
+National Archives of Australia, Australian Governments’ Interactive Functions Thesaurus, 2nd edition, September 2005, published at http://www.naa.gov.au/recordkeeping/thesaurus/index.htm <br/>
+data.gov.au http://data.gov.au/dataset/directory-gov-au-full-data-export/ <br/>
+directory.gov.au <br/>
+australia.gov.au http://australia.gov.au/about/copyright <br/>
 <h2> Open everything </h2>
 All documents released CC-BY 3 AU
 Open source git @

--- a/admin/naa-agift-tree.php
+++ b/admin/naa-agift-tree.php
@@ -31,9 +31,9 @@
 <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 type="text/javascript" src="../js/jquery-1.6.2.min.js"></script>
+<script type="text/javascript" src="../js/d3.min.js"></script>
+<script type="text/javascript" src="../js/d3.layout.min.js"></script>
 
 <script>
     /**

--- 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,36 @@
                 $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->positions)) {
+                    $positions = Array();
+                    foreach ($agency->value->positions as $position) {
+                        $positions[] = "Office of the ".$position;
                     }
+                    $otherBodies = array_merge($otherBodies, $positions);
                 }
-                if (isset($agency->value->shortName)) {
-                    $row["short_name"] = $agency->value->shortName;
-                } else {
-                    $row["short_name"] = shortName($agency->value->name);
+                sort($otherBodies);
+                if (count($otherBodies) > 0) {
+                    $row["notes"] .= "<br/> 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] . " " . $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) {

--- a/bubbletree.php
+++ b/bubbletree.php
@@ -5,13 +5,13 @@
         <meta charset="UTF-8"/> 
         <title>Minimal BubbleTree Demo</title> 
         <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script> 
-        <script type="text/javascript" src="javascripts/bubbletree/lib/jquery.history.js"></script> 
-        <script type="text/javascript" src="javascripts/bubbletree/lib/raphael.js"></script> 
-        <script type="text/javascript" src="javascripts/bubbletree/lib/vis4.js"></script> 
-        <script type="text/javascript" src="javascripts/bubbletree/lib/Tween.js"></script> 
-        <script type="text/javascript" src="javascripts/bubbletree/build/bubbletree.js"></script> 
-        <link rel="stylesheet" type="text/css" href="javascripts/bubbletree/build/bubbletree.css" /> 
-        <script type="text/javascript" src="javascripts/bubbletree/styles/cofog.js"></script> 
+        <script type="text/javascript" src="js/bubbletree/lib/jquery.history.js"></script> 
+        <script type="text/javascript" src="js/bubbletree/lib/raphael.js"></script> 
+        <script type="text/javascript" src="js/bubbletree/lib/vis4.js"></script> 
+        <script type="text/javascript" src="js/bubbletree/lib/Tween.js"></script> 
+        <script type="text/javascript" src="js/bubbletree/build/bubbletree.js"></script> 
+        <link rel="stylesheet" type="text/css" href="js/bubbletree/build/bubbletree.css" /> 
+        <script type="text/javascript" src="js/bubbletree/styles/cofog.js"></script> 
 
 
         <script type="text/javascript"> 

file:a/graph.php -> file:b/graph.php
--- a/graph.php
+++ b/graph.php
@@ -86,9 +86,9 @@
 if ($format == "html") {
     ?>
  <div id="sigma-example" width="960" style="min-height:800px;background-color: #333;"></div>
-  <script src="javascripts/sigma.min.js"></script>
-  <script src="javascripts/sigma/plugins/sigma.parseGexf.js"></script>
-  <script src="javascripts/sigma/plugins/sigma.forceatlas2.js"></script>
+  <script src="js/sigma.min.js"></script>
+  <script src="js/sigma/plugins/sigma.parseGexf.js"></script>
+  <script src="js/sigma/plugins/sigma.forceatlas2.js"></script>
   <script type="text/javascript">function init() {
   // Instanciate sigma.js and customize rendering :
   var sigInst = sigma.init(document.getElementById('sigma-example')).drawingProperties({

--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -14,6 +14,11 @@
 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:2464', 
+		'protocol' => 'http', 
+		'secret_key' => "I2LJ6dOMmlnXgVAkTPFXd5M3ejkga8Gd2FbBt6iqZdw"));
+Amon::setup_exception_handler();
 # Convert a stdClass to an Array. http://www.php.net/manual/en/language.types.object.php#102735
 
 function object_to_array(stdClass $Class) {

--- a/include/couchdb.inc.php
+++ b/include/couchdb.inc.php
@@ -168,6 +168,7 @@
 $server = new SetteeServer($serverAddr);
 
 function setteErrorHandler($e) {
+    Amon::log($e->getMessage() . " " . print_r($_SERVER,true), array('error'));
     echo $e->getMessage() . "<br>" . PHP_EOL;
 }
 

--- a/include/template.inc.php
+++ b/include/template.inc.php
@@ -66,11 +66,11 @@
 
 
             <!-- Included JS Files -->
-            <script src="<?php echo $basePath; ?>javascripts/foundation.js"></script>
-            <script src="<?php echo $basePath; ?>javascripts/app.js"></script>
+            <script src="<?php echo $basePath; ?>js/foundation.js"></script>
+            <script src="<?php echo $basePath; ?>js/app.js"></script>
            <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
             
-    <script type="text/javascript" src="javascripts/flotr2/flotr2.js"></script>
+    <script type="text/javascript" src="<?php echo $basePath ?>js/flotr2/flotr2.js"></script>
         <?php
         if (strpos($_SERVER['SERVER_NAME'], ".gs")) {
             ?>

directory:b/js/bubbletree (new)
--- /dev/null
+++ b/js/bubbletree

directory:b/js/flotr2 (new)
--- /dev/null
+++ b/js/flotr2

directory:b/js/sigma (new)
--- /dev/null
+++ b/js/sigma

directory:b/lib/amon-php (new)
--- /dev/null
+++ b/lib/amon-php