apples.* fixes
[disclosr.git] / getAgency.php
blob:a/getAgency.php -> blob:b/getAgency.php
--- a/getAgency.php
+++ b/getAgency.php
@@ -1,23 +1,31 @@
 <?php
 
 include_once('include/common.inc.php');
-include_header();
+
 
 function displayValue($key, $value, $mode) {
     global $db, $schemas;
     if ($mode == "view") {
-
+if (strpos($key, "_") === 0 || $key== "metadata") return;
         echo "<tr>";
 
-        echo "<td>" . $schemas['agency']["properties"][$key]['x-title'] . "<br><small>" . $schemas['agency']["properties"][$key]['description'] . "</small></td><td>";
+        echo "<td>";
+        if (isset($schemas['agency']["properties"][$key])) {
+             echo $schemas['agency']["properties"][$key]['x-title'] . "<br><small>" . $schemas['agency']["properties"][$key]['description']."</small>";
+        }
+         echo                "</td><td>";
         if (is_array($value)) {
             echo "<ol>";
             foreach ($value as $subkey => $subvalue) {
-                if (isset($schemas['agency']["properties"][$key]['x-property'])) {
-                    echo '<li property="' . $schemas['agency']["properties"][$key]['x-property'] . '">';
-                } else {
-                    echo "<li>";
-                }
+                 
+                    echo "<li ";
+                    if (isset($schemas['agency']["properties"][$key]['x-property'])) {
+                    echo ' property="' . $schemas['agency']["properties"][$key]['x-property'] . '" ';
+                }    if (isset($schemas['agency']["properties"][$key]['x-itemprop'])) {
+                    echo ' itemprop="' . $schemas['agency']["properties"][$key]['x-itemprop'] . '" ';
+                }
+                echo " >";
+                
                 echo "$subvalue</li>";
             }
             echo "</ol></td></tr>";
@@ -28,8 +36,8 @@
                 echo "<span>";
             }
             if ((strpos($key, "URL") > 0 || $key == 'website') && $value != "") {
-                echo "<a href='$value'>view</a></span>";
-            } else {
+                echo "<a ".($key == 'website' ? 'itemprop="url"':'')." href='$value'>$value</a>";
+                          } else {
                 echo "$value</span>";
             }
         }
@@ -61,7 +69,8 @@
             } else {
                 echo "<label>$key</label><input  class='input-text' type='text' id='$key' name='$key' value='$value'/>";
                 if ((strpos($key, "URL") > 0 || $key == 'website') && $value != "") {
-                    echo "<a href='$value'>view</a>";
+                    echo "<a ".($key == 'website' ? 'itemprop="url"':'')." href='$value'>view</a>";
+                        
                 }
                 if ($key == 'abn') {
                     echo "<a href='http://www.abr.business.gov.au/SearchByAbn.aspx?SearchText=$value'>view abn</a>";
@@ -108,6 +117,7 @@
 // edit?
 
     $obj = $db->get($_REQUEST['id']);
+    include_header($obj->name);
 //print_r($row);
     if (sizeof($_POST) > 0) {
 //print_r($_POST);
@@ -147,8 +157,8 @@
     }
 
     if ($mode == "view") {
-        echo '<div typeof="schema:GovernmentOrganisation" about="#' . $row['_id'] . '"><table width="100%">';
-        echo '<tr> <td colspan="2"><h3>' . $row['name'] . "</h3></td></tr>";
+        echo '<div itemscope itemtype="http://schema.org/GovernmentOrganization" typeof="schema:GovernmentOrganization" about="#' . $row['_id'] . '"><table width="100%">';
+        echo '<tr> <td colspan="2"><h3 itemprop="name">' . $row['name'] . "</h3></td></tr>";
         echo "<tr><th>Field Name</th><th>Field Value</th></tr>";
     }
     if ($mode == "edit") {
@@ -185,7 +195,8 @@
             echo '<input id="submitbutton" type="submit"/></form>';
         }
     } else {
-
+// show all list
+        include_header('Agencies');
         try {
             /* $rows = $db->get_view("app", "showNamesABNs")->rows;
               //print_r($rows);
@@ -200,10 +211,10 @@
             echo '<ul>';
             foreach ($rows as $row) {
                 //   print_r($row);
-                echo '<li typeof="schema:GovernmentOrganisation foaf:Organization" about="getAgency.php?id=' . $row->value->_id . '">
-<a href="getAgency.php?id=' . $row->value->_id . '" rel="schema:url foaf:page" property="schema:name foaf:name">' .
+                echo '<li itemscope itemtype="http://schema.org/GovernmentOrganization" typeof="schema:GovernmentOrganization foaf:Organization" about="getAgency.php?id=' . $row->value->_id . '">
+<a href="getAgency.php?id=' . $row->value->_id . '" rel="schema:url foaf:page" property="schema:name foaf:name" itemprop="url"><span itemprop="name">' .
                 $row->value->name
-                . '</a></li>';
+                . '</span></a></li>';
             }
             echo "</ul>";
         } catch (SetteeRestClientException $e) {