beginnings rss scraper
[disclosr.git] / licensing.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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();
?>