Browse Source

Made query more robust

pull/307/head
Alan Stanley 12 years ago
parent
commit
0731a26e15
  1. 23
      includes/utilities.inc

23
includes/utilities.inc

@ -717,14 +717,24 @@ function islandora_get_content_models($ignore_system_namespace = TRUE) {
module_load_include('inc', 'islandora', 'includes/utilities');
$tuque = islandora_get_tuque_connection();
$query = 'PREFIX fm: <info:fedora/fedora-system:def/model#>
PREFIX fr: <info:fedora/fedora-system:def/relations-external#>
SELECT ?object ?label
FROM <#ri>
WHERE {
?object fm:hasModel <info:fedora/fedora-system:ContentModel-3.0>;
{?object fm:hasModel <info:fedora/fedora-system:ContentModel-3.0>;
fm:state <info:fedora/fedora-system:def/model#Active>
OPTIONAL{
?object fm:label ?label
}
}
UNION
{?object fr:isMemberOfCollection <info:fedora/islandora:ContentModelsCollection>;
fm:state <info:fedora/fedora-system:def/model#Active>
OPTIONAL{
?object fm:label ?label
}
}';
}
}';
$content_models = array();
$results = $tuque->repository->ri->sparqlQuery($query, 'unlimited');
foreach ($results as $result) {
@ -754,18 +764,11 @@ function islandora_get_content_models($ignore_system_namespace = TRUE) {
function islandora_content_model_select_table_form_element($drupal_variable) {
$connection = islandora_get_tuque_connection();
$restricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
$allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string);
foreach ($namespaces as $namespace) {
if ($namespace) {
$allowed[] = trim($namespace);
}
}
$defaults = array();
$rows = array();
$content_models = array();
$options = islandora_get_content_models(TRUE);
foreach($options as $option){
$content_models[$option['pid']] = $option['label'];
}

Loading…
Cancel
Save