|
|
@ -204,13 +204,13 @@ function islandora_escape_pid_for_function($pid) { |
|
|
|
// Apparently, case doesn't matter for function calls in PHP, so let's not |
|
|
|
// Apparently, case doesn't matter for function calls in PHP, so let's not |
|
|
|
// really worry about changing the case. |
|
|
|
// really worry about changing the case. |
|
|
|
return str_replace( |
|
|
|
return str_replace( |
|
|
|
// Any PID characters which are not valid in the name of a PHP function. |
|
|
|
// Any PID characters which are not valid in the name of a PHP function. |
|
|
|
array( |
|
|
|
array( |
|
|
|
':', |
|
|
|
':', |
|
|
|
'-', |
|
|
|
'-', |
|
|
|
), |
|
|
|
), |
|
|
|
'_', |
|
|
|
'_', |
|
|
|
$pid |
|
|
|
$pid |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -281,16 +281,16 @@ function islandora_namespace_accessible($id) { |
|
|
|
function islandora_get_parents_from_rels_ext(FedoraObject $object) { |
|
|
|
function islandora_get_parents_from_rels_ext(FedoraObject $object) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
$collections = array_merge( |
|
|
|
$collections = array_merge( |
|
|
|
$object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'), |
|
|
|
$object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'), |
|
|
|
$object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOf')); |
|
|
|
$object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOf')); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (RepositoryException $e) { |
|
|
|
catch (RepositoryException $e) { |
|
|
|
// @todo some logging would be nice, not sure what this throws. |
|
|
|
// @todo some logging would be nice, not sure what this throws. |
|
|
|
return array(); |
|
|
|
return array(); |
|
|
|
} |
|
|
|
} |
|
|
|
$map = function($o) { |
|
|
|
$map = function($o) { |
|
|
|
return islandora_object_load($o['object']['value']); |
|
|
|
return islandora_object_load($o['object']['value']); |
|
|
|
}; |
|
|
|
}; |
|
|
|
$collections = array_map($map, $collections); |
|
|
|
$collections = array_map($map, $collections); |
|
|
|
return array_filter($collections); |
|
|
|
return array_filter($collections); |
|
|
|
} |
|
|
|
} |
|
|
@ -505,7 +505,7 @@ function islandora_display_repository_inaccessible_message() { |
|
|
|
$text = t('Islandora configuration'); |
|
|
|
$text = t('Islandora configuration'); |
|
|
|
$link = l($text, 'admin/islandora/configure', array('attributes' => array('title' => $text))); |
|
|
|
$link = l($text, 'admin/islandora/configure', array('attributes' => array('title' => $text))); |
|
|
|
$message = t('Could not connect to the repository. Please check the settings on the !link page.', |
|
|
|
$message = t('Could not connect to the repository. Please check the settings on the !link page.', |
|
|
|
array('!link' => $link)); |
|
|
|
array('!link' => $link)); |
|
|
|
drupal_set_message($message, 'error', FALSE); |
|
|
|
drupal_set_message($message, 'error', FALSE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -744,7 +744,7 @@ function islandora_get_content_models($ignore_system_namespace = TRUE) { |
|
|
|
$label = $result['label']['value']; |
|
|
|
$label = $result['label']['value']; |
|
|
|
$namespace = islandora_get_namespace($content_model); |
|
|
|
$namespace = islandora_get_namespace($content_model); |
|
|
|
$ignore = $ignore_system_namespace && $namespace == 'fedora-system'; |
|
|
|
$ignore = $ignore_system_namespace && $namespace == 'fedora-system'; |
|
|
|
$ignore |= !islandora_namespace_accessible($namespace); |
|
|
|
$ignore |= ! islandora_namespace_accessible($namespace); |
|
|
|
if (!$ignore) { |
|
|
|
if (!$ignore) { |
|
|
|
$content_models[$content_model] = array('pid' => $content_model, 'label' => $label); |
|
|
|
$content_models[$content_model] = array('pid' => $content_model, 'label' => $label); |
|
|
|
} |
|
|
|
} |
|
|
@ -759,11 +759,12 @@ function islandora_get_content_models($ignore_system_namespace = TRUE) { |
|
|
|
* the name of the Drupal variable holding selected content models |
|
|
|
* the name of the Drupal variable holding selected content models |
|
|
|
* Content models held in this variable will appear at the top of |
|
|
|
* Content models held in this variable will appear at the top of |
|
|
|
* the displayed list |
|
|
|
* the displayed list |
|
|
|
* |
|
|
|
* @param array $default_values_array |
|
|
|
|
|
|
|
* default values to display if $drupal_variable is unset |
|
|
|
* @return array |
|
|
|
* @return array |
|
|
|
* Drupal form element allowing content model selection |
|
|
|
* Drupal form element allowing content model selection |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function islandora_content_model_select_table_form_element($drupal_variable) { |
|
|
|
function islandora_content_model_select_table_form_element($drupal_variable, $default_values_array = array('')) { |
|
|
|
$defaults = array(); |
|
|
|
$defaults = array(); |
|
|
|
$rows = array(); |
|
|
|
$rows = array(); |
|
|
|
$content_models = array(); |
|
|
|
$content_models = array(); |
|
|
@ -773,19 +774,24 @@ function islandora_content_model_select_table_form_element($drupal_variable) { |
|
|
|
$content_models[$option['pid']] = $option['label']; |
|
|
|
$content_models[$option['pid']] = $option['label']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$selected = array_values(variable_get($drupal_variable, array(''))); |
|
|
|
$selected = array_values(variable_get($drupal_variable, $default_values_array)); |
|
|
|
foreach ($selected as $selection) { |
|
|
|
$comparator = function ($a, $b) use ($selected) { |
|
|
|
if (isset($content_models[$selection])) { |
|
|
|
$a_val = $b_val = 0; |
|
|
|
$content_models = array($selection => $content_models[$selection]) + $content_models; |
|
|
|
if (in_array($a, $selected)) { |
|
|
|
} |
|
|
|
$a_val = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (in_array($b, $selected)) { |
|
|
|
|
|
|
|
$b_val = 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $a_val = $b_val; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
uksort($content_models, $comparator); |
|
|
|
foreach ($content_models as $pid => $label) { |
|
|
|
foreach ($content_models as $pid => $label) { |
|
|
|
$rows[$pid] = array( |
|
|
|
$rows[$pid] = array( |
|
|
|
'pid' => $pid, |
|
|
|
'pid' => $pid, |
|
|
|
'title' => $label, |
|
|
|
'title' => $label, |
|
|
|
); |
|
|
|
); |
|
|
|
in_array($pid, $selected) ? $defaults[$pid] = TRUE : $defaults[$pid] = FALSE; |
|
|
|
$defaults[$pid] = in_array($pid, $selected); |
|
|
|
} |
|
|
|
} |
|
|
|
$header = array( |
|
|
|
$header = array( |
|
|
|
'pid' => array('data' => t('PID')), |
|
|
|
'pid' => array('data' => t('PID')), |
|
|
|