Protected method to serialise the properties of a resource @ignore
protected function serialiseProperties($res, $depth = 1) {
$properties = $res
->propertyUris();
$indent = str_repeat(' ', $depth * 2 - 1);
$turtle = '';
if (count($properties) > 1) {
$turtle .= "\n{$indent}";
}
$pCount = 0;
foreach ($properties as $property) {
$short = EasyRdf_Namespace::shorten($property, true);
if ($short) {
if ($short == 'rdf:type') {
$pStr = 'a';
}
else {
$this
->addPrefix($short);
$pStr = $short;
}
}
else {
$pStr = '<' . str_replace('>', '\\>', $property) . '>';
}
if ($pCount) {
$turtle .= " ;\n{$indent}";
}
$turtle .= ' ' . $pStr;
$oCount = 0;
foreach ($res
->all("<{$property}>") as $object) {
if ($oCount) {
$turtle .= ',';
}
if ($object instanceof EasyRdf_Resource and $object
->isBnode()) {
$id = $object
->getNodeId();
$rpcount = $this
->reversePropertyCount($object);
if ($rpcount <= 1 and !isset($this->outputtedBnodes[$id])) {
// Nested unlabelled Blank Node
$this->outputtedBnodes[$id] = true;
$turtle .= ' [';
$turtle .= $this
->serialiseProperties($object, $depth + 1);
$turtle .= ' ]';
}
else {
// Multiple properties pointing to this blank node
$turtle .= ' ' . $this
->serialiseObject($object);
}
}
else {
$turtle .= ' ' . $this
->serialiseObject($object);
}
$oCount++;
}
$pCount++;
}
if ($depth == 1) {
$turtle .= " .";
if ($pCount > 1) {
$turtle .= "\n";
}
}
elseif ($pCount > 1) {
$turtle .= "\n" . str_repeat(' ', ($depth - 1) * 2 - 1);
}
return $turtle;
}