|
|
|
@ -744,7 +744,7 @@ function islandora_get_content_models($ignore_system_namespace = TRUE) {
|
|
|
|
|
$label = $result['label']['value']; |
|
|
|
|
$namespace = islandora_get_namespace($content_model); |
|
|
|
|
$ignore = $ignore_system_namespace && $namespace == 'fedora-system'; |
|
|
|
|
$ignore |= !islandora_namespace_accessible($namespace); |
|
|
|
|
$ignore |= ! islandora_namespace_accessible($namespace); |
|
|
|
|
if (!$ignore) { |
|
|
|
|
$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 |
|
|
|
|
* Content models held in this variable will appear at the top of |
|
|
|
|
* the displayed list |
|
|
|
|
* |
|
|
|
|
* @param array $default_values_array |
|
|
|
|
* default values to display if $drupal_variable is unset |
|
|
|
|
* @return array |
|
|
|
|
* 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(); |
|
|
|
|
$rows = array(); |
|
|
|
|
$content_models = array(); |
|
|
|
@ -773,19 +774,24 @@ function islandora_content_model_select_table_form_element($drupal_variable) {
|
|
|
|
|
$content_models[$option['pid']] = $option['label']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$selected = array_values(variable_get($drupal_variable, array(''))); |
|
|
|
|
foreach ($selected as $selection) { |
|
|
|
|
if (isset($content_models[$selection])) { |
|
|
|
|
$content_models = array($selection => $content_models[$selection]) + $content_models; |
|
|
|
|
$selected = array_values(variable_get($drupal_variable, $default_values_array)); |
|
|
|
|
$comparator = function ($a, $b) use ($selected) { |
|
|
|
|
$a_val = $b_val = 0; |
|
|
|
|
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) { |
|
|
|
|
$rows[$pid] = array( |
|
|
|
|
'pid' => $pid, |
|
|
|
|
'title' => $label, |
|
|
|
|
); |
|
|
|
|
in_array($pid, $selected) ? $defaults[$pid] = TRUE : $defaults[$pid] = FALSE; |
|
|
|
|
$defaults[$pid] = in_array($pid, $selected); |
|
|
|
|
} |
|
|
|
|
$header = array( |
|
|
|
|
'pid' => array('data' => t('PID')), |
|
|
|
|