Skip to content
Snippets Groups Projects
Commit 6d6788d1 authored by alvaro's avatar alvaro
Browse files

Merge branch 'development' into hotfixes

parents 28f2bda5 859dccb5
No related branches found
No related tags found
No related merge requests found
...@@ -61,7 +61,7 @@ class Endpoint{ ...@@ -61,7 +61,7 @@ class Endpoint{
$r = json_decode($aux, true); $r = json_decode($aux, true);
return $r; return $r;
} }
} }
public function queryPost($q){ public function queryPost($q){
$params = $this->params; $params = $this->params;
......
...@@ -174,7 +174,7 @@ class Utils{ ...@@ -174,7 +174,7 @@ class Utils{
} }
private static function serializeRdf($data, $extension){ public static function serializeRdf($data, $extension='rdf'){
global $conf; global $conf;
global $lodspk; global $lodspk;
$ser; $ser;
...@@ -427,6 +427,7 @@ class Utils{ ...@@ -427,6 +427,7 @@ class Utils{
$rPointer[$modelFile]['first'] = $rPointer[$modelFile][0]; $rPointer[$modelFile]['first'] = $rPointer[$modelFile][0];
}*/ }*/
}else{ }else{
$lodspk['resultRdf'] = true;
$rPointer[$strippedModelFile] = $aux; $rPointer[$strippedModelFile] = $aux;
} }
}else{ }else{
...@@ -437,6 +438,7 @@ class Utils{ ...@@ -437,6 +438,7 @@ class Utils{
$rPointer['first'] = $rPointer[0]; $rPointer['first'] = $rPointer[0];
}*/ }*/
}else{ }else{
$lodspk['resultRdf'] = true;
$rPointer = $aux; $rPointer = $aux;
} }
} }
...@@ -521,9 +523,12 @@ class Utils{ ...@@ -521,9 +523,12 @@ class Utils{
echo($data); echo($data);
}elseif(is_file($lodspk['view'].$view)){ }elseif(is_file($lodspk['view'].$view)){
Haanga::Load($view, $vars); Haanga::Load($view, $vars);
}elseif($view == null){
$fnc = Haanga::compile('{{models|safe}}');
$fnc($vars, TRUE);
}else{ }else{
$fnc = Haanga::compile($view); $fnc = Haanga::compile($view);
$fnc($vars, FALSE); $fnc($vars, TRUE);
} }
} }
......
...@@ -35,10 +35,16 @@ class UriModule extends abstractModule{ ...@@ -35,10 +35,16 @@ class UriModule extends abstractModule{
if($modelFile == NULL){ if($modelFile == NULL){
return FALSE; return FALSE;
} }
return $pair; $result = array( 'res' => $pair[0],
'page' => $pair[1],
'format' => $pair[2],
'modelFile' => $modelFile,
'viewFile' => $viewFile);
return $result;
} }
public function execute($pair){ public function execute($p){
global $conf; global $conf;
global $localUri; global $localUri;
global $uri; global $uri;
...@@ -47,10 +53,14 @@ class UriModule extends abstractModule{ ...@@ -47,10 +53,14 @@ class UriModule extends abstractModule{
global $lodspk; global $lodspk;
global $results; global $results;
global $first; global $first;
list($res, $page, $format) = $pair; $res = $p['res'];
$page = $p['page'];
$format = $p['format'];
$modelFile = $p['modelFile'];
$viewFile = $p['viewFile'];
$uri = $res; $uri = $res;
$curie = Utils::uri2curie($res); $curie = Utils::uri2curie($res);
//If resource is not the page, send a 303 to the document //If resource is not the page, send a 303 to the document
if($res == $localUri){ if($res == $localUri){
Utils::send303($page, $acceptContentType); Utils::send303($page, $acceptContentType);
...@@ -67,14 +77,14 @@ class UriModule extends abstractModule{ ...@@ -67,14 +77,14 @@ class UriModule extends abstractModule{
* dcterms:format for this page * dcterms:format for this page
*/ */
$acceptContentType = $format; $acceptContentType = $format;
$curie = Utils::uri2curie($uri); $curie = Utils::uri2curie($uri);
list($modelFile, $viewFile) = $this->getModelandView($curie, $extension);
if($modelFile == NULL){ if($modelFile == NULL){
return; return;
} }
$lodspk = $conf['view']['standard']; //$lodspk = $conf['view']['standard'];
$lodspk['type'] = $modelFile; $lodspk['type'] = $modelFile;
$lodspk['module'] = 'uri'; $lodspk['module'] = 'uri';
$lodspk['add_mirrored_uris'] = true; $lodspk['add_mirrored_uris'] = true;
...@@ -92,8 +102,12 @@ class UriModule extends abstractModule{ ...@@ -92,8 +102,12 @@ class UriModule extends abstractModule{
chdir($conf['home'].$conf['model']['directory']); chdir($conf['home'].$conf['model']['directory']);
Utils::queryFile($modelFile, $endpoints['local'], $results, $first); Utils::queryFile($modelFile, $endpoints['local'], $results, $first);
$results = Utils::internalize($results); if($lodspk['resultRdf']){
echo Utils::serializeRdf($results, $extension);
exit(0);
}else{
$results = Utils::internalize($results);
}
$lodspk['first'] = Utils::getFirsts($results); $lodspk['first'] = Utils::getFirsts($results);
chdir($conf['home']); chdir($conf['home']);
if(is_array($results)){ if(is_array($results)){
...@@ -101,17 +115,40 @@ class UriModule extends abstractModule{ ...@@ -101,17 +115,40 @@ class UriModule extends abstractModule{
}else{ }else{
$resultsObj = $results; $resultsObj = $results;
} }
if($conf['debug']){
trigger_error("Using template ".$viewFile, E_USER_NOTICE);
echo("TEMPLATE: ".$viewFile."\n\n");
}
Utils::processDocument($viewFile, $lodspk, $resultsObj); Utils::processDocument($viewFile, $lodspk, $resultsObj);
} }
private static function getModelandView($uri, $extension){ private static function getModelandView($uri, $extension){
global $conf; global $conf;
global $lodspk;
$auxViewFile = $conf['view']['directory'].$conf['uri']['prefix'].$uri.'/'.$extension.'.template'; $auxViewFile = $conf['view']['directory'].$conf['uri']['prefix'].$uri.'/'.$extension.'.template';
$auxModelFile = $conf['model']['directory'].$conf['uri']['prefix'].$uri.'/'.$extension.'.queries'; $auxModelFile = $conf['model']['directory'].$conf['uri']['prefix'].$uri.'/'.$extension.'.queries';
if(file_exists($auxModelFile) && file_exists($auxViewFile) ){ if(file_exists($auxModelFile)){
$viewFile = $conf['uri']['prefix'].$uri.'/'.$extension.'.template'; //Model exists
$modelFile = $conf['uri']['prefix'].$uri.'/'.$extension.'.queries'; $modelFile = $conf['uri']['prefix'].$uri.'/'.$extension.'.queries';
if(file_exists($auxViewFile) ){
//View exists, everything is fine
$viewFile = $conf['uri']['prefix'].$uri.'/'.$extension.'.template';
}elseif($extension != 'html'){
//View doesn't exists (and is not HTML)
$viewFile = null;
}
return array($modelFile, $viewFile);
}elseif($extension != 'html' && file_exists($conf['model']['directory'].$conf['uri']['prefix'].$uri.'/html.queries')){
$modelFile = $conf['uri']['prefix'].$uri.'/html.queries';
if(file_exists($auxViewFile) ){
//View exists, everything is fine
$viewFile = $conf['uri']['prefix'].$uri.'/'.$extension.'.template';
}elseif($extension != 'html'){
//View doesn't exists (and is not HTML)
$lodspk['transform_select_query'] = true;
$viewFile = null;
}
return array($modelFile, $viewFile); return array($modelFile, $viewFile);
} }
return array(NULL, NULL); return array(NULL, NULL);
......
<? <?
error_reporting(E_ERROR);
$s = 'settings.inc.php'; $s = 'settings.inc.php';
$c = file_get_contents($s); $c = file_get_contents($s);
$optionarray = Array('on' => 'true', '1' => 'true', 'off' => 'false', '0' =>'false'); $optionarray = Array('on' => 'true', '1' => 'true', 'off' => 'false', '0' =>'false');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment