Browse Source

Made query more robust

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

21
includes/utilities.inc

@ -717,13 +717,23 @@ function islandora_get_content_models($ignore_system_namespace = TRUE) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$tuque = islandora_get_tuque_connection(); $tuque = islandora_get_tuque_connection();
$query = 'PREFIX fm: <info:fedora/fedora-system:def/model#> $query = 'PREFIX fm: <info:fedora/fedora-system:def/model#>
PREFIX fr: <info:fedora/fedora-system:def/relations-external#>
SELECT ?object ?label SELECT ?object ?label
FROM <#ri> FROM <#ri>
WHERE { 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{ OPTIONAL{
?object fm:label ?label ?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(); $content_models = array();
$results = $tuque->repository->ri->sparqlQuery($query, 'unlimited'); $results = $tuque->repository->ri->sparqlQuery($query, 'unlimited');
@ -754,18 +764,11 @@ function islandora_get_content_models($ignore_system_namespace = TRUE) {
function islandora_content_model_select_table_form_element($drupal_variable) { function islandora_content_model_select_table_form_element($drupal_variable) {
$connection = islandora_get_tuque_connection(); $connection = islandora_get_tuque_connection();
$restricted = variable_get('islandora_namespace_restriction_enforced', FALSE); $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(); $defaults = array();
$rows = array(); $rows = array();
$content_models = array(); $content_models = array();
$options = islandora_get_content_models(TRUE);
$options = islandora_get_content_models(TRUE);
foreach($options as $option){ foreach($options as $option){
$content_models[$option['pid']] = $option['label']; $content_models[$option['pid']] = $option['label'];
} }

Loading…
Cancel
Save