add licencing page
add licencing page

Former-commit-id: 1bc00d6d903c08480371ee3e94feffae455d3520

--- a/.gitmodules
+++ b/.gitmodules
@@ -22,4 +22,7 @@
 [submodule "javascripts/bubbletree"]
 	path = javascripts/bubbletree
 	url = https://github.com/okfn/bubbletree.git
+[submodule "lib/querypath"]
+	path = lib/querypath
+	url = https://github.com/technosophos/querypath.git
 

file:b/admin/agls.php (new)
--- /dev/null
+++ b/admin/agls.php
@@ -1,1 +1,35 @@
+<?php
 
+include_once('include/common.inc.php');
+include_header('Webserver and Accessiblity');
+
+echo "<table>
+    <tr><th>name</th><th>function</th></tr>";
+$db = $server->get_db('disclosr-agencies');
+try {
+     $agencies = $db->get_view("app", "byCanonicalName", null, true)->rows;
+
+
+    if ($agencies) {
+        foreach ($agencies as $row) {
+
+            echo "<tr><td>" . $row->value->name . "</td>";
+            if (isset($row->value->metaTags)) {
+                if (is_array($row->value->metaTags)) {
+                        $tags =$row->value->metaTags;
+                } else {
+			$tags = object_to_array($row->value->metaTags);
+                }
+                if (isset($tags['AGLS.Function'])) {
+                    echo "<td>" . $tags['AGLS.Function'] . "</td>";
+                }
+            }
+            echo "</tr>";
+        }
+    }
+} catch (SetteeRestClientException $e) {
+    setteErrorHandler($e);
+}
+include_footer();
+?>
+

--- a/admin/conflicts.php
+++ b/admin/conflicts.php
@@ -1,7 +1,7 @@
 <?php
 
 include_once('../include/common.inc.php');
-include_header();
+include_header('Fix Conflicts');
                 require_once '../lib/php-diff/lib/Diff.php';
                 require_once '../lib/php-diff/lib/Diff/Renderer/Html/SideBySide.php';
 

--- /dev/null
+++ b/admin/genericAgencyFixer.php
@@ -1,1 +1,44 @@
+<?php
 
+include_once("../include/common.inc.php");
+require($basePath . 'lib/phpquery/phpQuery/phpQuery.php');
+
+setlocale(LC_CTYPE, 'C');
+
+
+$db = $server->get_db('disclosr-agencies');
+
+try {
+    $agencies = $db->get_view("app", "byCanonicalName", null, true)->rows;
+    //print_r($rows);
+    foreach ($agencies as $agency) {
+        //echo $agency->value->name . " ".$agency->value->website."<br />\n";
+         // print_r($agency);
+        //hasRestricitiveLicence"	hasRestrictiveLicense -> has Restrictive Licence
+        // "hasYoutube" -> Tube
+        // "comment" -> "comments"
+        if (!isset($agency->value->metaTags) && isset($agency->value->website)) {
+                echo $agency->value->name . " ".$agency->value->website."<br />\n";
+            $agency->value->metaTags = Array();
+            $request = Requests::get($agency->value->website);
+            $html = phpQuery::newDocumentHTML($request->body);
+            phpQuery::selectDocument($html);
+            foreach (pq('meta')->elements as $meta) {
+                $tagName = $meta->getAttribute('name');;
+                $content = $meta->getAttribute('content');
+                if ($tagName != "") {
+echo "$tagName == $content <br>\n";
+                 $agency->value->metaTags[$tagName] = $content;
+                }
+            }
+            //print_r($agency->value->metaTags);
+            $db->save($agency->value);
+            echo "<hr>";
+            flush();
+        }
+    }
+} catch (SetteeRestClientException $e) {
+    setteErrorHandler($e);
+}
+?>
+

file:b/licensing.php (new)
--- /dev/null
+++ b/licensing.php
@@ -1,1 +1,54 @@
+<?php
 
+include_once('include/common.inc.php');
+include_header('Website Licensing');
+
+echo "<table>
+    <tr><th>name</th><th>licencing terms</th></tr>";
+$agenciesdb = $server->get_db('disclosr-agencies');
+try {
+    $rows = $agenciesdb->get_view("app", "all", null, true)->rows;
+
+
+    if ($rows) {
+        
+        foreach ($rows as $row) {
+             $rowArray = object_to_array($row->value);
+             if (isset($rowArray['name'])&& isset($rowArray['website']) && !isset($rowArray['status'])) {
+ echo "<tr><td><a href='" . $rowArray['website'] ."'>". $rowArray['name'] . "</a></td>";
+           
+           
+            
+            $licences = Array(
+                "hasCrownCopyright"=>"Crown Copyright",
+                "hasCCBY"=>"Creative Commons Attribution",
+                "hasCCBYND" =>"Creative Commons No Derivatives",	
+"hasCCBYNCND" =>"Creative Commons No Derivatives Non-Commercial",	
+                "hasRestrictiveLicense"	=> "ERRRRRRRRRRRRRRRRRRR",
+"hasRestrictiveLicence"	=> "Bespoke restrictive (permission for reuse) licences",
+"hasRestricitiveLicence"=>"ERRRRRRRRRRRR");
+            $websiteLicences = Array();
+            foreach ($rowArray as $fieldName => $rowField) {
+                foreach($licences as $licenceID => $licenceName) {
+                if (strstr($fieldName,$licenceID)) {
+                    $websiteLicences[$licenceName] = $rowField[0];
+                }
+                }
+            }
+            echo "<td>";
+            foreach ($websiteLicences as $name => $url) {
+                echo '<A href="' .$url.'">'.$name.'</a><br>';
+            }
+        
+        echo "</td></tr>";
+             }
+        }
+    }
+ 
+} catch (SetteeRestClientException $e) {
+    setteErrorHandler($e);
+}
+include_footer();
+?>
+
+