Skip to content

Commit

Permalink
Merge pull request #574 from DiegoPino/7.x
Browse files Browse the repository at this point in the history
breadcrumbs xacml compliant
  • Loading branch information
ruebot committed Dec 30, 2014
2 parents 0c9c5e8 + fa14e83 commit 6cdfb43
Showing 1 changed file with 39 additions and 26 deletions.
65 changes: 39 additions & 26 deletions includes/breadcrumb.inc
Expand Up @@ -77,37 +77,50 @@ function islandora_get_breadcrumbs_recursive($pid, FedoraRepository $repository,
);
}
else {
$query_string = 'select $parentObject $title $content from <#ri>
where (
<info:fedora/' . $pid . '> <fedora-model:label> $title
and $parentObject <fedora-model:hasModel> $content
and (
<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject
)
and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>
)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
minus $parentObject <mulgara:is> <info:fedora/' . $pid . '>
order by $title desc';
$results = $repository->ri->itqlQuery($query_string);

if (count($results) > 0 && $context['level'] > 0) {
$parent = $results[0]['parentObject']['value'];
$this_title = $results[0]['title']['value'];
$query = <<<EOQ
PREFIX islandora-rels-ext: <http://islandora.ca/ontology/relsext#>
PREFIX fedora-rels-ext: <info:fedora/fedora-system:def/relations-external#>
SELECT DISTINCT ?object ?label
FROM <#ri>
WHERE {
<info:fedora/!pid> ?collection_predicate ?object;
<fedora-model:label> ?label .
?object <fedora-model:state> <fedora-model:Active>
.
!optionals
!filters
}
EOQ;

if (empty($this_title)) {
$this_title = t('-');
$query_optionals = (array) module_invoke('islandora_xacml_api', 'islandora_basic_collection_get_query_optionals', 'view');
$query_filters = (array) module_invoke('islandora_xacml_api', 'islandora_basic_collection_get_query_filters');
$filter_map = function ($filter) {
return "FILTER($filter)";
};
$query_filters[] = "sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOfCollection>) || sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOf>)";
$query = format_string($query, array(
'!optionals' => !empty($query_optionals) ? ('OPTIONAL {{' . implode('} UNION {', $query_optionals) . '}}') : '',
'!filters' => implode(' ', array_map($filter_map, $query_filters)),
));
$query = format_string($query, array(
'!pid' => $pid,
));

$results = $repository->ri->sparqlQuery($query, 'unlimited');

if (count($results) > 0 && $context['level'] > 0) {
$parent = $results[0]['object']['value'];
$this_label = $results[0]['label']['value'];

if (empty($this_label)) {
$this_label = t('-');
}

$context['level']--;
return array_merge(
islandora_get_breadcrumbs_recursive($parent, $repository, $context),
array(
l($this_title, "islandora/object/$pid"),
)
);
return array_merge(islandora_get_breadcrumbs_recursive($parent, $repository, $context), array(
l($this_label, "islandora/object/$pid"),
));
}
else {
// Add an non-link, as we don't know how to get back to the root, and
Expand Down

7 comments on commit 6cdfb43

@jordandukart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing isPartOf no?

@ruebot
Copy link
Member Author

@ruebot ruebot commented on 6cdfb43 Dec 30, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh-oh!

@DiegoPino, did we miss porting or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject to the SPARQL query?

@DiegoPino
Copy link

@DiegoPino DiegoPino commented on 6cdfb43 Dec 30, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jordandukart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding isConstituentOf probably would be a sound idea, not sure what other folks might say as a lot of people are still on holidays. I believe isPartOf is for legacy reasons iirc.

@ruebot
Copy link
Member Author

@ruebot ruebot commented on 6cdfb43 Dec 30, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding isConstituentOf
👍

@DiegoPino
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, doing so. But having no particular result order will give as result always the parent Collection first(first added predicate to the triple-store). the "order by $title DESC" of the previous itql should/could also be preserved? order by make things always slower. If no php sorting or precedence is being done, then maybe "Limit 1" is faster?Just thoughts. Thanks.

@DiegoPino
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added #575

Please sign in to comment.