From dd9896d18787af2ea00ad0078265f41d317b164b Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Fri, 2 Aug 2013 17:19:55 +0000 Subject: [PATCH 1/4] Code style cleanup. --- includes/datastream.inc | 9 +++++++++ includes/datastream.version.inc | 2 ++ includes/ingest.form.inc | 27 ++++++++++++++++++++++----- includes/object.entity_controller.inc | 3 +++ includes/utilities.inc | 2 ++ tests/islandora_ingest_test.module | 12 +++++++----- theme/theme.inc | 12 ++++++++++++ 7 files changed, 57 insertions(+), 10 deletions(-) diff --git a/includes/datastream.inc b/includes/datastream.inc index 8a02439a..4b138bdf 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -112,6 +112,9 @@ function islandora_datastream_get_url(AbstractDatastream $datastream, $type = 'd * * @param AbstractDatastream $datastream * The datastream to generated the url to. + * + * @return string + * Markup containing the link to the confirm form to delete the datastream. */ function islandora_datastream_get_delete_link(AbstractDatastream $datastream) { $message = islandora_deprecated('7.x-1.2', 'Use the "islandora_datastream_delete_link" theme implementation.'); @@ -127,6 +130,9 @@ function islandora_datastream_get_delete_link(AbstractDatastream $datastream) { * * @param AbstractDatastream $datastream * The datastream to generated the url to. + * + * @return string + * Markup containing the link to edit the datastream. */ function islandora_datastream_edit_get_link(AbstractDatastream $datastream) { $message = islandora_deprecated('7.x-1.2', 'Use the "islandora_datastream_edit_link" theme implementation.'); @@ -169,6 +175,9 @@ function islandora_edit_datastream(AbstractDatastream $datastream) { * * @param array $edit_registry * A list of 'islandora_edit_datastream_registry' values. + * + * @return array + * A Drupal renderable array containing the "edit" markup. */ function islandora_edit_datastream_registry_render(array $edit_registry) { $markup = ''; diff --git a/includes/datastream.version.inc b/includes/datastream.version.inc index 2631790f..1e7c0830 100644 --- a/includes/datastream.version.inc +++ b/includes/datastream.version.inc @@ -65,6 +65,8 @@ function islandora_datastream_version_table($datastream) { * The Drupal form state. * @param AbstractDatastream $datastream * The datastream to be deleted. + * @param string $version + * The version number of the datastream we are trying to delete. * * @return array * The drupal form definition. diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 6faa642c..7edd0f60 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -186,10 +186,10 @@ function islandora_ingest_form_get_step(array &$form_state, $step_id = NULL) { * * @param array $form_state * The Drupal form state. - * @param string $step + * @param array $step * The step relative to the result, if not provided the current step is used. * - * @return string + * @return array|null * The next step if found, NULL otherwise. */ function islandora_ingest_form_get_next_step(array &$form_state, array $step = NULL) { @@ -205,10 +205,10 @@ function islandora_ingest_form_get_next_step(array &$form_state, array $step = N * * @param array $form_state * The Drupal form state. - * @param string $step + * @param array $step * The step relative to the result, if not provided the current step is used. * - * @return string + * @return array|null * The next step if found, NULL otherwise. */ function islandora_ingest_form_get_previous_step(array &$form_state, array $step = NULL) { @@ -329,6 +329,9 @@ function islandora_ingest_form_decrement_step(array &$form_state) { * The Drupal form. * @param array $form_state * The Drupal form state. + * @param string $step_id + * The ID of the step relative to the result, if not provided the current + * step_id is used. * * @return array * The form definition of the current step. @@ -363,6 +366,8 @@ function islandora_ingest_form_execute_step(array $form, array &$form_state, $st * The Drupal form. * @param array $form_state * The Drupal form state. + * @param array $step + * The step we are executing. * * @return array * The form definition of the given step. @@ -391,6 +396,8 @@ function islandora_ingest_form_execute_form_step(array $form, array &$form_state * The Drupal form. * @param array $form_state * The Drupal form state. + * @param array $step + * The step that execution begins from. */ function islandora_ingest_form_execute_consecutive_callback_steps(array $form, array &$form_state, array $step) { do { @@ -409,6 +416,8 @@ function islandora_ingest_form_execute_consecutive_callback_steps(array $form, a * The Drupal form. * @param array $form_state * The Drupal form state. + * @param array $step + * The step currently being executed. */ function islandora_ingest_form_execute_callback_step(array $form, array &$form_state, array $step) { $args = array(&$form_state); @@ -425,6 +434,8 @@ function islandora_ingest_form_execute_callback_step(array $form, array &$form_s * The Drupal form. * @param array $form_state * The Drupal form state. + * @param array $step + * The step that execution begins from. */ function islandora_ingest_form_undo_consecutive_callback_steps(array $form, array &$form_state, array $step) { do { @@ -443,6 +454,8 @@ function islandora_ingest_form_undo_consecutive_callback_steps(array $form, arra * The Drupal form. * @param array $form_state * The Drupal form state. + * @param array $step + * The step which the undo callback is being called on. */ function islandora_ingest_form_undo_callback_step(array $form, array &$form_state, array $step) { $args = array(&$form_state); @@ -457,11 +470,13 @@ function islandora_ingest_form_undo_callback_step(array $form, array &$form_stat * The Drupal form. * @param array $form_state * The Drupal form state. + * @param array $step + * An array defining a ingest step. * * @return array * The stepified Drupal form definition for the given step. */ -function islandora_ingest_form_stepify(array $form, array &$form_state, $step) { +function islandora_ingest_form_stepify(array $form, array &$form_state, array $step) { $first_form_step = islandora_ingest_form_on_first_form_step($form_state); $last_form_step = islandora_ingest_form_on_last_form_step($form_state); $form['form_step_id'] = array( @@ -692,6 +707,8 @@ function islandora_ingest_form_ingest_button(array &$form_state) { * * Attempts to ingest every object built by the previous steps. * + * @param array $form + * The Drupal form. * @param array $form_state * The Drupal form state. */ diff --git a/includes/object.entity_controller.inc b/includes/object.entity_controller.inc index d3fd6986..9464d7b5 100644 --- a/includes/object.entity_controller.inc +++ b/includes/object.entity_controller.inc @@ -24,6 +24,9 @@ class IslandoraObjectEntityController implements DrupalEntityControllerInterface * The ID's of the entities. * @param array $conditions * The conditions to apply. + * + * @return array + * An array of loaded objects. */ public function load($ids = array(), $conditions = array()) { if (!empty($conditions)) { diff --git a/includes/utilities.inc b/includes/utilities.inc index 5ce2ca14..c8d1ae5e 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -14,6 +14,8 @@ * * @param int $bytes * Size in bytes to convert + * @param int $precision + * The amount of decimal precision to show. * * @return string * Human readable size. diff --git a/tests/islandora_ingest_test.module b/tests/islandora_ingest_test.module index d414c717..8a6771d9 100644 --- a/tests/islandora_ingest_test.module +++ b/tests/islandora_ingest_test.module @@ -87,7 +87,11 @@ function islandora_ingest_test_test_testcmodel2_islandora_ingest_steps(array &$f * The Drupal form definition. */ function islandora_ingest_test_set_label_form(array $form, array &$form_state) { - $models = array('test:nomorestepscmodel', 'test:testcmodel', 'test:testcmodel2'); + $models = array( + 'test:nomorestepscmodel', + 'test:testcmodel', + 'test:testcmodel2', + ); $model = isset($form_state['values']['model']) ? $form_state['values']['model'] : reset($models); $shared_storage = &islandora_ingest_form_get_shared_storage($form_state); $shared_storage['models'] = array($model); @@ -139,8 +143,7 @@ function islandora_ingest_test_set_label_form_submit(array $form, array &$form_s * Test the First content model. */ function islandora_ingest_test_testcmodel_form(array $form, array &$form_state) { - return array( - ); + return array(); } /** @@ -154,8 +157,7 @@ function islandora_ingest_test_testcmodel_form_submit(array $form, array &$form_ * Test the second content model. */ function islandora_ingest_test_testcmodel2_form(array $form, array &$form_state) { - return array( - ); + return array(); } /** diff --git a/theme/theme.inc b/theme/theme.inc index 85341838..d988ee77 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -251,6 +251,9 @@ function islandora_preprocess_islandora_objects(array &$variables) { * @param array $vars * An array containing: * - datastream: An AbstractDatastream for which to generate a download link. + * + * @return string + * Markup containing the download url if the user has access, empty otherwise. */ function theme_islandora_datastream_download_link(array $vars) { $datastream = $vars['datastream']; @@ -270,6 +273,9 @@ function theme_islandora_datastream_download_link(array $vars) { * - datastream: An AbstractDatastream for which to generate a view link. * - label: (Optional) The label for the link. * - version: (Optional) The version of the datstream to link to. + * + * @return string + * Markup containing the link to the datastream or the label if inaccessible. */ function theme_islandora_datastream_view_link(array $vars) { $datastream = $vars['datastream']; @@ -304,6 +310,9 @@ function theme_islandora_datastream_view_link(array $vars) { * An array containing: * - datastream: An AbstractDatastream for which to generate a delete link. * - version: (optional) the version of the datastream to delete. + * + * @return string + * Markup containing the url to delete a datastream, or empty if inaccessible. */ function theme_islandora_datastream_delete_link(array $vars) { $datastream = $vars['datastream']; @@ -336,6 +345,9 @@ function theme_islandora_datastream_delete_link(array $vars) { * @param array $vars * An array containing: * - datastream: An AbstractDatastream for which to generate a edit link. + * + * @return string + * Markup containing the url to edit a datastream, or empty if inaccessible. */ function theme_islandora_datastream_edit_link(array $vars) { $datastream = $vars['datastream']; From 1fa7d0790fa9eeb12385309c156666f38189d4a7 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Fri, 2 Aug 2013 17:59:32 +0000 Subject: [PATCH 2/4] Actually use the fieldset that's defined. --- includes/add_datastream.form.inc | 72 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/includes/add_datastream.form.inc b/includes/add_datastream.form.inc index 62490c9a..2a215478 100644 --- a/includes/add_datastream.form.inc +++ b/includes/add_datastream.form.inc @@ -40,44 +40,44 @@ function islandora_add_datastream_form(array $form, array &$form_state, Abstract 'dsid' => array( '#title' => 'Datastream ID', '#description' => t("An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters, dashes and underscores. The following datastreams are defined by this content model but don't currently exist: @unused_dsids.", array('@unused_dsids' => $unused_datastreams)), + '#type' => 'textfield', + '#size' => 64, + '#maxlength' => 64, + '#required' => TRUE, + '#element_validate' => array( + 'islandora_add_datastream_form_field_is_not_an_existing_datastream_id', + 'islandora_add_datastream_form_field_starts_with_a_letter', + 'islandora_add_datastream_form_field_is_valid_dsid', + ), + '#autocomplete_path' => "islandora/object/{$object->id}/manage/datastreams/add/autocomplete", ), - '#type' => 'textfield', - '#size' => 64, - '#maxlength' => 64, - '#required' => TRUE, - '#element_validate' => array( - 'islandora_add_datastream_form_field_is_not_an_existing_datastream_id', - 'islandora_add_datastream_form_field_starts_with_a_letter', - 'islandora_add_datastream_form_field_is_valid_dsid', + 'label' => array( + '#title' => 'Datastream Label', + '#required' => TRUE, + '#size' => 64, + '#maxlength' => 64, + '#description' => t('A human-readable label'), + '#type' => 'textfield', + '#element_validate' => array('islandora_add_datastream_form_field_does_not_contain_a_forward_slash'), ), - '#autocomplete_path' => "islandora/object/{$object->id}/manage/datastreams/add/autocomplete", - ), - 'label' => array( - '#title' => 'Datastream Label', - '#required' => TRUE, - '#size' => 64, - '#maxlength' => 64, - '#description' => t('A human-readable label'), - '#type' => 'textfield', - '#element_validate' => array('islandora_add_datastream_form_field_does_not_contain_a_forward_slash'), - ), - 'file' => array( - '#type' => 'managed_file', - '#required' => TRUE, - '#title' => t('Upload Document'), - '#size' => 48, - '#description' => t('Select a file to upload.
Files must be less than @size MB.', array('@size' => $upload_size)), - '#default_value' => isset($form_state['values']['files']) ? $form_state['values']['files'] : NULL, - '#upload_location' => 'temporary://', - '#upload_validators' => array( - 'file_validate_extensions' => array(NULL), - // Assume its specified in MB. - 'file_validate_size' => array($upload_size * 1024 * 1024), + 'file' => array( + '#type' => 'managed_file', + '#required' => TRUE, + '#title' => t('Upload Document'), + '#size' => 48, + '#description' => t('Select a file to upload.
Files must be less than @size MB.', array('@size' => $upload_size)), + '#default_value' => isset($form_state['values']['files']) ? $form_state['values']['files'] : NULL, + '#upload_location' => 'temporary://', + '#upload_validators' => array( + 'file_validate_extensions' => array(NULL), + // Assume its specified in MB. + 'file_validate_size' => array($upload_size * 1024 * 1024), + ), + ), + 'submit' => array( + '#type' => 'submit', + '#value' => t('Add Datastream'), ), - ), - 'submit' => array( - '#type' => 'submit', - '#value' => t('Add Datastream'), ), ); } @@ -148,7 +148,7 @@ function islandora_add_datastream_form_field_does_not_contain_a_forward_slash(ar } /** - * Checks if the given datastream requires the upload to be a certian MIME type. + * Checks if the given datastream requires the upload to be a certain MIME type. * * @param array $form * The Drupal form. From 88448d329f41e4afd1cebbe14d29ceb9ef09a8e1 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Fri, 2 Aug 2013 18:01:24 +0000 Subject: [PATCH 3/4] Unique array key. --- includes/add_datastream.form.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/add_datastream.form.inc b/includes/add_datastream.form.inc index 2a215478..3a1d964d 100644 --- a/includes/add_datastream.form.inc +++ b/includes/add_datastream.form.inc @@ -32,7 +32,7 @@ function islandora_add_datastream_form(array $form, array &$form_state, Abstract '#attributes' => array( 'enctype' => 'multipart/form-data', ), - 'dsid' => array( + 'dsid_fieldset' => array( '#type' => 'fieldset', '#title' => 'Add a datastream', '#collapsible' => FALSE, From 7af39f17fcf9e0ca3cccbb3ef03253764f3ae0d8 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Fri, 2 Aug 2013 18:11:29 +0000 Subject: [PATCH 4/4] Spacing. --- includes/datastream.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/datastream.inc b/includes/datastream.inc index 4b138bdf..da55dcd5 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -131,7 +131,7 @@ function islandora_datastream_get_delete_link(AbstractDatastream $datastream) { * @param AbstractDatastream $datastream * The datastream to generated the url to. * - * @return string + * @return string * Markup containing the link to edit the datastream. */ function islandora_datastream_edit_get_link(AbstractDatastream $datastream) {