|
|
@ -127,9 +127,10 @@ class IslandoraBook { |
|
|
|
$title_info = $mods_item_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3', 'titleInfo')->item(0); |
|
|
|
$title_info = $mods_item_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3', 'titleInfo')->item(0); |
|
|
|
$title = ''; |
|
|
|
$title = ''; |
|
|
|
foreach(array('nonSort', 'title') as $title_field) { |
|
|
|
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(); |
|
|
|
$mods_text = $mods_item_doc->saveXML(); |
|
|
|
global $user; |
|
|
|
global $user; |
|
|
|
$mimetype = new MimeClass(); |
|
|
|
$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( |
|
|
|
$form['pid'] = array( |
|
|
|
'#type' => 'hidden', |
|
|
|
'#type' => 'hidden', |
|
|
|
'#value' => $pid, |
|
|
|
'#value' => $pid, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
$form['page_cmodel'] = array ( |
|
|
|
|
|
|
|
'#type' => 'hidden', |
|
|
|
|
|
|
|
'#value' => $page_cmodel, |
|
|
|
|
|
|
|
); |
|
|
|
$form['tiff_dir'] = array( |
|
|
|
$form['tiff_dir'] = array( |
|
|
|
'#type' => 'textfield', |
|
|
|
'#type' => 'textfield', |
|
|
|
'#title' => t('TIFF folder'), |
|
|
|
'#title' => t('TIFF folder'), |
|
|
@ -244,7 +248,7 @@ function book_add_pages_form_submit($form, &$form_state) { |
|
|
|
} |
|
|
|
} |
|
|
|
closedir($tiff_dir); |
|
|
|
closedir($tiff_dir); |
|
|
|
sort($file_list); |
|
|
|
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 |
|
|
|
* 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'); |
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
$book = new Fedora_Item($pid); |
|
|
|
$book = new Fedora_Item($pid); |
|
|
|
if (!$book->exists()) { |
|
|
|
if (!$book->exists()) { |
|
|
@ -267,17 +271,17 @@ function ilives_create_page_objects($pid, $image_list = array()) { |
|
|
|
$page_num = 1; |
|
|
|
$page_num = 1; |
|
|
|
$book_title = $book->objectProfile->objLabel; |
|
|
|
$book_title = $book->objectProfile->objLabel; |
|
|
|
foreach ($image_list as $image_path) { |
|
|
|
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++; |
|
|
|
$page_num++; |
|
|
|
} |
|
|
|
} |
|
|
|
batch_set($batch); |
|
|
|
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_utils'); |
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
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 = 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_relationship('isMemberOf', $book_pid); |
|
|
|
$page_item->add_datastream_from_file($page_file, 'TIFF', 'Archival TIFF', 'image/tiff', 'M'); |
|
|
|
$page_item->add_datastream_from_file($page_file, 'TIFF', 'Archival TIFF', 'image/tiff', 'M'); |
|
|
|
} |
|
|
|
} |
|
|
|