diff --git a/classes/Utils.php~ b/classes/Utils.php~ deleted file mode 100644 index c36c8c270a6d30f3a4f52137cfa4af25edfd2f5b..0000000000000000000000000000000000000000 --- a/classes/Utils.php~ +++ /dev/null @@ -1,157 +0,0 @@ -<? - -class Utils{ - - public static function send303($uri, $ext){ - header("HTTP/1.0 303 See Other"); - header("Location: ".$uri); - header("Content-type: ".$ext); - echo $uri."\n\n"; - exit(0); - } - - public static function send404($uri){ - header("HTTP/1.0 404 Not Found"); - echo "I could not find ".$uri." or information about it.\n\n"; - exit(0); - } - - public static function send406($uri){ - header("HTTP/1.0 406 Not Acceptable"); - echo "I can't find a representation suitable for the content type you accept\n\n"; - exit(0); - } - - public static function send500($uri){ - header("HTTP/1.0 500 Internal Server Error"); - echo "An internal error ocurred. Please try later\n\n"; - exit(0); - } - - public static function uri2curie($uri){ - global $conf; - $ns = $conf['ns']; - $curie = $uri; - foreach($ns as $k => $v){ - $curie = preg_replace("|^$v|", "$k:", $uri); - if($curie != $uri){ - break; - } - } - return $curie; - } - - public static function getTemplate($uri){ - $filename = str_replace(":", "_", $uri); - if(file_exists ($filename)){ - include_once($filename); - } - } - - private static function sparqlResult2Obj($data){ - $aux = $data['results']['bindings']; - $obj = array(); - foreach($aux as $w){ - $row = array(); - foreach($w as $k => $v){ - $row[$k]['value'] = $v['value']; - if($v['type'] == 'uri'){ - $row[$k]['curie'] = Utils::uri2curie($v['value']); - $row[$k]['uri'] = 1; - } - } - array_push($obj, $row); - } - return $obj; - } - - public static function showView($uri, $data, $view){ - global $conf; - $base = $conf['view']['standard']; - $base['value']['this'] = $uri; - $base['curie']['this'] = Utils::uri2curie($uri); - $base['ns'] = $conf['ns']; - require('lib/Haanga/lib/Haanga.php'); - Haanga::configure(array( - 'template_dir' => './', - 'cache_dir' => 'compiled/', - )); - $r = Utils::sparqlResult2Obj($data); - $vars = compact('base', 'r'); - Haanga::Load($view, $vars); - - } - - public static function getExtension($accept_string){ - global $conf; - $extension = "html"; - foreach($conf['http_accept'] as $ext => $accept_arr){ - if(in_array($accept_string, $accept_arr)){ - $extension = $ext; - } - } - return $extension; - } - - public static function getBestContentType($accept_string){ - global $conf; - /* - * TODO: Choose best content type from - * things like - * "text/html;q=0.2,application/xml;q=0.1" - * and so on. In the meantime, - * assume there is only one CT - */ - $a = split(",", $accept_string); - $ct = 'text/html'; - if(strstr($a[0], ";")){ - $a = split(";", $a[0]); - } - foreach($conf['http_accept'] as $ext => $arr){ - if(in_array($a[0], $arr)){ - $ct = $a[0]; - } - } - - return $ct; - } - - public static function processQuery($modelFile, $uri, $endpoint){ - global $conf; - //Check if files for model and view exist - - $query = file_get_contents($modelFile); - $query = preg_replace("|".$conf['resource']['url_delimiter']."|", "<".$uri.">", $query); -echo $query; - header('Content-Type: '.$acceptContentType); - if(preg_match("/describe/i", $query)){ - $results = $endpoint->query($query, $conf['endpoint']['describe']['output']); - require('lib/arc2/ARC2.php'); - $parser = ARC2::getRDFParser(); - $parser->parse($conf['basedir'], $results); - $triples = $parser->getTriples(); - $ser; - switch ($extension){ - case 'ttl': - $ser = ARC2::getTurtleSerializer(); - break; - case 'nt': - $ser = ARC2::getNTriplesSerializer(); - break; - case 'rdf': - $ser = ARC2::getRDFXMLSerializer(); - break; - } - $doc = $ser->getSerializedTriples($triples); - echo $doc; - exit(0); - } - elseif(preg_match("/select/i", $query)){ - return $endpoint->query($query, $conf['endpoint']['select']['output']); - if(sizeof($results['results']['bindings']) == 0){ - Utils::send404($uri); - } - } - } -} -?> diff --git a/compiled/65a63e1d92b5e02960e7039e14a5754d707e4e60.php b/compiled/65a63e1d92b5e02960e7039e14a5754d707e4e60.php deleted file mode 100644 index b36aa0bdc8bbd55b44dbe4554f7f993c9fc789ef..0000000000000000000000000000000000000000 --- a/compiled/65a63e1d92b5e02960e7039e14a5754d707e4e60.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php -$HAANGA_VERSION = '1.0.4'; -/* Generated from /Users/alvarograves/github/lodspeakr/views/default.view.html */ -function haanga_65a63e1d92b5e02960e7039e14a5754d707e4e60($vars, $return=FALSE, $blocks=array()) -{ - extract($vars); - if ($return == TRUE) { - ob_start(); - } - echo '<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" - "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" '; - foreach ($base['ns'] as $i => $ns) { - echo 'xmlns:'.htmlspecialchars($i).'="'.htmlspecialchars($ns).'" - '; - } - echo 'version="XHTML+RDFa 1.0" xml:lang="en"> - <head> - <title>Page about '.htmlspecialchars($base['this']['value']).'</title> - <link href="'.htmlspecialchars($base['baseUrl']).'/lodspeakr/css/basic.css" rel="stylesheet" type="text/css" media="screen" /> - </head> - <body> - <h1>Page about <a href=\''.htmlspecialchars($base['this']['value']).'\'>'.htmlspecialchars($base['this']['curie']).'</a></h1> - <div> - <h2>Information from '.htmlspecialchars($base['this']['curie']).'</h2> - <table about="'.htmlspecialchars($base['this']['value']).'"> - '; - foreach ($r as $row) { - echo ' - '; - if ($row['s1'] != $null) { - echo ' - <tr> - <td><a href=\''.htmlspecialchars($row['s1']->value).'\'>'.htmlspecialchars($row['s1']->value).'</a></td> - '; - if ($row['p1']->uri == 1) { - echo ' - <td><a rel=\''.htmlspecialchars($row['s1']->curie).'\' href=\''.htmlspecialchars($row['p1']->value).'\'>'.htmlspecialchars($row['p1']->curie).'</a></td> - '; - } else { - echo ' - <td><span property=\''.htmlspecialchars($row['s1']->curie).'\'>'.htmlspecialchars($row['p1']->value).'</span></td> - '; - } - echo ' - </tr> - '; - } - echo ' - '; - } - echo ' - </table> - <br/><br/> - <h2>Information pointing to '.htmlspecialchars($base['this']['curie']).'</h2> - - <table about="'.htmlspecialchars($base['this']['value']).'"> - '; - foreach ($r as $row) { - echo ' - - '; - if ($row['s2'] != $null) { - echo ' - <tr> - <td><a rev=\''.htmlspecialchars($row['p2']['curie']).'\' href=\''.htmlspecialchars($row['s2']['value']).'\'>'.htmlspecialchars($row['s2']['curie']).'</a></td> - <td><a href=\''.htmlspecialchars($row['p2']['value']).'\'>'.htmlspecialchars($row['p2']['curie']).'</a></td> - </tr> - '; - } - echo ' - '; - } - echo ' - </table> - </div> - </body> -</html> - -'; - if ($return == TRUE) { - return ob_get_clean(); - } -} \ No newline at end of file diff --git a/meta/db.sqlite b/meta/db.sqlite index 970b8ef3b9954dbdbab4b05733913451d04f4704..b8671961c6dd59aef4cb2d4b0d59d5a041a184ec 100644 Binary files a/meta/db.sqlite and b/meta/db.sqlite differ diff --git a/views/default.view.html~ b/views/default.view.html~ index 69724883824c944dfe39d85adac54da39d4ebffa..83bede9156337b31bbe8cbcdfee24526539c0c22 100644 --- a/views/default.view.html~ +++ b/views/default.view.html~ @@ -1,38 +1,40 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" + <html {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> <head> <title>Page about {{base.value.this}}</title> - <link href="{{base.baseUrl}}/lodspeakr/css/basic.css" rel="stylesheet" type="text/css" media="screen" /> + <link href="{{base.baseUrl}}css/basic.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> - <h1>Page about <a href='{{base.this.value}}'>{{base.curie.this}}</a></h1> + <h1>Page about <a href='{{base.value.this}}'>{{base.curie.this}}</a></h1> + <br/> + <br/> <div> - <h2>Information from {{base.this.curie}}</h2> + <h2>Information from {{base.curie.this}}</h2> <table about="{{base.value.this}}"> {% for row in r %} - {% if row.s1.value != null %} + {% if row.value.s1 != null %} <tr> - <td><a href='{{row.s1.value}}'>{{row.s1.curie}}</a></td> + <td><a href='{{row.value.s1}}'>{{row.curie.s1}}</a></td> {% if row.uri.p1 == 1 %} - <td><a rel='{{row.s1.curie}}' href='{{row.p1.value}}'>{{row.p1.curie}}</a></td> + <td><a rel='{{row.curie.s1}}' href='{{row.value.p1}}'>{{row.curie.p1}}</a></td> {% else %} - <td><span property='{{row.s1.curie}}'>{{row.p1.value}}</span></td> + <td><span property='{{row.curie.s1}}'>{{row.value.p1}}</span></td> {% endif %} </tr> {% endif %} {% endfor %} </table> <br/><br/> - <h2>Information pointing to {{base.this.curie}}</h2> + <h2>Information pointing to {{base.curie.this}}</h2> <table about="{{base.value.this}}"> {% for row in r %} {% if row.value.s2 != null %} <tr> - <td><a rev='{{row.p2.curie}}' href='{{row.value.s2}}'>{{row.s2.curie}}</a></td> - <td><a href='{{row.value.p2}}'>{{row.p2.curie}}</a></td> + <td><a rev='{{row.curie.p2}}' href='{{row.value.s2}}'>{{row.curie.s2}}</a></td> + <td><a href='{{row.value.p2}}'>{{row.curie.p2}}</a></td> </tr> {%endif %} {% endfor %}