Browse Source

Merge pull request #25 from bwoodhead/6.x

Fixed issues with add collection
pull/26/merge
Ben Woodhead 13 years ago
parent
commit
6023993939
  1. BIN
      .CollectionClass.inc.swp
  2. 11
      CollectionClass.inc
  3. 2
      ObjectHelper.inc
  4. 4
      SearchClass.inc
  5. 2
      api/fedora_item.inc
  6. 2
      fedora_repository.module
  7. 4
      formClass.inc

BIN
.CollectionClass.inc.swp

Binary file not shown.

11
CollectionClass.inc

@ -715,6 +715,7 @@ function collection_creation_form(&$form_state, $parent_collection_pid) {
'#title' => "Choose allowable content models for this collection", '#title' => "Choose allowable content models for this collection",
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#options' => $content_models, '#options' => $content_models,
'#required' => true,
'#description' => t("Content models describe the behaviours of objects with which they are associated."), '#description' => t("Content models describe the behaviours of objects with which they are associated."),
); );
@ -736,12 +737,17 @@ function collection_creation_form(&$form_state, $parent_collection_pid) {
*/ */
function collection_creation_form_validate($form, &$form_state) { function collection_creation_form_validate($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$pid = $form_state['values']['collection_pid']; $pid = $form_state['values']['collection_pid'];
$item = new fedora_item($pid); $item = new fedora_item($pid);
if ($item->exists()) { if ($item->exists()) {
drupal_set_message("$pid already exists within your repository. the PID must be unique", 'warning'); form_set_error('', t("$pid already exists within your repository. the PID must be unique"));
return; return;
} }
if (!valid_pid($pid)){
form_set_error('', t("$pid is not a valid identifier"));
return;
}
} }
/** /**
@ -759,6 +765,7 @@ function collection_creation_form_submit($form, &$form_state) {
$collection_pid = $form_state['values']['collection_pid']; $collection_pid = $form_state['values']['collection_pid'];
$new_collection_label = $form_state['values']['collection_name']; $new_collection_label = $form_state['values']['collection_name'];
$parent_collection = $form_state['values']['parent_collection']; $parent_collection = $form_state['values']['parent_collection'];
$pid_namespace = $form_state['values']['collection_namespace'];
$all_cModels = get_content_models_as_option_array(); $all_cModels = get_content_models_as_option_array();
$collection_policy = '<?xml version="1.0" encoding="UTF-8"?> $collection_policy = '<?xml version="1.0" encoding="UTF-8"?>
<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd"> <collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd">
@ -776,7 +783,7 @@ function collection_creation_form_submit($form, &$form_state) {
$node = $collection_policy_xml->content_models->addChild('content_model'); $node = $collection_policy_xml->content_models->addChild('content_model');
$node->addAttribute('dsid', 'ISLANDORACM'); $node->addAttribute('dsid', 'ISLANDORACM');
$node->addAttribute('name', $all_cModels[$content_model]); $node->addAttribute('name', $all_cModels[$content_model]);
$node->addAttribute('namespace', $pid_namespace . '1'); $node->addAttribute('namespace', $pid_namespace . ':1');
$node->addAttribute('pid', $content_model); $node->addAttribute('pid', $content_model);
} }
} }

2
ObjectHelper.inc

@ -601,7 +601,7 @@ class ObjectHelper {
if ($pid == NULL) { if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top'); $pid = variable_get('fedora_repository_pid', 'islandora:top');
} }
$nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); $nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$pos = NULL; $pos = NULL;
foreach ($nameSpaceAllowed as $nameSpace) { foreach ($nameSpaceAllowed as $nameSpace) {
$pos = stripos($pid, $nameSpace); $pos = stripos($pid, $nameSpace);

4
SearchClass.inc

@ -393,7 +393,7 @@ class SearchClass {
$proc->setParameter('', 'searchToken', drupal_get_token('fedora_repository_advanced_search')); //token generated by Drupal, keeps tack of what tab etc we are on $proc->setParameter('', 'searchToken', drupal_get_token('fedora_repository_advanced_search')); //token generated by Drupal, keeps tack of what tab etc we are on
$proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
$proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'objectsPage', base_path());
$proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$proc->setParameter('', 'hitPageStart', $startPage); $proc->setParameter('', 'hitPageStart', $startPage);
$proc->registerPHPFunctions(); $proc->registerPHPFunctions();
$xsl = new DomDocument(); $xsl = new DomDocument();
@ -443,7 +443,7 @@ class SearchClass {
$proc->setParameter('', 'userID', $user->uid); $proc->setParameter('', 'userID', $user->uid);
$proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
$proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'objectsPage', base_path());
$proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$proc->setParameter('', 'orderBy', $orderBy); $proc->setParameter('', 'orderBy', $orderBy);
$xsl = new DomDocument(); $xsl = new DomDocument();

2
api/fedora_item.inc

@ -652,7 +652,7 @@ class Fedora_Item {
if (empty($pid_namespace)) { if (empty($pid_namespace)) {
// Just get the first one in the config settings. // Just get the first one in the config settings.
$allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')); $allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$pid_namespace = $allowed_namespaces[0]; $pid_namespace = $allowed_namespaces[0];
if (!empty($pid_namespace)) { if (!empty($pid_namespace)) {
$pid_namespace = substr($pid_namespace, 0, strpos($pid_namespace, ":")); $pid_namespace = substr($pid_namespace, 0, strpos($pid_namespace, ":"));

2
fedora_repository.module

@ -1194,7 +1194,7 @@ function fedora_repository_search_page($resultData) {
$proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on
$proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
$proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'objectsPage', base_path());
$proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$proc->registerPHPFunctions(); $proc->registerPHPFunctions();
$xsl = new DomDocument(); $xsl = new DomDocument();
if ($isRestricted) { if ($isRestricted) {

4
formClass.inc

@ -281,7 +281,7 @@ class formClass {
$form['fedora_namespace']['fedora_pids_allowed'] = array( $form['fedora_namespace']['fedora_pids_allowed'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('PID namespaces allowed in this Drupal install'), '#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '), '#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '),
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'), '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'),
'#weight' => 0 '#weight' => 0
); );
@ -290,7 +290,7 @@ class formClass {
$form['fedora_pids_allowed'] = array( $form['fedora_pids_allowed'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('PID namespaces allowed in this Drupal install'), '#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '), '#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '),
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'), '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'),
'#weight' => 0 '#weight' => 0
); );

Loading…
Cancel
Save