Skip to content

Commit

Permalink
Move RDF implementations into lib/rdf/
Browse files Browse the repository at this point in the history
  • Loading branch information
nevali committed Apr 8, 2012
1 parent 6056f40 commit 203f013
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 58 deletions.
2 changes: 1 addition & 1 deletion lib/rdf.php
Expand Up @@ -511,7 +511,7 @@ public static function uriPredicates()
}
}

require_once(dirname(__FILE__) . '/' . EREGANSU_RDF_IMPLEMENTATION . '.php');
require_once(dirname(__FILE__) . '/rdf/' . EREGANSU_RDF_IMPLEMENTATION . '.php');

class RDFInstance extends RDFInstanceBase
{
Expand Down
File renamed without changes.
63 changes: 6 additions & 57 deletions lib/redland.php → lib/rdf/redland.php
Expand Up @@ -476,7 +476,8 @@ public function __construct($name, $mime = null, $uri = null, $world = null)

public function serializeModelToString(RedlandModel $model, $baseURI = null)
{
foreach(RDF::$namespaces as $uri => $prefix)
$ns = URI::namespaces();
foreach($ns as $uri => $prefix)
{
librdf_serializer_set_namespace($this->resource, librdf_new_uri($this->world->resource, $uri), $prefix);
}
Expand All @@ -485,7 +486,8 @@ public function serializeModelToString(RedlandModel $model, $baseURI = null)

public function serializeModelToFile(RedlandModel $model, $fileName, $baseURI = null)
{
foreach(RDF::$namespaces as $uri => $prefix)
$ns = URI::namespaces();
foreach($ns as $uri => $prefix)
{
librdf_serializer_set_namespace($this->resource, librdf_new_uri($this->world->resource, $uri), $prefix);
}
Expand Down Expand Up @@ -1828,62 +1830,9 @@ public function promote($subject)
}

/* Given a URI, generate a prefix:short form name */
public function namespacedName($qname, $generate = true)
public function namespacedName($uri, $generate = true)
{
RDF::ns();
$qname = strval($qname);
if(!isset($this->qnames[$qname]))
{
if(false !== ($p = strrpos($qname, '#')))
{
$ns = substr($qname, 0, $p + 1);
$lname = substr($qname, $p + 1);
}
else if(false !== ($p = strrpos($qname, ' ')))
{
$ns = substr($qname, 0, $p);
$lname = substr($qname, $p + 1);
}
else if(false !== ($p = strrpos($qname, '/')))
{
$ns = substr($qname, 0, $p + 1);
$lname = substr($qname, $p + 1);
}
else
{
return $qname;
}
if(!strcmp($ns, XMLNS::xml))
{
return 'xml:' . $lname;
}
if(!strcmp($ns, XMLNS::xmlns))
{
return 'xmlns:' . $lname;
}
if(!isset($this->namespaces[$ns]))
{
if(isset(RDF::$namespaces[$ns]))
{
$this->namespaces[$ns] = RDF::$namespaces[$ns];
}
else if($generate)
{
$this->namespaces[$ns] = 'ns' . count($this->namespaces);
}
else
{
return $qname;
}
}
if(!strlen($lname))
{
return $qname;
}
$pname = $this->namespaces[$ns] . ':' . $lname;
$this->qnames[$qname] = $pname;
}
return $this->qnames[$qname];
return URI::contractUri($uri, $generate);
}

/* Return the RDFInstance which is either explicitly or implicitly the
Expand Down

0 comments on commit 203f013

Please sign in to comment.