Browse Source

ISLANDORA_214

Book page ingest now supports newspaper pages.
pull/105/head
Alexander O'Neill 14 years ago
parent
commit
ae4bd5bef3
  1. 2
      fedora_repository.module
  2. 22
      ilives/book.inc
  3. 2
      plugins/islandora_newspaper/Newspaper.inc

2
fedora_repository.module

@ -1849,7 +1849,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
// Does the object exist? If so, purge it.
$item = new Fedora_Item($pid);
if ($item->exists()) {
$item->purge(t('Remove during re-install batch job'), TRUE);
$item->purge(t('Remove during re-install batch job'));
}
// Ingest the object from the source file.

22
ilives/book.inc

@ -127,9 +127,10 @@ class IslandoraBook {
$title_info = $mods_item_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3', 'titleInfo')->item(0);
$title = '';
foreach(array('nonSort', 'title') as $title_field) {
$title .= $title_info->getElementsByTagNameNS('http://www.loc.gov/mods/v3', $title_field)->item(0)->nodeValue;
$title .= $title_info->getElementsByTagNameNS('http://www.loc.gov/mods/v3', $title_field)->item(0)->nodeValue . ' ';
}
$title = trim($title);
$mods_text = $mods_item_doc->saveXML();
global $user;
$mimetype = new MimeClass();
@ -204,12 +205,15 @@ class IslandoraBook {
}
}
function book_add_pages_form(&$form_state, $pid) {
function book_add_pages_form(&$form_state, $pid, $page_cmodel = 'ilives:pageCModel') {
$form['pid'] = array(
'#type' => 'hidden',
'#value' => $pid,
);
$form['page_cmodel'] = array (
'#type' => 'hidden',
'#value' => $page_cmodel,
);
$form['tiff_dir'] = array(
'#type' => 'textfield',
'#title' => t('TIFF folder'),
@ -244,7 +248,7 @@ function book_add_pages_form_submit($form, &$form_state) {
}
closedir($tiff_dir);
sort($file_list);
ilives_create_page_objects($pid, $file_list);
ilives_create_page_objects($pid, $file_list, $form_state['values']['page_cmodel']);
}
}
}
@ -252,7 +256,7 @@ function book_add_pages_form_submit($form, &$form_state) {
/**
* Create a page object for each element in $image_list as a child object of $pid
*/
function ilives_create_page_objects($pid, $image_list = array()) {
function ilives_create_page_objects($pid, $image_list = array(), $page_cmodel = 'ilives:pageCModel') {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$book = new Fedora_Item($pid);
if (!$book->exists()) {
@ -267,17 +271,17 @@ function ilives_create_page_objects($pid, $image_list = array()) {
$page_num = 1;
$book_title = $book->objectProfile->objLabel;
foreach ($image_list as $image_path) {
$batch['operations'][] = array('ilives_add_single_page_object', array($pid, $image_path, $page_num, "$book_title - Page ". sprintf("%03d", $page_num)));
$batch['operations'][] = array('ilives_add_single_page_object', array($pid, $image_path, $page_num, "$book_title - Page ". sprintf("%03d", $page_num), $page_cmodel));
$page_num++;
}
batch_set($batch);
}
function ilives_add_single_page_object($book_pid, $page_file, $page_num = 1, $page_title = NULL) {
function ilives_add_single_page_object($book_pid, $page_file, $page_num = 1, $page_title = NULL, $page_cmodel = 'ilives:pageCModel') {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$page_item = Fedora_Item::ingest_new_item("$book_pid-". sprintf("%03d", $page_num), 'A', $page_title);
$page_item->add_relationship('hasModel', 'ilives:pageCModel', FEDORA_MODEL_URI);
$page_item->add_relationship('hasModel', $page_cmodel, FEDORA_MODEL_URI);
$page_item->add_relationship('isMemberOf', $book_pid);
$page_item->add_datastream_from_file($page_file, 'TIFF', 'Archival TIFF', 'image/tiff', 'M');
}

2
plugins/islandora_newspaper/Newspaper.inc

@ -122,7 +122,7 @@ class Newspaper {
$tabset['my_tabset']['add_pages'] = array(
'#type' => 'tabpage',
'#title' => t('Add pages'),
'#content' => drupal_get_form('book_add_pages_form', $this->pid),
'#content' => drupal_get_form('book_add_pages_form', $this->pid, 'newspapers:pageCModel'),
);
return tabs_render($tabset);
}

Loading…
Cancel
Save