Skip to content
Snippets Groups Projects
Commit a7bdb9af authored by alangrafu's avatar alangrafu
Browse files

Fixed small bugs

parent 07902d8d
No related branches found
No related tags found
No related merge requests found
<?
//Taken from http://www.php.net/manual/en/language.types.object.php#102735
//Based (but corrected) from http://www.php.net/manual/en/language.types.object.php#102735
final class Convert {
# Convert a stdClass to an Array.
static public function object_to_array(stdClass $Class){
# Typecast to (array) automatically converts stdClass -> array.
$Class = (array)$Class;
$newClass = array();
# Iterate through the former properties looking for any stdClass properties.
# Recursively apply (array).
foreach($Class as $key => $value){
if(is_object($value)&&get_class($value)==='stdClass'){
$Class[$key] = self::object_to_array($value);
$newClass[$key] = self::object_to_array($value);
}else{
$newClass[$key] = $value;
}
}
return $Class;
return $newClass;
}
# Convert an Array to stdClass.
......
......@@ -138,26 +138,26 @@ class Utils{
return $ct;
}
private static function serializeRdf($data, $extension){
global $conf;
require('lib/arc2/ARC2.php');
$parser = ARC2::getRDFParser();
$parser->parse($conf['basedir'], $data);
$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);
require('lib/arc2/ARC2.php');
$parser = ARC2::getRDFParser();
$parser->parse($conf['basedir'], $data);
$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);
return $doc;
}
......@@ -165,7 +165,7 @@ class Utils{
global $conf;
$contentType = $base['this']['contentType'];
$extension = Utils::getExtension($contentType);
header('Content-Type: '.$contentType);
if(!is_object($data)){
$data = Utils::serializeRdf($data, $extension);
......@@ -267,7 +267,7 @@ class Utils{
$baseObj = Convert::array_to_object($base);
$base = $baseObj;
}
$r2 = Convert::array_copy($results);
$r2 = Convert::array_copy($results);
$r = Convert::array_to_object($r2);
$vars = compact('uri', 'base', 'r');
$fnc = Haanga::compile(file_get_contents($modelFile));
......@@ -317,7 +317,7 @@ class Utils{
}
require_once('lib/Haanga/lib/Haanga.php');
Haanga::configure(array(
'template_dir' => $base['view']['directory'],
'template_dir' => $conf['home'].$base['view']['directory'],
'cache_dir' => $conf['home'].'cache/',
));
if(is_object($data)){
......
<?
//error_reporting(E_ERROR);
error_reporting(E_ERROR);
if(!file_exists('settings.inc.php')){
echo 'Need to configure lodspeakr first. Please run "install.sh" first';
......
......@@ -28,7 +28,7 @@ Since it is very simple, it may be prone to errors, but so far it is usable.
/*
*/
//The remote namespace
$remote = 'http://originalNamespace.com/data/';
......@@ -43,6 +43,7 @@ $newget = array();
foreach($_GET as $k => $v){
$newget[$k] = preg_replace("|$local|", $remote, $v);
}
$url .= '?';
$r = file_get_contents($url.http_build_query($newget));
......
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