From 97297ea8108aea19e958d99df5f28045ee4e5500 Mon Sep 17 00:00:00 2001
From: alangrafu <alvaro@graves.cl>
Date: Mon, 7 Nov 2011 03:00:48 -0800
Subject: [PATCH] Fixing bug that did not allow to use external uris in other
 queries

---
 classes/Utils.php | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/classes/Utils.php b/classes/Utils.php
index 321057c4..66c063f3 100644
--- a/classes/Utils.php
+++ b/classes/Utils.php
@@ -87,9 +87,7 @@ class Utils{
   	  	foreach($aux as $w){
   	  	  $row = array();
   	  	  foreach($w as $k => $v){
-  	  	  	if($conf['use_external_uris'] === true && $v['type'] == 'uri'){
-  	  	  	  $v['value'] = preg_replace("|^".$conf['ns']['local']."|", $conf['basedir'], $v['value']);
-  	  	  	} 	  	
+  	  	  		
   	  	  	$row[$k]['value'] = $v['value'];
   	  	  	if($v['type'] == 'uri'){
   	  	  	  $row[$k]['curie'] = Utils::uri2curie($v['value']);
@@ -269,7 +267,10 @@ class Utils{
   	global $conf;
   	global $base;
   	global $results;
-   	
+   	$internalize = false;
+  	if(sizeof($rPointer) == 0 && $conf['use_external_uris']){
+  	  $internalize = true;
+  	}
   	$uri = $base['this']['value'];
   	$data = array();
   	
@@ -333,6 +334,23 @@ class Utils{
   	  	Utils::queryDir($modelFile, $rPointer);
   	  }
   	}
+  	
+  	if($internalize){
+  	  Utils::internalize($rPointer); 
+  	}
+  }
+  
+  private static function internalize($arr){
+  	foreach($array as $key => $value){
+  	  if(!isset($value['value'])){
+  	  	$array[$key] = Utils::internalize($value);
+  	  }else{
+  	  	if($value['uri'] == 1){
+  	  	  $value['value'] = preg_replace("|^".$conf['ns']['local']."|", $conf['basedir'], $value);
+  	  	  $value['curie'] = Utils::uri2curie($value['value']);
+  	  	}
+  	  } 
+  	}
   }
   
   
-- 
GitLab