From 5110efd0867284736a091da2699e6ffed2bc619e Mon Sep 17 00:00:00 2001 From: krisbulman Date: Tue, 29 May 2012 09:06:30 -0300 Subject: [PATCH 01/24] moved add datastream link to action item --- includes/datastream.inc | 4 ++-- islandora.module | 53 +++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/includes/datastream.inc b/includes/datastream.inc index 2c7e58b2..197d5e2b 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -280,8 +280,8 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) { $form['add_fieldset'] = array( '#type' => 'fieldset', '#title' => 'Add a datastream', - '#collapsible' => TRUE, - '#collapsed' => TRUE, + '#collapsible' => FALSE, + '#collapsed' => FALSE, ); $form['add_fieldset']['add_datastream_label'] = array( '#value' => t('

Add Datastream:

'), diff --git a/islandora.module b/islandora.module index 521101bc..99b3ff7b 100644 --- a/islandora.module +++ b/islandora.module @@ -108,16 +108,7 @@ function islandora_menu() { 'access arguments' => array(FEDORA_VIEW), ); - - $items['islandora/object/%/add'] = array( - 'title' => 'Add to an object', - 'file' => 'includes/datastream.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('islandora_add_datastream_form',2), - 'type' => MENU_NORMAL_ITEM, - 'access arguments' => array(FEDORA_ADD_DS) - ); - + $items['islandora/object/%/view'] = array( 'title' => 'View', @@ -153,6 +144,7 @@ function islandora_menu() { 'weight' => -10, ); + $items['islandora/object/%/manage/properties'] = array( 'title' => 'Properties', 'page callback' => 'drupal_get_form', @@ -163,7 +155,6 @@ function islandora_menu() { 'weight' => -5, ); - $items['islandora/object/%/delete'] = array( 'title' => 'Purge object', 'page callback' => 'islandora_purge_object', @@ -172,6 +163,26 @@ function islandora_menu() { 'access arguments' => array(FEDORA_PURGE), ); + $items['islandora/object/%/manage/datastreams/add'] = array( + 'title' => 'Add a datastream', + 'file' => 'includes/datastream.inc', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('islandora_add_datastream_form', 2), + 'type' => MENU_NORMAL_ITEM, + 'access arguments' => array(FEDORA_ADD_DS) + ); + + + // $items['islandora/object/%/add'] = array( + // 'title' => 'Add to an object', + // 'file' => 'includes/datastream.inc', + // 'page callback' => 'drupal_get_form', + // 'page arguments' => array('islandora_add_datastream_form',2), + // 'type' => MENU_NORMAL_ITEM, + // 'access arguments' => array(FEDORA_ADD_DS) + // ); + + $items['islandora/object/%/datastream/%'] = array( 'title' => 'View datastream', 'page callback' => 'islandora_datastream_as_attachment', @@ -223,6 +234,24 @@ function islandora_admin_paths_alter(&$paths) { $paths['*/manage*'] = TRUE; } + +/** + * Implements hook_menu_local_tasks_alter(). + */ +function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) { + // Add action link 'islandora/object/%/manage/datastreams'. + $object_id = $router_item['page_arguments'][0]; + if ($root_path == 'islandora/object/%/manage/datastreams') { + $item = menu_get_item("islandora/object/$object_id/manage/datastreams/add"); + if ($item['access']) { + $data['actions']['output'][] = array( + '#theme' => 'menu_local_action', + '#link' => $item, + ); + } + } +} + /** * determines whether we can see the object or not * checks PID namespace permissions, and user permissions @@ -616,7 +645,7 @@ function islandora_preprocess_islandora_default_edit(&$variables) { $datastreams = array(); $variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id; module_load_include('inc','islandora','includes/datastream'); - $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); + // $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); foreach ($islandora_object as $ds) { $datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download'; $datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view'; From 6f57531da0219aea053655d42dab4bdff854f8bd Mon Sep 17 00:00:00 2001 From: krisbulman Date: Tue, 29 May 2012 09:22:30 -0300 Subject: [PATCH 02/24] moved call to get pid back into if statement that creates action link to remove error --- islandora.module | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/islandora.module b/islandora.module index 99b3ff7b..da0bfc58 100644 --- a/islandora.module +++ b/islandora.module @@ -234,14 +234,13 @@ function islandora_admin_paths_alter(&$paths) { $paths['*/manage*'] = TRUE; } - /** * Implements hook_menu_local_tasks_alter(). */ function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) { // Add action link 'islandora/object/%/manage/datastreams'. - $object_id = $router_item['page_arguments'][0]; if ($root_path == 'islandora/object/%/manage/datastreams') { + $object_id = $router_item['page_arguments'][0]; $item = menu_get_item("islandora/object/$object_id/manage/datastreams/add"); if ($item['access']) { $data['actions']['output'][] = array( From 5888b79a70309cc5cc50710df301cefbf5c12a12 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 09:40:13 -0300 Subject: [PATCH 03/24] made datastreams a default local task for manage tab --- islandora.module | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/islandora.module b/islandora.module index 99b3ff7b..3a7a217b 100644 --- a/islandora.module +++ b/islandora.module @@ -137,9 +137,9 @@ function islandora_menu() { $items['islandora/object/%/manage/datastreams'] = array( 'title' => 'Datastreams', - 'page callback' => 'islandora_edit_object', + //'page callback' => 'islandora_edit_object', 'page arguments' => array(2), - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_DEFAULT_LOCAL_TASK, 'access arguments' => array(FEDORA_PURGE), 'weight' => -10, ); @@ -241,7 +241,7 @@ function islandora_admin_paths_alter(&$paths) { function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) { // Add action link 'islandora/object/%/manage/datastreams'. $object_id = $router_item['page_arguments'][0]; - if ($root_path == 'islandora/object/%/manage/datastreams') { + if ($root_path == 'islandora/object/%/manage') { $item = menu_get_item("islandora/object/$object_id/manage/datastreams/add"); if ($item['access']) { $data['actions']['output'][] = array( From 64cda487b5d04693c3224fdc60022c807381d37b Mon Sep 17 00:00:00 2001 From: krisbulman Date: Tue, 29 May 2012 10:52:12 -0300 Subject: [PATCH 04/24] resolved word break problem in collection view --- css/islandora.base.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/css/islandora.base.css b/css/islandora.base.css index 0a8b3662..585ad756 100644 --- a/css/islandora.base.css +++ b/css/islandora.base.css @@ -32,14 +32,14 @@ dl.islandora-inline-metadata { .islandora-inline-metadata dt { margin-right: -1px; - width: 15.625%; - font-weight: normal; + width: 20.625%; font-weight: bold; padding-right: 0; + word-wrap: normal; } .islandora-inline-metadata dd { - width: 84.375%; + width: 79.375%; padding-left: 40px; } From 9cca7a3ce17e6122ca3726810f4bff73efef9898 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 10:59:40 -0300 Subject: [PATCH 05/24] updated properties form --- includes/object_properties.inc | 57 ++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/includes/object_properties.inc b/includes/object_properties.inc index 34a7b67e..c8589e62 100644 --- a/includes/object_properties.inc +++ b/includes/object_properties.inc @@ -1,8 +1,17 @@ owner){ - $params['ownerId'] = check_plain($owner); - $submit = TRUE; - } - if(isset($state) && $state != $islandora_object->state){ - $params['state'] = check_plain($state); - $submit = TRUE; + if (isset($owner) && $owner != $islandora_object->owner) { + try { + $islandora_object->owner = $owner; + drupal_set_message(t('Successfully updated owner %s', array('%s' => $owner))); + } catch (Exception $e) { + form_set_error('object_owner',t('Error updating owner %s', array('%s'=> $e->getMessage()))); + } } - if(isset($label) && $label != $islandora_object->label){ - $params['label'] = check_plain($label); - $submit = TRUE; + if (isset($state) && $state != $islandora_object->state) { + try { + $islandora_object->state = $state; + drupal_set_message(t('Successfully updated state %s', array('%s' => $state))); + } catch (Exception $e) { + form_set_error('object_state',t('Error updating state %s', array('%s'=> $e->getMessage()))); + } } - if($submit){ - $islandora_object->modifyObject($params); + if (isset($label) && $label != $islandora_object->label) { + try { + $islandora_object->label = $label; + drupal_set_message(t('Successfully updated label %s', array('%s' => check_plain($label)))); + } catch (Exception $e) { + form_set_error(t('Error updating label %s', array('%s' => $e->getMessage()))); + } } } @@ -45,10 +61,10 @@ function islandora_edit_properties_form_submit($form, &$form_state){ * an object id * @return array */ -function islandora_edit_properties_form ($form, &$form_state, $object_id){ +function islandora_edit_properties_form($form, &$form_state, $object_id) { $form = array(); $islandora_object = islandora_get_object($object_id); - if(!isset($islandora_object)){ + if (!isset($islandora_object)) { return NULL; } $form['pid'] = array( @@ -76,7 +92,7 @@ function islandora_edit_properties_form ($form, &$form_state, $object_id){ '#required' => TRUE, '#description' => t('The items state one of active, inactive or deleted'), '#type' => 'select', - '#options' => array ('A' => 'Active', 'I' => 'Inactive', 'D'=>'Deleted'), + '#options' => array('A' => 'Active', 'I' => 'Inactive', 'D' => 'Deleted'), ); $form['submit'] = array( '#type' => 'submit', @@ -84,4 +100,5 @@ function islandora_edit_properties_form ($form, &$form_state, $object_id){ ); return $form; } + ?> From a902683e98650b735398649e38db561d3c52a98d Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 12:12:20 -0300 Subject: [PATCH 06/24] used theme table for list of datastreams --- islandora-object-edit.tpl.php | 11 +---------- islandora.module | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/islandora-object-edit.tpl.php b/islandora-object-edit.tpl.php index f06d8f64..3145cf44 100644 --- a/islandora-object-edit.tpl.php +++ b/islandora-object-edit.tpl.php @@ -44,17 +44,8 @@ //dsm($object); drupal_set_title($islandora_object->label); -$islandora_datastreams = $variables['islandora_datastreams']; print($islandora_object->label . ' ' . $islandora_object->id); -print ('

datastreams

'); -foreach ($islandora_datastreams as $dsid => $ds) { - print (l($ds['label'],$ds['view_url'])); - print (' ' . l('download', $ds['download_url'])); - print (' ' . l('delete', $ds['delete_url'])); - print ('
'); -} -print (drupal_render($variables['add_datastream_form'])); -print (l(t('Edit Metadata'),$variables['islandora_editmetadata_url'])); +print ($variables['datastream_table']); ?> diff --git a/islandora.module b/islandora.module index 16732800..2c1c694c 100644 --- a/islandora.module +++ b/islandora.module @@ -149,7 +149,7 @@ function islandora_menu() { 'title' => 'Properties', 'page callback' => 'drupal_get_form', 'file' => 'includes/object_properties.inc', - 'page arguments' => array('islandora_edit_properties_form',2), + 'page arguments' => array('islandora_edit_properties_form', 2), 'type' => MENU_LOCAL_TASK, 'access arguments' => array(FEDORA_MODIFY_STATE), 'weight' => -5, @@ -181,7 +181,7 @@ function islandora_menu() { // 'type' => MENU_NORMAL_ITEM, // 'access arguments' => array(FEDORA_ADD_DS) // ); - + $items['islandora/object/%/datastream/%'] = array( 'title' => 'View datastream', @@ -381,7 +381,7 @@ function islandora_edit_object($object_id) { function islandora_edit_properties($object_id) { $object = islandora_get_object($object_id); if (isset($object)) { - module_load_include('inc','islandora','includes/object_properties'); + module_load_include('inc', 'islandora', 'includes/object_properties'); $form = drupal_get_form('islandora_edit_properties_form', $object); drupal_set_title($object->label); return drupal_render($form); @@ -643,13 +643,22 @@ function islandora_preprocess_islandora_default_edit(&$variables) { global $base_url; $datastreams = array(); $variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id; - module_load_include('inc','islandora','includes/datastream'); + module_load_include('inc', 'islandora', 'includes/datastream'); // $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); + $header = array( + array('data' => t('Label')), + array('data' => t('Operations'),'colspan' => '2'), + //array('data' => t('Delete')), + ); + $table_attributes = array('class' => array('manage-datastrea')); + $rows = array(); foreach ($islandora_object as $ds) { - $datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download'; - $datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view'; - $datastreams['delete_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete'; - $datastreams['label'] = $ds->label; - $variables['islandora_datastreams'][$ds->id] = $datastreams; + $rows[] = array( + array('class' => 'datastream-label', 'data' => l($ds->label, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), + array('class' => 'datastream-download', 'data' => l(t('download'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download')), + array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')), + ); } + $table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => NULL, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes); + $variables['datastream_table'] = theme_table($table); } \ No newline at end of file From 465ea079a23115003f5bcb969e01973d27114bf4 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 12:16:09 -0300 Subject: [PATCH 07/24] updated caption for datastreams table --- islandora-object-edit.tpl.php | 2 +- islandora.module | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/islandora-object-edit.tpl.php b/islandora-object-edit.tpl.php index 3145cf44..409c9781 100644 --- a/islandora-object-edit.tpl.php +++ b/islandora-object-edit.tpl.php @@ -44,7 +44,7 @@ //dsm($object); drupal_set_title($islandora_object->label); -print($islandora_object->label . ' ' . $islandora_object->id); +//print($islandora_object->label . ' ' . $islandora_object->id); print ($variables['datastream_table']); ?> diff --git a/islandora.module b/islandora.module index 2c1c694c..750fccaf 100644 --- a/islandora.module +++ b/islandora.module @@ -659,6 +659,7 @@ function islandora_preprocess_islandora_default_edit(&$variables) { array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')), ); } - $table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => NULL, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes); + $caption = $islandora_object->label . ' - ' . $islandora_object->id; + $table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => $caption, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes); $variables['datastream_table'] = theme_table($table); } \ No newline at end of file From 9dc897382e8aeaaad4e03d7c6d3e8d9b5b596b38 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Tue, 29 May 2012 12:24:39 -0300 Subject: [PATCH 08/24] Updated object template --- islandora-object.tpl.php | 55 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/islandora-object.tpl.php b/islandora-object.tpl.php index 06b11cab..6a6680d3 100644 --- a/islandora-object.tpl.php +++ b/islandora-object.tpl.php @@ -27,15 +27,46 @@ * this is a template for objects that do not have a module to registered to build their display. * * islandora_object is a fedora tuque Object - * $object->label - * $object->id + * $object->label - The label for this object. + * $object->id - The identifier of the object. + * $object->state - The state of this object. + * $object->createdDate - The date the object was ingested. + * $object->lastModifiedDate - The date teh object was last mofified. + * * to get the contents of a datastream - * $object['dsid']->content + * $object['dsid']->content + * + * to test if a datastream exists isset($object['dsid']) + * + * to iterate over datastreams: + * foreach($object as $ds) { + * $ds->label, etc + * } + * + * each $ds in the above loop has the following properties: + * $ds->label - The label for this datastream. + * $ds->id - The identifier of the datastream. + * $ds->controlGroup - The control group of the datastream. This + * property is read-only. This will return one of: "X", "M", "R", or "E". + * $ds->versionable - This defines if the datastream will be versioned + * or not. This is boolean. + * $ds->state - The state of the datastream. This will be one + * of: "A", "I", "D". + * $ds->mimetype - The mimetype of the datastrem. + * $ds->format - The format of the datastream + * $ds->size - The size of the datastream + * $ds->checksum - The checksum of the datastream + * $ds->checksumType - The type of checksum for the datastream. + * $ds->createdDate - The created date + * $ds->content - The content of the datastream + * $ds->url - The URL. This is only valid for R and E datastreams. * * $dublin_core is a Dublin_Core object * which is an array of elements, such as dc.title * and each element has an array of values. dc.title can have none, one or many titles * this is the case for all dc elements. + * + * * * we can get a list of datastreams by doing * foreach ($object as $ds){ @@ -90,4 +121,22 @@ drupal_set_title($islandora_object->label); + + + + + + + + + +
+ id; ?> + + label; ?> + + controlGroup; ?> + + mimetype; ?> +
From d1de0ce042dd882447efb07fce2ebe545a0b10b5 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Tue, 29 May 2012 14:29:20 -0300 Subject: [PATCH 09/24] Updated preprocessor function --- islandora.module | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/islandora.module b/islandora.module index 750fccaf..dcbb92ac 100644 --- a/islandora.module +++ b/islandora.module @@ -596,7 +596,20 @@ function islandora_permission() { */ function islandora_preprocess_islandora_default(&$variables) { $islandora_object = $variables['islandora_object']; + $repository = $islandora_object->repository; module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); + + $variables['parent_collections'] = array(); + $collections = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'); + foreach($collections as $collection) { + $pid = $collection['object']['value']; + $object = $repository->getObject($collection['object']['value']); + $variables['parent_collections'][$pid] = array(); + $variables['parent_collections'][$pid]['object'] = $object; + $variables['parent_collections'][$pid]['label'] = $object->label; + $variables['parent_collections'][$pid]['url'] = url('islandora/object/' . $object->id); + } + try { $dc = $islandora_object['DC']->content; //$dc_xml = simplexml_load_string($dc); From d51f9cad7e194983340e4dbc8c92b84b4eed6941 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 14:29:48 -0300 Subject: [PATCH 10/24] updated admin datastream table and started pager function --- includes/object_properties.inc | 1 + islandora.module | 16 +++++++++++----- .../islandora-basic-collection.tpl.php | 2 ++ .../islandora_basic_collection.module | 15 ++++++++++----- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/includes/object_properties.inc b/includes/object_properties.inc index c8589e62..97dd20a4 100644 --- a/includes/object_properties.inc +++ b/includes/object_properties.inc @@ -64,6 +64,7 @@ function islandora_edit_properties_form_submit($form, &$form_state) { function islandora_edit_properties_form($form, &$form_state, $object_id) { $form = array(); $islandora_object = islandora_get_object($object_id); + drupal_set_title($islandora_object->label); if (!isset($islandora_object)) { return NULL; } diff --git a/islandora.module b/islandora.module index 750fccaf..4dd75232 100644 --- a/islandora.module +++ b/islandora.module @@ -646,20 +646,26 @@ function islandora_preprocess_islandora_default_edit(&$variables) { module_load_include('inc', 'islandora', 'includes/datastream'); // $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); $header = array( + array('data' => t('ID')), + array('data' => t('Type')), + array('data' => t('Mime type')), array('data' => t('Label')), - array('data' => t('Operations'),'colspan' => '2'), - //array('data' => t('Delete')), + array('data' => t('Operations'), 'colspan' => '2'), + //array('data' => t('Delete')), ); $table_attributes = array('class' => array('manage-datastrea')); $rows = array(); foreach ($islandora_object as $ds) { $rows[] = array( + array('class' => 'datastream-label', 'data' => l($ds->id, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), + array('class' => 'datastream-label', 'data' => $ds->controlGroup), + array('class' => 'datastream-label', 'data' => $ds->mimeType), array('class' => 'datastream-label', 'data' => l($ds->label, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), - array('class' => 'datastream-download', 'data' => l(t('download'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download')), + array('class' => 'datastream-download', 'data' => l(t('download'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download')), array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')), - ); + ); } $caption = $islandora_object->label . ' - ' . $islandora_object->id; - $table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => $caption, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes); + $table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => $caption, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes); $variables['datastream_table'] = theme_table($table); } \ No newline at end of file diff --git a/islandora_basic_collection/islandora-basic-collection.tpl.php b/islandora_basic_collection/islandora-basic-collection.tpl.php index da5de757..92c9ec5f 100644 --- a/islandora_basic_collection/islandora-basic-collection.tpl.php +++ b/islandora_basic_collection/islandora-basic-collection.tpl.php @@ -25,11 +25,13 @@
+ $value): ?>
+
\ No newline at end of file diff --git a/islandora_basic_collection/islandora_basic_collection.module b/islandora_basic_collection/islandora_basic_collection.module index a288e00d..d0fecb9d 100644 --- a/islandora_basic_collection/islandora_basic_collection.module +++ b/islandora_basic_collection/islandora_basic_collection.module @@ -210,7 +210,7 @@ function islandora_basic_collection_islandora_get_types() { * @return string * themed html */ -function islandora_basic_collection_islandora_view_object($object, $user, $page_number, $page_size) { +function islandora_basic_collection_islandora_view_object($object, $user) { //global $user; $cmodel_list = islandora_basic_collection_islandora_get_types(); $models = $object->models; @@ -242,7 +242,13 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } catch (Exception $e) { drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error'); } - $variables['islandora_associated_objects'] = islandora_basic_collection_get_objects($islandora_object); + $page_number = (empty($_GET['page'])) ? '1' : $_GET['page']; + $page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_collection_pagesize',5) : $_GET['pagesize']; + $results = islandora_basic_collection_get_objects($islandora_object,$page_number,$page_size); + pager_default_initialize(count($results), $page_size); + $variables['islandora_associated_objects'] = $results; + $pager = theme('pager', array('quantity' => count($results))); + $variables['pager'] = $pager; $variables['islandora_dublin_core'] = $dc_object; $variables['islandora_object_label'] = $islandora_object->label; $variables['theme_hook_suggestions'][] = 'islandora_basic_collection__' . str_replace(':', '_', $islandora_object->id); @@ -260,6 +266,7 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } $associated_objects_array = array(); + //for($i=$page_size * ($page_number -1),$i < $page_size * ($page) foreach ($variables['islandora_associated_objects'] as $key => $value) { $pid = $variables['islandora_associated_objects'][$key]['object']['value']; $fc_object = islandora_basic_collection_get_object($pid); @@ -307,7 +314,7 @@ function islandora_basic_collection_get_object($object_id) { return $fedora_object; } -function islandora_basic_collection_get_objects($object) { +function islandora_basic_collection_get_objects($object, $page_number = 1, $page_size = 5) { $query = 'select $object $title $content from <#ri> where ($object $title and $object $content @@ -316,8 +323,6 @@ function islandora_basic_collection_get_objects($object) { and $object ) minus $content order by $title'; - $page_number = (empty($_GET['page'])) ? '1' : $_GET['page']; - $page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize']; module_load_include('inc', 'islandora', 'RestConnection'); $query_array = array('query' => $query, 'type' => 'itql', 'pid' => $object->id, 'page_size' => $page_size, 'page_number' => $page_number); drupal_alter('islandora_basic_collection_query', $query_array); From e35af9f7bf42d7b0a81589192702668a03d59aad Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 15:20:12 -0300 Subject: [PATCH 11/24] added admin section for collection paging and implemented paging --- .../islandora_basic_collection.admin.inc | 7 ++++++ .../islandora_basic_collection.module | 25 +++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/islandora_basic_collection/admin/islandora_basic_collection.admin.inc b/islandora_basic_collection/admin/islandora_basic_collection.admin.inc index 8311f3e8..1536de3b 100644 --- a/islandora_basic_collection/admin/islandora_basic_collection.admin.inc +++ b/islandora_basic_collection/admin/islandora_basic_collection.admin.inc @@ -10,6 +10,13 @@ function islandora_basic_collection_admin() { on a view tab you may have multiple modules configured to provide content for the default tab.'), '#weight' => -10 ); + $form['islandora_basic_collection_page_size'] = array( + '#type' => 'textfield', + '#title' => t('The default number of objects to show for a collection'), + '#default_value' => variable_get('islandora_basic_collection_page_size', '10'), + '#description' => t('The default number of object to show in a collection view.'), + '#weight' => -10 + ); return system_settings_form($form); } diff --git a/islandora_basic_collection/islandora_basic_collection.module b/islandora_basic_collection/islandora_basic_collection.module index d0fecb9d..8b0a2dd3 100644 --- a/islandora_basic_collection/islandora_basic_collection.module +++ b/islandora_basic_collection/islandora_basic_collection.module @@ -224,7 +224,7 @@ function islandora_basic_collection_islandora_view_object($object, $user) { } /** - * + * * @global type $base_url * @param array $variables * an array of variables that will be passed to the theme function @@ -242,12 +242,13 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } catch (Exception $e) { drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error'); } - $page_number = (empty($_GET['page'])) ? '1' : $_GET['page']; - $page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_collection_pagesize',5) : $_GET['pagesize']; - $results = islandora_basic_collection_get_objects($islandora_object,$page_number,$page_size); - pager_default_initialize(count($results), $page_size); - $variables['islandora_associated_objects'] = $results; - $pager = theme('pager', array('quantity' => count($results))); + $page_number = (empty($_GET['page'])) ? 0 : $_GET['page']; + $page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize']; + $results = islandora_basic_collection_get_objects($islandora_object, $page_number, $page_size); + $total_count = count($results); + pager_default_initialize($total_count, $page_size); + + $pager = theme('pager', array('quantity' => $total_count)); $variables['pager'] = $pager; $variables['islandora_dublin_core'] = $dc_object; $variables['islandora_object_label'] = $islandora_object->label; @@ -266,9 +267,11 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } $associated_objects_array = array(); - //for($i=$page_size * ($page_number -1),$i < $page_size * ($page) - foreach ($variables['islandora_associated_objects'] as $key => $value) { - $pid = $variables['islandora_associated_objects'][$key]['object']['value']; + $start = $page_size * ($page_number); + $end = min($start + $page_size, $total_count); + + for ($i = $start; $i < $end; $i++) { + $pid = $results[$i]['object']['value']; $fc_object = islandora_basic_collection_get_object($pid); if (!isset($fc_object)) { continue; //null object so don't show in collection view; @@ -283,7 +286,7 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } $object_url = 'islandora/object/' . $pid; $thumbnail_img = ''; - $title = $variables['islandora_associated_objects'][$key]['title']['value']; + $title = $results[$i]['title']['value']; $associated_objects_array[$pid]['pid'] = $pid; $associated_objects_array[$pid]['path'] = $object_url; $associated_objects_array[$pid]['title'] = $title; From ddb6737d534a5b9ad7be98b96efe09c9e0ae8193 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 16:11:25 -0300 Subject: [PATCH 12/24] added state to datastream admin table --- islandora.module | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/islandora.module b/islandora.module index dbfad96b..0ce2659c 100644 --- a/islandora.module +++ b/islandora.module @@ -661,6 +661,7 @@ function islandora_preprocess_islandora_default_edit(&$variables) { $header = array( array('data' => t('ID')), array('data' => t('Type')), + array('data' => t('State')), array('data' => t('Mime type')), array('data' => t('Label')), array('data' => t('Operations'), 'colspan' => '2'), @@ -670,9 +671,10 @@ function islandora_preprocess_islandora_default_edit(&$variables) { $rows = array(); foreach ($islandora_object as $ds) { $rows[] = array( - array('class' => 'datastream-label', 'data' => l($ds->id, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), - array('class' => 'datastream-label', 'data' => $ds->controlGroup), - array('class' => 'datastream-label', 'data' => $ds->mimeType), + array('class' => 'datastream-id', 'data' => l($ds->id, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), + array('class' => 'datastream-control', 'data' => $ds->controlGroup), + array('class' => 'datastream-state', 'data' => $ds->state), + array('class' => 'datastream-mime', 'data' => $ds->mimeType), array('class' => 'datastream-label', 'data' => l($ds->label, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), array('class' => 'datastream-download', 'data' => l(t('download'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download')), array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')), From 01c0c34daaf029667df431ab047343119408240a Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 16:15:58 -0300 Subject: [PATCH 13/24] updated basic image and basic collection admin forms --- .../admin/islandora_basic_collection.admin.inc | 2 +- islandora_basic_image/admin/islandora_basic_image.admin.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora_basic_collection/admin/islandora_basic_collection.admin.inc b/islandora_basic_collection/admin/islandora_basic_collection.admin.inc index 1536de3b..48b0164c 100644 --- a/islandora_basic_collection/admin/islandora_basic_collection.admin.inc +++ b/islandora_basic_collection/admin/islandora_basic_collection.admin.inc @@ -5,7 +5,7 @@ function islandora_basic_collection_admin() { $form['islandora_basic_collection_use_for_default_tab'] = array( '#type' => 'checkbox', '#title' => t('Provide the view for the default tab'), - '#default_value' => variable_get('islandora_basic_collection_use_for_default_tab', 'TRUE'), + '#default_value' => variable_get('islandora_basic_collection_use_for_default_tab', TRUE), '#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content on a view tab you may have multiple modules configured to provide content for the default tab.'), '#weight' => -10 diff --git a/islandora_basic_image/admin/islandora_basic_image.admin.inc b/islandora_basic_image/admin/islandora_basic_image.admin.inc index d31dbef0..2e6652f3 100644 --- a/islandora_basic_image/admin/islandora_basic_image.admin.inc +++ b/islandora_basic_image/admin/islandora_basic_image.admin.inc @@ -5,7 +5,7 @@ function islandora_basic_image_admin() { $form['islandora_basic_image_use_for_default_tab'] = array( '#type' => 'checkbox', '#title' => t('Provide the view for the default tab'), - '#default_value' => variable_get('islandora_basic_image_use_for_default_tab', 'TRUE'), + '#default_value' => variable_get('islandora_basic_image_use_for_default_tab', TRUE), '#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content on a view tab you may have multiple modules configured to provide content for the default tab.'), '#weight' => -10 From d232ab46f883bccb8e8a80899e03c57dc2579dd3 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 16:35:43 -0300 Subject: [PATCH 14/24] added alternate template for collection view --- .../islandora-basic-collection-grid.tpl.php | 37 +++++++++++++++++++ .../islandora_basic_collection.module | 23 +++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 islandora_basic_collection/islandora-basic-collection-grid.tpl.php diff --git a/islandora_basic_collection/islandora-basic-collection-grid.tpl.php b/islandora_basic_collection/islandora-basic-collection-grid.tpl.php new file mode 100644 index 00000000..05b3d807 --- /dev/null +++ b/islandora_basic_collection/islandora-basic-collection-grid.tpl.php @@ -0,0 +1,37 @@ +. + */ +?> + + +
+
+ + $value): ?> +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/islandora_basic_collection/islandora_basic_collection.module b/islandora_basic_collection/islandora_basic_collection.module index 8b0a2dd3..be4732ca 100644 --- a/islandora_basic_collection/islandora_basic_collection.module +++ b/islandora_basic_collection/islandora_basic_collection.module @@ -176,6 +176,11 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) { //an example template would be named islandora-basic-image--islandora-27.tpl.phps 'variables' => array('islandora_object' => NULL), ), + 'islandora_basic_collection_grid' => array( + 'template' => 'islandora-basic-collection-grid', + 'pattern' => 'islandora_basic_collection_grid__', + 'variables' => array('islandora_object' => NULL), + ), 'islandora_basic_collection_management_form_table' => array( 'arguments' => array('element' => NULL), 'file' => 'includes/CollectionManagerTable.inc', @@ -216,13 +221,27 @@ function islandora_basic_collection_islandora_view_object($object, $user) { $models = $object->models; foreach ($object->models as $model) { if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) { - $output = theme('islandora_basic_collection', array('islandora_object' => $object)); - return array('' => $output); + $display = (empty($_GET['display'])) ? 'list' : $_GET['display']; + if($display == 'grid'){ + $output = theme('islandora_basic_collection_grid', array('islandora_object' => $object)); + } else { + $output = theme('islandora_basic_collection', array('islandora_object' => $object)); + } + return array('Collection View' => $output); } } return NULL; } +/** + * list view preprocess + * currently just calls normal view preprocess as variables are the same + * @param type $variables + */ +function islandora_basic_collection_preprocess_islandora_basic_collection_grid(&$variables){ + islandora_basic_collection_preprocess_islandora_basic_collection($variables); +} + /** * * @global type $base_url From 335940697c0802e70a7acc4562dbe97797057546 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 29 May 2012 17:23:40 -0300 Subject: [PATCH 15/24] removed state from datastream admin table --- islandora.module | 2 -- 1 file changed, 2 deletions(-) diff --git a/islandora.module b/islandora.module index 0ce2659c..0c621c95 100644 --- a/islandora.module +++ b/islandora.module @@ -661,7 +661,6 @@ function islandora_preprocess_islandora_default_edit(&$variables) { $header = array( array('data' => t('ID')), array('data' => t('Type')), - array('data' => t('State')), array('data' => t('Mime type')), array('data' => t('Label')), array('data' => t('Operations'), 'colspan' => '2'), @@ -673,7 +672,6 @@ function islandora_preprocess_islandora_default_edit(&$variables) { $rows[] = array( array('class' => 'datastream-id', 'data' => l($ds->id, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), array('class' => 'datastream-control', 'data' => $ds->controlGroup), - array('class' => 'datastream-state', 'data' => $ds->state), array('class' => 'datastream-mime', 'data' => $ds->mimeType), array('class' => 'datastream-label', 'data' => l($ds->label, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), array('class' => 'datastream-download', 'data' => l(t('download'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download')), From 949c221c7909b2127c8c3096b1800f2f043fd12f Mon Sep 17 00:00:00 2001 From: krisbulman Date: Tue, 29 May 2012 22:28:20 -0300 Subject: [PATCH 16/24] basic object update. added items to datastreams array, added fieldset for file details, added table with datastream details to fieldset --- css/islandora.theme.css | 9 +++++-- islandora-object.tpl.php | 46 ++++++++++++++++++++---------------- islandora.module | 51 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 23 deletions(-) diff --git a/css/islandora.theme.css b/css/islandora.theme.css index e299b9db..29f14e66 100644 --- a/css/islandora.theme.css +++ b/css/islandora.theme.css @@ -13,19 +13,24 @@ dl.islandora-object-tn { float: left; width: 20.8333%; padding: 0 10px 0 0; - margin: 0; + margin: 1.5em 0; } dl.islandora-object-fields { float: right; width:79.1666%; - border-top:3px solid #ddd; + border-top:0px solid #ddd; + margin: 1.5em 0; } .islandora-object-fields dt { font-weight: bold; } +.islandora-object-fields dt.first { + border-top:0; +} + .islandora-object-fields dt, .islandora-object-fields dd { padding:6px 2% 4px; diff --git a/islandora-object.tpl.php b/islandora-object.tpl.php index 6a6680d3..614d72b1 100644 --- a/islandora-object.tpl.php +++ b/islandora-object.tpl.php @@ -57,7 +57,7 @@ * $ds->size - The size of the datastream * $ds->checksum - The checksum of the datastream * $ds->checksumType - The type of checksum for the datastream. - * $ds->createdDate - The created date + * $ds->createdDate->format("Y-m-d") - The created date with an option to use a format of your choice * $ds->content - The content of the datastream * $ds->url - The URL. This is only valid for R and E datastreams. * @@ -118,25 +118,31 @@ drupal_set_title($islandora_object->label);
- + - - - - - - - - - -
- id; ?> - - label; ?> - - controlGroup; ?> - - mimetype; ?> -
+ + diff --git a/islandora.module b/islandora.module index 0c621c95..2970cbf2 100644 --- a/islandora.module +++ b/islandora.module @@ -595,6 +595,8 @@ function islandora_permission() { * @param array $variables */ function islandora_preprocess_islandora_default(&$variables) { + drupal_add_js('misc/form.js'); + drupal_add_js('misc/collapse.js'); $islandora_object = $variables['islandora_object']; $repository = $islandora_object->repository; module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); @@ -609,7 +611,22 @@ function islandora_preprocess_islandora_default(&$variables) { $variables['parent_collections'][$pid]['label'] = $object->label; $variables['parent_collections'][$pid]['url'] = url('islandora/object/' . $object->id); } - + $datastreams = array(); + foreach ($islandora_object as $ds) { + $pid = $islandora_object->id; + $id = $ds->id; + $label = $ds->label; + $download_path = 'islandora/object/' . $pid . '/datastream/' . $id . '/download'; + $datastreams[$id]['id'] = $id; + $datastreams[$id]['label'] = $label; + $datastreams[$id]['label_link'] = l($label, $download_path); + $datastreams[$id]['download_url'] = $download_path; + $datastreams[$id]['mimetype'] = $ds->mimetype; + $datastreams[$id]['size'] = bytesToSize($ds->size); + $datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d"); + $datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id)); + } + $variables['datastreams'] = $datastreams; try { $dc = $islandora_object['DC']->content; //$dc_xml = simplexml_load_string($dc); @@ -626,6 +643,38 @@ function islandora_preprocess_islandora_default(&$variables) { } } +/** + * Convert bytes to human readable format + * + * @param integer bytes Size in bytes to convert + * @return string + */ +function bytesToSize($bytes, $precision = 2) +{ + $kilobyte = 1024; + $megabyte = $kilobyte * 1024; + $gigabyte = $megabyte * 1024; + $terabyte = $gigabyte * 1024; + + if (($bytes >= 0) && ($bytes < $kilobyte)) { + return $bytes . ' B'; + + } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { + return round($bytes / $kilobyte, $precision) . ' KB'; + + } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { + return round($bytes / $megabyte, $precision) . ' MB'; + + } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { + return round($bytes / $gigabyte, $precision) . ' GB'; + + } elseif ($bytes >= $terabyte) { + return round($bytes / $terabyte, $precision) . ' TB'; + } else { + return $bytes . ' B'; + } +} + /** * a helper function to get a connection and return an object * @global object $user From c8d10f4c4cb552cece3e6f082acc8c4960c9e91d Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Tue, 29 May 2012 22:44:10 -0300 Subject: [PATCH 17/24] Moved around some conversion functions. --- includes/utilities.inc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 includes/utilities.inc diff --git a/includes/utilities.inc b/includes/utilities.inc new file mode 100644 index 00000000..28e3b140 --- /dev/null +++ b/includes/utilities.inc @@ -0,0 +1,33 @@ += 0) && ($bytes < $kilobyte)) { + return $bytes . ' B'; + + } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { + return round($bytes / $kilobyte, $precision) . ' KB'; + + } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { + return round($bytes / $megabyte, $precision) . ' MB'; + + } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { + return round($bytes / $gigabyte, $precision) . ' GB'; + + } elseif ($bytes >= $terabyte) { + return round($bytes / $terabyte, $precision) . ' TB'; + } else { + return $bytes . ' B'; + } +} \ No newline at end of file From ef78943e94ad611dbc038ed162346e4e728ad0cf Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Tue, 29 May 2012 22:52:30 -0300 Subject: [PATCH 18/24] added to the manage tab --- islandora.module | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/islandora.module b/islandora.module index 2970cbf2..60f6f14c 100644 --- a/islandora.module +++ b/islandora.module @@ -600,6 +600,7 @@ function islandora_preprocess_islandora_default(&$variables) { $islandora_object = $variables['islandora_object']; $repository = $islandora_object->repository; module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); + module_load_include('inc', 'islandora', 'includes/utilities'); $variables['parent_collections'] = array(); $collections = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'); @@ -622,7 +623,7 @@ function islandora_preprocess_islandora_default(&$variables) { $datastreams[$id]['label_link'] = l($label, $download_path); $datastreams[$id]['download_url'] = $download_path; $datastreams[$id]['mimetype'] = $ds->mimetype; - $datastreams[$id]['size'] = bytesToSize($ds->size); + $datastreams[$id]['size'] = islandora_convert_bytes_to_human_readable($ds->size); $datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d"); $datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id)); } @@ -643,38 +644,6 @@ function islandora_preprocess_islandora_default(&$variables) { } } -/** - * Convert bytes to human readable format - * - * @param integer bytes Size in bytes to convert - * @return string - */ -function bytesToSize($bytes, $precision = 2) -{ - $kilobyte = 1024; - $megabyte = $kilobyte * 1024; - $gigabyte = $megabyte * 1024; - $terabyte = $gigabyte * 1024; - - if (($bytes >= 0) && ($bytes < $kilobyte)) { - return $bytes . ' B'; - - } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { - return round($bytes / $kilobyte, $precision) . ' KB'; - - } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { - return round($bytes / $megabyte, $precision) . ' MB'; - - } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { - return round($bytes / $gigabyte, $precision) . ' GB'; - - } elseif ($bytes >= $terabyte) { - return round($bytes / $terabyte, $precision) . ' TB'; - } else { - return $bytes . ' B'; - } -} - /** * a helper function to get a connection and return an object * @global object $user @@ -706,12 +675,14 @@ function islandora_preprocess_islandora_default_edit(&$variables) { $datastreams = array(); $variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id; module_load_include('inc', 'islandora', 'includes/datastream'); + module_load_include('inc', 'islandora', 'includes/utilities'); // $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); $header = array( array('data' => t('ID')), array('data' => t('Type')), array('data' => t('Mime type')), array('data' => t('Label')), + array('data' => t('Size')), array('data' => t('Operations'), 'colspan' => '2'), //array('data' => t('Delete')), ); @@ -723,6 +694,7 @@ function islandora_preprocess_islandora_default_edit(&$variables) { array('class' => 'datastream-control', 'data' => $ds->controlGroup), array('class' => 'datastream-mime', 'data' => $ds->mimeType), array('class' => 'datastream-label', 'data' => l($ds->label, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), + array('class' => 'datastream-size', 'data' => islandora_convert_bytes_to_human_readable($ds->size)), array('class' => 'datastream-download', 'data' => l(t('download'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download')), array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')), ); From fe5c54a3901cb88a458976e54accc8b19ca3e574 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Tue, 29 May 2012 23:22:38 -0300 Subject: [PATCH 19/24] Changed some things with datastreams so redirect and managed work okay. --- includes/datastream.inc | 4 +++- includes/utilities.inc | 15 +++++++++++++++ islandora.module | 26 +++++++++++++++++--------- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/includes/datastream.inc b/includes/datastream.inc index 197d5e2b..4e47a5c7 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -24,7 +24,9 @@ function islandora_datastream_as_attachment($object_id, $dsid) { return""; } header('Content-type: ' . $fedora_object[$dsid]->mimetype); - header('Content-length: ' . $fedora_object[$dsid]->size); + if($fedora_object[$dsid]->controlGroup == 'M' || $fedora_object[$dsid]->controlGroup == 'X') { + header('Content-length: ' . $fedora_object[$dsid]->size); + } header("Cache-control: private"); $method = arg(5); if (isset($method) && $method == 'download') { diff --git a/includes/utilities.inc b/includes/utilities.inc index 28e3b140..edb49780 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -30,4 +30,19 @@ function islandora_convert_bytes_to_human_readable($bytes, $precision = 2) } else { return $bytes . ' B'; } +} + +function islandora_control_group_to_human_readable($control_group) { + switch($control_group) { + case 'M': + return 'Managed'; + case 'X': + return 'Inline XML'; + case 'R': + return 'Redirect'; + case 'E': + return 'Externally Referenced'; + default: + return $control_group; + } } \ No newline at end of file diff --git a/islandora.module b/islandora.module index 60f6f14c..7d029a27 100644 --- a/islandora.module +++ b/islandora.module @@ -109,7 +109,6 @@ function islandora_menu() { ); - $items['islandora/object/%/view'] = array( 'title' => 'View', //'page callback' => 'islandora_view_object', @@ -144,7 +143,6 @@ function islandora_menu() { 'weight' => -10, ); - $items['islandora/object/%/manage/properties'] = array( 'title' => 'Properties', 'page callback' => 'drupal_get_form', @@ -617,13 +615,23 @@ function islandora_preprocess_islandora_default(&$variables) { $pid = $islandora_object->id; $id = $ds->id; $label = $ds->label; - $download_path = 'islandora/object/' . $pid . '/datastream/' . $id . '/download'; + if($ds->controlGroup != 'R') { + $download_path = 'islandora/object/' . $pid . '/datastream/' . $id . '/download'; + } + else { + $download_path = $ds->url; + } $datastreams[$id]['id'] = $id; $datastreams[$id]['label'] = $label; $datastreams[$id]['label_link'] = l($label, $download_path); $datastreams[$id]['download_url'] = $download_path; $datastreams[$id]['mimetype'] = $ds->mimetype; - $datastreams[$id]['size'] = islandora_convert_bytes_to_human_readable($ds->size); + if($ds->controlGroup == 'M' || $ds->controlGroup == 'X') { + $datastreams[$id]['size'] = islandora_convert_bytes_to_human_readable($ds->size); + } + else { + $datastreams[$id]['size'] = '-'; + } $datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d"); $datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id)); } @@ -679,9 +687,9 @@ function islandora_preprocess_islandora_default_edit(&$variables) { // $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); $header = array( array('data' => t('ID')), + array('data' => t('Label')), array('data' => t('Type')), array('data' => t('Mime type')), - array('data' => t('Label')), array('data' => t('Size')), array('data' => t('Operations'), 'colspan' => '2'), //array('data' => t('Delete')), @@ -690,11 +698,11 @@ function islandora_preprocess_islandora_default_edit(&$variables) { $rows = array(); foreach ($islandora_object as $ds) { $rows[] = array( - array('class' => 'datastream-id', 'data' => l($ds->id, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), - array('class' => 'datastream-control', 'data' => $ds->controlGroup), + array('class' => 'datastream-id', 'data' => $ds->id), + array('class' => 'datastream-label', 'data' => l($ds->label, $ds->controlGroup != 'R' ? $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view' : $ds->url)), + array('class' => 'datastream-control', 'data' => islandora_control_group_to_human_readable($ds->controlGroup)), array('class' => 'datastream-mime', 'data' => $ds->mimeType), - array('class' => 'datastream-label', 'data' => l($ds->label, $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view')), - array('class' => 'datastream-size', 'data' => islandora_convert_bytes_to_human_readable($ds->size)), + array('class' => 'datastream-size', 'data' => $ds->controlGroup == 'M' || $ds->controlGroup == 'X' ? islandora_convert_bytes_to_human_readable($ds->size) : '-'), array('class' => 'datastream-download', 'data' => l(t('download'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download')), array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')), ); From 096830c27a4d3a8d8fec492bb0efda305f2c861b Mon Sep 17 00:00:00 2001 From: krisbulman Date: Tue, 29 May 2012 23:44:03 -0300 Subject: [PATCH 20/24] added ismemberof collection output to displays --- islandora-object.tpl.php | 30 ++++--------------- islandora.module | 12 ++++---- .../css/islandora_basic_image.theme.css | 1 + .../islandora-basic-image.tpl.php | 8 +++++ .../islandora_basic_image.module | 13 ++++++++ 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/islandora-object.tpl.php b/islandora-object.tpl.php index 614d72b1..4a50d07f 100644 --- a/islandora-object.tpl.php +++ b/islandora-object.tpl.php @@ -75,30 +75,7 @@ * */ -//dsm($object); drupal_set_title($islandora_object->label); -// $dublin_core = $variables['islandora_dublin_core']; -// print($islandora_object->label . ' ' . $islandora_object->id); -// print ('

