Skip to content

Commit

Permalink
Merge pull request Islandora#21 from ajstanley/master
Browse files Browse the repository at this point in the history
Tested for Beta 3
  • Loading branch information
bwoodhead committed Dec 13, 2011
2 parents b0a9072 + 513d96d commit 8c5576a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 31 deletions.
6 changes: 1 addition & 5 deletions book.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class IslandoraBook {
public function showFieldSets() {
module_load_include('inc', 'islandora_book', 'book_pack_utils');
module_load_include('inc', 'islandora_book', 'add_pages');
drupal_set_title($this->item->objectProfile->objLabel);
module_load_include('module', 'islandora_book');
module_load_include('inc', 'fedora_repository', 'CollectionClass');
drupal_add_css(drupal_get_path('module', 'islandora_book') . '/css/islandora_book.css');
global $base_url;
$show_purge_tab = (!empty($_POST['form_id']) && ($_POST['form_id'] == 'islandora_book_purge_pages_form'));
$page_number = 1;
Expand Down Expand Up @@ -107,7 +107,3 @@ class IslandoraBook {

}





68 changes: 43 additions & 25 deletions book_object_manager.inc
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php


/**
* wrapper function to allow tab callback detail to be called from url
* @param string pid
* @return boolean
*/

function book_management_wrapper($pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
return drupal_render(get_page_model_management_content($pid));
Expand All @@ -17,8 +15,6 @@ function book_management_wrapper($pid) {
* @param string pid
* @return array
*/


function get_book_model_management_content($pid) {
$form['manage_book_tab'] = array(
'#type' => 'tabpage',
Expand All @@ -35,8 +31,6 @@ function get_book_model_management_content($pid) {
* @param string pid
* @return array
*/


function book_management_form(&$form_state, $pid) {

module_load_include('inc', 'islandora_book', 'book_pack_utils');
Expand All @@ -49,7 +43,7 @@ function book_management_form(&$form_state, $pid) {
$purge_form = drupal_get_form('fedora_repository_purge_object_form', $content_helper->pid, check_plain(substr(request_uri(), strlen(base_path()))));
$potential_collections = get_collections_as_option_array();
$current_collections = get_collection_relationships($pid);
$editform = drupal_get_form('fedora_repository_edit_qdc_form', $pid, 'DC');

$values = array_values($current_collections);
$collection_value = $values[0];
$keys = array_keys($current_collections);
Expand All @@ -74,26 +68,47 @@ function book_management_form(&$form_state, $pid) {
'#title' => t('Collection Membership'),
);


$form['collections']['current'] = array(
'#title' => 'Currently Member of',
'#type' => 'item',
'#value' => $collection_value,
$form['collections']['collection_add'] = array(
'#type' => 'fieldset',
'#collapsed' => true,
'#collapsible' => true,
'#title' => t('Add Book to Collection'),
);

$form['collections']['new_collection'] = array(
$form['collections']['collection_add']['new_collection'] = array(
'#title' => 'New Collection',
'#description' => t("Move book object to new collection"),
'#description' => t("Add book to new collection"),
'#type' => 'select',
'#options' => $potential_collections,
);

$form['collections']['submit'] = array(
$form['collections']['collection_add']['submit'] = array(
'#type' => 'submit',
'#id' => 'update_collection',
'#value' => t('Move Book to New Collection'),
'#id' => 'add_collection',
'#value' => t('Add Book to New Collection'),
);

if (count($current_collections) > 1) {
$form['collections']['collection_remove'] = array(
'#type' => 'fieldset',
'#collapsed' => true,
'#collapsible' => true,
'#title' => t('Remove Book from Collection'),
);

$form['collections']['collection_remove']['current'] = array(
'#title' => 'Currentl Memberships',
'#type' => 'select',
'#options' => $current_collections,
);

$form['collections']['collection_remove']['submit'] = array(
'#type' => 'submit',
'#id' => 'remove_collection',
'#value' => t('Remove Book from This Collection'),
);
}



$form['view_dc'] = array(
'#type' => 'fieldset',
Expand Down Expand Up @@ -185,20 +200,24 @@ function book_management_form(&$form_state, $pid) {
* @param array $form
* @param array $form_state
*/



function book_management_form_submit($form, &$form_state) {
global $user;
$book_pid = $form_state['values']['pid'];
$collection_pids = get_collection_from_pid($book_pid);
$item = new Fedora_Item($book_pid);
if ($form_state['clicked_button']['#id'] == 'update_collection') {

if ($form_state['clicked_button']['#id'] == 'add_collection') {
$new_collection = $form_state['values']['new_collection'];
$item->add_relationship('isMemberOfCollection', $new_collection, RELS_EXT_URI);
drupal_goto("fedora/repository/$new_collection");
}

if ($form_state['clicked_button']['#id'] == 'remove_collection') {
$current = $form_state['values']['current'];
$item->purge_relationship('isMemberOfCollection', $current);
drupal_goto("fedora/repository/$book_pid");
}

if ($form_state['clicked_button']['#id'] == 'refresh_datastreams') {
if ($form_state['values']['do_ocr']) {
$do_ocr = TRUE;
Expand All @@ -223,7 +242,6 @@ function book_management_form_submit($form, &$form_state) {
drupal_goto('fedora/repository/' . $collection_pids[0]);
}


function book_batch_update_pages($book_pid, $do_ocr, $refresh_images, $make_pdf) {
$page_pids = get_page_pids($book_pid);
$count = count($page_pids);
Expand Down Expand Up @@ -275,7 +293,6 @@ function replace_cover_thumbnail($book_pid, $page_pid) {
file_delete($file);
}


function recreate_pdf($book_pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'islandora_book', 'book_pack_utils');
Expand All @@ -300,4 +317,5 @@ function recreate_pdf($book_pid) {
$book_item->add_datastream_from_file($outputFile, 'PDF', "PDF of Book", 'application/pdf', 'M');
}
islandora_recursive_directory_delete($file_dir);
}
}

2 changes: 2 additions & 0 deletions islandora_book.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ package = Islandora Solution Pack
dependencies[] = fedora_repository
dependencies[] = xml_forms
dependencies[] = islandora_content_model_forms
dependencies[] = islandora_collection_manager
version = 11.3beta3

core = 6.x
5 changes: 4 additions & 1 deletion islandora_book.module
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ function islandora_book_islandora_tabs($content_models, $pid) {
module_load_include('inc', 'islandora_book', 'book_object_manager');
module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent');
if (!variable_get('islandora_add_collection_tabs', TRUE)) {
drupal_add_css(drupal_get_path('module', 'islandora_book') . '/css/islandora_book.css');

return;
}

Expand Down Expand Up @@ -97,9 +99,10 @@ function islandora_book_islandora_tabs($content_models, $pid) {

/**
* Implementation of hook_init
* (currenlty disabled)
*/

function islandora_book_init() {
function disabled_islandora_book_init() {

drupal_add_css(drupal_get_path('module', 'islandora_book') . '/css/islandora_book.css');

Expand Down

0 comments on commit 8c5576a

Please sign in to comment.