Support @context in frame arrays.

This commit is contained in:
Dave Longley 2011-11-09 12:46:03 -05:00
parent 4eb2832c11
commit ff35e9796f

View file

@ -234,10 +234,26 @@ function jsonld_frame($input, $frame, $options=null)
if(property_exists($frame, '@context')) if(property_exists($frame, '@context'))
{ {
$ctx = _clone($frame->{'@context'}); $ctx = _clone($frame->{'@context'});
}
// remove context from frame // remove context from frame
$frame = jsonld_expand($frame); $frame = jsonld_expand($frame);
}
else if(is_array($frame))
{
// save first context in the array
if(count($frame) > 0 and property_exists($frame[0], '@context'))
{
$ctx = _clone($frame[0]->{'@context'});
}
// expand all elements in the array
$tmp = array();
foreach($frame as $f)
{
$tmp[] = jsonld_expand($f);
}
$frame = $tmp;
}
// create framing options // create framing options
// TODO: merge in options from function parameter // TODO: merge in options from function parameter