datastreams

'); -// foreach ($islandora_object as $ds) { -// print $ds->label . '
'; -// //do something -// } -// print('

Dublin Core

'); - -// foreach ($dublin_core as $element) { -// if (!empty($element)) { -// // print($element); -// foreach ($element as $key => $value) { -// foreach($value as $v){ -// if(!empty($v)){ -// print ''.($key).': ';print($v).'
'; -// } -// } -// } -// } -// } - ?>

Details

@@ -120,6 +97,12 @@ drupal_set_title($islandora_object->label); +
Collections
+
+ $value): ?> +
+ +
- diff --git a/islandora.module b/islandora.module index 60f6f14c..e7bb7502 100644 --- a/islandora.module +++ b/islandora.module @@ -602,16 +602,18 @@ function islandora_preprocess_islandora_default(&$variables) { module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); module_load_include('inc', 'islandora', 'includes/utilities'); - $variables['parent_collections'] = array(); + $parent_collections = array(); $collections = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'); foreach($collections as $collection) { $pid = $collection['object']['value']; $object = $repository->getObject($collection['object']['value']); - $variables['parent_collections'][$pid] = array(); - $variables['parent_collections'][$pid]['object'] = $object; - $variables['parent_collections'][$pid]['label'] = $object->label; - $variables['parent_collections'][$pid]['url'] = url('islandora/object/' . $object->id); + $parent_collections[$pid] = array(); + $parent_collections[$pid]['object'] = $object; + $parent_collections[$pid]['url'] = 'islandora/object/' . $object->id; + $parent_collections[$pid]['label'] = $object->label; + $parent_collections[$pid]['label_link'] = l($parent_collections[$pid]['label'], $parent_collections[$pid]['url']); } + $variables['parent_collections'] = $parent_collections; $datastreams = array(); foreach ($islandora_object as $ds) { $pid = $islandora_object->id; diff --git a/islandora_basic_image/css/islandora_basic_image.theme.css b/islandora_basic_image/css/islandora_basic_image.theme.css index e7b31c4d..93a8db89 100644 --- a/islandora_basic_image/css/islandora_basic_image.theme.css +++ b/islandora_basic_image/css/islandora_basic_image.theme.css @@ -56,6 +56,7 @@ body.two-sidebars .islandora-basic-image-sidebar { width: 60%; padding: 0 20px 0 0; float: left; /* LTR */ + margin-top: 1em; } body.no-sidebars .islandora-basic-image-sidebar { diff --git a/islandora_basic_image/islandora-basic-image.tpl.php b/islandora_basic_image/islandora-basic-image.tpl.php index a1a61da5..44228a7c 100644 --- a/islandora_basic_image/islandora-basic-image.tpl.php +++ b/islandora_basic_image/islandora-basic-image.tpl.php @@ -31,6 +31,14 @@

+
+

In Collections

+
    + $value): ?> +
  • + +
+