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

Fixed error whiel reusing {{first}} values

parent 0ed19ddb
No related branches found
No related tags found
No related merge requests found
......@@ -302,7 +302,7 @@ class Utils{
$r[$modelDir] = array();
$f[$modelDir] = array();
}
Utils::queryFile($modelFile, $e, $r[$modelDir], $f[$modelDir]);
Utils::queryFile($modelFile, $e, $r[$modelDir], $f);
}else{
Utils::queryFile($modelFile, $e, $r, $f);
}
......@@ -317,9 +317,9 @@ class Utils{
$r[$modelDir] = array();
}
if($modelDir != $lodspk['type']){
Utils::queryDir($v, $r[$modelDir]);
Utils::queryDir($v, $r[$modelDir], $f[$modelDir]);
}else{
Utils::queryDir($v, $r);
Utils::queryDir($v, $r, $f);
}
}
}
......@@ -332,8 +332,8 @@ class Utils{
global $conf;
global $lodspk;
global $results;
global $first;
$uri = $lodspk['this']['value'];
global $firstResults;
$uri = $lodspk['this']['value'];
$data = array();
$strippedModelFile = str_replace('.query', '',$modelFile);
if(!is_dir($modelFile)){
......@@ -350,8 +350,9 @@ class Utils{
}
$r2 = Convert::array_copy($results);
$models = Convert::array_to_object($r2);
$f = Convert::array_to_object($first);
$vars = compact('uri', 'lodspk', 'models', 'f');
$f2 = Convert::array_copy($firstResults);
$first = Convert::array_to_object($f2);
$vars = compact('uri', 'lodspk', 'models', 'first');
$q = file_get_contents($modelFile);
if($q == false){
Utils::send500("I can't load ".$modelFile." in ".getcwd());
......@@ -438,13 +439,13 @@ class Utils{
if($modelFile != $lodspk['type']){
if(!isset($rPointer[$strippedModelFile])){
$rPointer[$strippedModelFile] = array();
$first[$strippedModelFile] = array();
$firstResults[$strippedModelFile] = array();
}
if(Utils::getResultsType($query) == $conf['output']['select']){
$rPointer[$strippedModelFile] = Utils::sparqlResult2Obj($aux);
$fPointer[$strippedModelFile] = $rPointer[$strippedModelFile][0];
/*if(sizeof($rPointer)>0){
$rPointer[$modelFile]['first'] = $rPointer[$modelFile][0];
$rPointer[$modelFile]['firstResults'] = $rPointer[$modelFile][0];
}*/
}else{
$lodspk['resultRdf'] = true;
......@@ -455,7 +456,7 @@ class Utils{
$rPointer = Utils::sparqlResult2Obj($aux);
$fPointer[$strippedModelFile] = $rPointer[0];
/*if(sizeof($rPointer)>0){
$rPointer['first'] = $rPointer[0];
$rPointer['firstResults'] = $rPointer[0];
}*/
}else{
$lodspk['resultRdf'] = true;
......@@ -477,13 +478,13 @@ class Utils{
public static function internalize($array){
global $conf;
$firstKeyAppearance = true;
$firstResultsKeyAppearance = true;
foreach($array as $key => $value){
if(!isset($value['value'])){
$array[$key] = Utils::internalize($value);
/*if($firstKeyAppearance){
$firstKeyAppearance = false;
$array['_first']=$array[$key];
/*if($firstResultsKeyAppearance){
$firstResultsKeyAppearance = false;
$array['_firstResults']=$array[$key];
}*/
}else{
if(isset($value['uri']) && $value['uri'] == 1){
......@@ -507,12 +508,12 @@ class Utils{
return $array;
}
public static function getFirsts($array){
public static function getfirstResultss($array){
global $conf;
$firstKeyAppearance = true;
$firstResultsKeyAppearance = true;
foreach($array as $key => $value){
if(!isset($value['value'])){
$aux = Utils::getFirsts($value);
$aux = Utils::getfirstResultss($value);
if(isset($aux['0'])){
$array[$key] = $aux['0'];
}else{
......@@ -539,8 +540,8 @@ class Utils{
'cache_dir' => $conf['home'].'cache/',
));
$models = $data;
$first = $lodspk['first'];
unset($lodspk['first']);
$first = $lodspk['firstResults'];
unset($lodspk['firstResults']);
$lodspk = $lodspk;
//unset($lodspk);
$vars = compact('uri','lodspk', 'models', 'first');
......
......@@ -45,7 +45,7 @@ class ServiceModule extends abstractModule{
global $acceptContentType;
global $endpoints;
global $lodspk;
global $first;
global $firstResults;
$context = array();
$context['contentType'] = $acceptContentType;
$context['endpoints'] = $endpoints;
......@@ -111,10 +111,10 @@ class ServiceModule extends abstractModule{
}
chdir($lodspk['model']);
Utils::queryFile($modelFile, $endpoints['local'], $results, $first);
Utils::queryFile($modelFile, $endpoints['local'], $results, $firstResults);
if(!$lodspk['resultRdf']){
$results = Utils::internalize($results);
$lodspk['first'] = Utils::getFirsts($results);
$lodspk['firstResults'] = Utils::getfirstResultss($results);
chdir($conf['home']);
if(is_array($results)){
......
......@@ -39,7 +39,7 @@ class TypeModule extends abstractModule{
global $endpoints;
global $lodspk;
global $results;
global $first;
global $firstResults;
list($res, $page, $format) = $pair;
//If resource is not the page, send a 303 to the document
if($res == $localUri){
......@@ -85,10 +85,10 @@ class TypeModule extends abstractModule{
$lodspk['this']['local'] = $localUri;
$lodspk['this']['extension'] = $extension;
chdir($conf['home'].$conf['model']['directory']);
Utils::queryFile($modelFile, $endpoints['local'], $results, $first);
Utils::queryFile($modelFile, $endpoints['local'], $results, $firstResults);
if(!$lodspk['resultRdf']){
$results = Utils::internalize($results);
$lodspk['first'] = Utils::getFirsts($results);
$lodspk['firstResults'] = Utils::getfirstResultss($results);
chdir($conf['home']);
if(is_array($results)){
......@@ -117,7 +117,7 @@ class TypeModule extends abstractModule{
$objResult['modelDir'] = $conf['model']['directory'].'type.rdfs:Resource/html.queries/';
$objResult['viewDir'] = $conf['view']['directory'].'type.rdfs:Resource/';
*/
//Get the first type available
//Get the firstResults type available
$typesAndValues = array('rdfs:Resource' => -1);
foreach($t as $v){
$curie = Utils::uri2curie($v);
......
......@@ -52,7 +52,7 @@ class UriModule extends abstractModule{
global $endpoints;
global $lodspk;
global $results;
global $first;
global $firstResults;
$res = $p['res'];
$page = $p['page'];
$format = $p['format'];
......@@ -100,10 +100,10 @@ class UriModule extends abstractModule{
chdir($conf['home'].$conf['model']['directory']);
Utils::queryFile($modelFile, $endpoints['local'], $results, $first);
Utils::queryFile($modelFile, $endpoints['local'], $results, $firstResults);
if(!$lodspk['resultRdf']){
$results = Utils::internalize($results);
$lodspk['first'] = Utils::getFirsts($results);
$lodspk['firstResults'] = Utils::getfirstResultss($results);
chdir($conf['home']);
if(is_array($results)){
......
......@@ -9,7 +9,7 @@ if($_GET['q'] == 'import'){
//Test if LODSPeaKr is configured
if(!file_exists('settings.inc.php')){
echo 'Need to configure lodspeakr first. Please run "install.sh" first. Alternatively, you can <a href="import">import an existing application</a>';
echo 'Need to configure lodspeakr firstResults. Please run "install.sh" firstResults. Alternatively, you can <a href="import">import an existing application</a>';
exit(0);
}
......@@ -27,7 +27,7 @@ include_once('classes/Queries.php');
include_once('classes/Endpoint.php');
include_once('classes/Convert.php');
$results = array();
$first = array();
$firstResults = array();
$endpoints = array();
$endpoints['local'] = new Endpoint($conf['endpoint']['local'], $conf['endpointParams']['config']);
......
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