diff --git a/admin/islandora.admin.inc b/admin/islandora.admin.inc index d82b8ef7..49de312c 100644 --- a/admin/islandora.admin.inc +++ b/admin/islandora.admin.inc @@ -1,11 +1,14 @@ api->m->getDatastream('fedora-system:ContentModel-3.0', 'DC'); } @@ -41,9 +44,9 @@ function islandora_repository_admin($form, &$form_state) { $dc = FALSE; } } - - if($info) { - if($dc) { + + if ($info) { + if ($dc) { $confirmation_message = '' . t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion'])); } @@ -77,7 +80,7 @@ function islandora_repository_admin($form, &$form_state) { '#type' => 'textfield', '#title' => t('Fedora base URL'), '#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'), - '#description' => t('The URL to use for REST connections
' . $confirmation_message), + '#description' => t('The URL to use for REST connections
' . $confirmation_message), '#required' => TRUE, '#ajax' => array( 'callback' => 'islandora_update_url_div', @@ -121,20 +124,20 @@ function islandora_repository_admin($form, &$form_state) { 'progress' => array('type' => 'throbber'), ), ); - - if(isset($form_state['values']['islandora_namespace_restriction_enforced'])) { + + if (isset($form_state['values']['islandora_namespace_restriction_enforced'])) { $namespaces = $form_state['values']['islandora_namespace_restriction_enforced']; } else { $namespaces = variable_get('islandora_namespace_restriction_enforced', FALSE); } - if($namespaces) { + if ($namespaces) { $form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_pids_allowed'] = array( '#type' => 'textfield', '#title' => t('PID namespaces allowed in this Drupal install'), '#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '), - '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation.
This could be more than a simple namespace ie demo:mydemos.
islandora: is reserved and is always allowed.'), + '#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation.
This could be more than a simple namespace ie demo:mydemos.
islandora: is reserved and is always allowed.'), '#weight' => 0, ); } @@ -158,6 +161,6 @@ function islandora_update_url_div($form, $form_state) { function islandora_update_namespace_div($form, $form_state) { unset($form_state['submit_handlers']); $form_state['rebuild'] = TRUE; - + return $form['islandora_tabs']['islandora_namespace']['wrapper']; } \ No newline at end of file diff --git a/includes/breadcrumb.inc b/includes/breadcrumb.inc index 3c725b7a..d1cacdbe 100644 --- a/includes/breadcrumb.inc +++ b/includes/breadcrumb.inc @@ -1,11 +1,16 @@ id, $breadcrumbs, $object->repository); - - if(isset($breadcrumbs[0])) { + + if (isset($breadcrumbs[0])) { unset($breadcrumbs[0]); } @@ -69,8 +74,8 @@ function islandora_get_breadcrumbs_recursive($pid, &$breadcrumbs, $repository) { islandora_get_breadcrumbs_recursive($parent, $breadcrumbs, $repository); } else { - $breadcrumbs[] = '...'; //Add an non-link, as we don't know how to get back to the root. - islandora_get_breadcrumbs_recursive($root, $breadcrumbs, $repository); //And render the last two links and break (on the next pass). + $breadcrumbs[] = '...'; // Add an non-link, as we don't know how to get back to the root. + islandora_get_breadcrumbs_recursive($root, $breadcrumbs, $repository); // And render the last two links and break (on the next pass). } } } \ No newline at end of file diff --git a/includes/datastream.inc b/includes/datastream.inc index 6a2e8724..fea8747c 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -1,26 +1,28 @@ mimetype); - if($object[$dsid]->controlGroup == 'M' || $object[$dsid]->controlGroup == 'X') { + if ($object[$dsid]->controlGroup == 'M' || $object[$dsid]->controlGroup == 'X') { header('Content-length: ' . $object[$dsid]->size); } @@ -45,7 +47,7 @@ function islandora_datastream_get_parents($islandora_object) { } $collections = array_merge($collections1, $collections2); - foreach($collections as $collection) { + foreach ($collections as $collection) { try { $pid = $collection['object']['value']; $object = $repository->getObject($collection['object']['value']); @@ -55,7 +57,9 @@ function islandora_datastream_get_parents($islandora_object) { $parent_collections[$pid]['label'] = $object->label; $parent_collections[$pid]['label_link'] = l($parent_collections[$pid]['label'], $parent_collections[$pid]['url']); } - catch (RepositoryException $e) {} + catch (RepositoryException $e) { + + } } return $parent_collections; @@ -65,13 +69,13 @@ function islandora_datastream_get_parents($islandora_object) { * * @param array $arr * an array of dsids that are defined by this objects cmodels - * @param string $ds_comp_stream + * @param string $ds_comp_stream * the dscomposite stream as xml */ function islandora_get_defined_dsids_array(&$arr, $ds_comp_stream) { $sxml = new SimpleXMLElement($ds_comp_stream); foreach ($sxml->dsTypeModel as $ds) { - //$arr[$ds['ID']] + //$arr[$ds['ID']] $mimes = array(); foreach ($ds->form as $form) { $mimetype = (string) $form['MIME']; @@ -88,13 +92,13 @@ function islandora_get_defined_dsids_array(&$arr, $ds_comp_stream) { * * @global type $user * @param string $object_id - * @return string|array + * @return string|array */ function islandora_get_unused_dsids($object) { $defined_dsids = array(); - if(!$object) { + if (!$object) { return $defined_dsids; } @@ -124,11 +128,11 @@ function islandora_get_unused_dsids($object) { * buids the default add datastream form * @param string $object_id * @param array $form_state - * @return array + * @return array * a form ready to be rendered with a call to Drupal render */ function islandora_get_add_datastream_form($object, &$form_state) { - $unused_dsids = islandora_get_unused_dsids($object); + $unused_dsids = islandora_get_unused_dsids($object); $form = array(); $form['add_fieldset'] = array( '#type' => 'fieldset', @@ -168,9 +172,9 @@ function islandora_get_add_datastream_form($object, &$form_state) { ); if (!empty($unused_dsids)) { - $dsidsForForm = array(); + $dsids_for_form = array(); foreach ($unused_dsids as $key => $value) { - $dsidsForForm[$key] = $key; + $dsids_for_form[$key] = $key; } $form['add_fieldset']['stream_id'] = array( '#type' => 'select', @@ -179,7 +183,7 @@ function islandora_get_add_datastream_form($object, &$form_state) { '#weight' => '-1', '#description' => t('Datastream IDs defined by the content model.'), ); - $form['add_fieldset']['stream_id']['#options'] = $dsidsForForm; + $form['add_fieldset']['stream_id']['#options'] = $dsids_for_form; } else { $form['add_fieldset']['stream_id'] = array( @@ -201,7 +205,7 @@ function islandora_get_add_datastream_form($object, &$form_state) { * Drupal user * @param array $form * @param array $form_state - * @return type + * @return type */ function islandora_add_datastream_form_submit($form, &$form_state) { global $base_url; @@ -212,7 +216,7 @@ function islandora_add_datastream_form_submit($form, &$form_state) { module_load_include('inc', 'islandora', 'includes/mime.detect'); $mimetype = new MimeDetect(); - + $file = $form_state['values']['add-stream-file-location']; $file = drupal_realpath($file); @@ -220,11 +224,11 @@ function islandora_add_datastream_form_submit($form, &$form_state) { $dsid = $form_state['values']['stream_id']; $ds_label = $form_state['values']['stream_label']; $dformat = $mimetype->getMimeType($file); - $controlGroup = "M"; + $control_group = "M"; try { $fedora_object = islandora_object_load($object_id); - $ds = $fedora_object->constructDatastream($dsid, $controlGroup); + $ds = $fedora_object->constructDatastream($dsid, $control_group); $ds->label = $ds_label; $ds->mimetype = $dformat; $ds->setContentFromFile($file); @@ -235,16 +239,16 @@ function islandora_add_datastream_form_submit($form, &$form_state) { drupal_set_message(t('@message', array('@message' => check_plain($e->getMessage()))), 'error'); return; } - drupal_set_message("Successfully Added Datastream!"); + drupal_set_message(t("Successfully Added Datastream!")); drupal_goto("islandora/object/$object_id"); } /** - * validates this datastream id against its allowed mimetypes in the dscomposite + * validates this datastream id against its allowed mimetypes in the dscomposite * of its content models. * @param array $form * @param array $form_state - * @return boolean + * @return boolean */ function islandora_add_datastream_form_validate($form, &$form_state) { module_load_include('inc', 'islandora', 'includes/mime.detect'); @@ -254,8 +258,8 @@ function islandora_add_datastream_form_validate($form, &$form_state) { return; } $dsid = $form_state['values']['stream_id']; - $dsLabel = $form_state['values']['stream_label']; - if (strlen($dsid) > 64) { + $ds_label = $form_state['values']['stream_label']; + if (drupal_strlen($dsid) > 64) { form_set_error('', t('Data stream ID cannot be more than 64 characters.')); return FALSE; } @@ -263,11 +267,11 @@ function islandora_add_datastream_form_validate($form, &$form_state) { form_set_error('', t("Data stream ID (@dsid) has to start with a letter.", array('@dsid' => check_plain($dsid)))); return FALSE; } - if (strlen($dsLabel) > 64) { + if (drupal_strlen($ds_label) > 64) { form_set_error('', t('Data stream Label cannot be more than 64 characters.')); return FALSE; } - if (strpos($dsLabel, '/')) { + if (strpos($ds_label, '/')) { form_set_error('', t('Data stream Label cannot contain a "/".')); return FALSE; } @@ -275,7 +279,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) { $object_id = $form_state['values']['pid']; $fedora_object = islandora_object_load($object_id); - if(isset($fedora_object[$dsid])) { + if (isset($fedora_object[$dsid])) { form_set_error('', t('Data stream ID already exists in object.')); return FALSE; } @@ -283,7 +287,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) { $mimetype = new MimeDetect(); $object = islandora_object_load($form_state['values']['pid']); $unused_dsids = islandora_get_unused_dsids($object); - if(isset($unused_dsids[$dsid])) { + if (isset($unused_dsids[$dsid])) { $types_allowed = $unused_dsids[$dsid]; $arr = array(); foreach ($types_allowed as $type) { @@ -295,7 +299,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) { // http://api.drupal.org/api/drupal/includes!file.inc/function/file_save_upload/7 $arr = array(); } - + $file = file_save_upload('add-stream-file-location', array('file_validate_extensions' => $arr)); if ($file) { @@ -312,7 +316,7 @@ function islandora_add_datastream_form_validate($form, &$form_state) { * buids the default add datastream form * @param string $object_id * @param array $form_state - * @return array + * @return array * a form ready to be rendered with a call to Drupal render */ function islandora_add_datastream_form($form, &$form_state, $object) { @@ -356,19 +360,19 @@ function islandora_add_datastream_form($form, &$form_state, $object) { ); $unused_dsids = islandora_get_unused_dsids($object); - $dsidsForForm = ''; + $dsids_for_form = ''; $i = 0; foreach ($unused_dsids as $key => $value) { - if($i++) { - $dsidsForForm .= ", "; + if ($i++) { + $dsids_for_form .= ", "; } - $dsidsForForm .= "'$key'"; + $dsids_for_form .= "'$key'"; } $form['add_fieldset']['stream_id'] = array( '#title' => 'Datastream ID', '#required' => 'TRUE', - '#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores. Datastreams that are defined by the content model dont currently exist: ' . $dsidsForForm . '.'), + '#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores. Datastreams that are defined by the content model dont currently exist: ' . $dsids_for_form . '.'), '#type' => 'textfield', '#weight' => -1, '#autocomplete_path' => "islandora/object/$object->id/manage/datastreams/add/autocomplete", @@ -379,13 +383,13 @@ function islandora_add_datastream_form($form, &$form_state, $object) { function islandora_datastream_autocomplete_callback($object, $string = '') { $dsids = islandora_get_unused_dsids($object); $output = array(); - foreach($dsids as $id => $ds) { - if(trim($string) == '') { + foreach ($dsids as $id => $ds) { + if (trim($string) == '') { $output[$id] = $id; } else { $ret = stripos($id, $string); - if($ret !== FALSE) { + if ($ret !== FALSE) { $output[$id] = $id; } } @@ -397,7 +401,7 @@ function islandora_datastream_get_human_readable_size($ds) { module_load_include('inc', 'islandora', 'includes/utilities'); // we return - if we don't have a size - if($ds->controlGroup == 'M' || $ds->controlGroup == 'X') { + if ($ds->controlGroup == 'M' || $ds->controlGroup == 'X') { return islandora_convert_bytes_to_human_readable($ds->size); } else { @@ -406,7 +410,7 @@ function islandora_datastream_get_human_readable_size($ds) { } function islandora_datastream_get_url($ds, $type = 'download') { - if($ds->controlGroup == 'R') { + if ($ds->controlGroup == 'R') { return $ds->url; } else { @@ -417,7 +421,7 @@ function islandora_datastream_get_url($ds, $type = 'download') { function islandora_datastream_get_delete_link($ds) { $datastreams = module_invoke_all('islandora_undeletable_datastreams', $ds->parent->models); - if(in_array($ds->id, $datastreams)) { + if (in_array($ds->id, $datastreams)) { return ''; } else { diff --git a/includes/ingest-menu.inc b/includes/ingest-menu.inc index 5c1dd9ee..56ae500e 100644 --- a/includes/ingest-menu.inc +++ b/includes/ingest-menu.inc @@ -11,13 +11,13 @@ * @param string $pid */ function islandora_ingest_callback($collection_object) { - if(!$collection_object) { + if (!$collection_object) { return drupal_not_found(); } $ingest_registry = module_invoke_all('islandora_ingest_registry', $collection_object); $registry_count = count($ingest_registry); - + if ($registry_count == 0) { // No ingest implementations. drupal_set_message(t('There are no ingest methods specified for @name.', array('@name', $collection_object->label))); @@ -33,7 +33,7 @@ function islandora_ingest_callback($collection_object) { } } -//@TODO: theme +// @TODO: theme function islandora_ingest_registry_render($ingest_registry) { $output = array( '#type' => 'markup', diff --git a/includes/islandora.ingest.inc b/includes/islandora.ingest.inc index fcc95964..bf33466a 100644 --- a/includes/islandora.ingest.inc +++ b/includes/islandora.ingest.inc @@ -1,5 +1,10 @@ models; $collection_info = module_invoke_all('islandora_ingest_get_information', $models, $collection_object); @@ -12,7 +17,7 @@ function islandora_ingest_get_object($content_models, $collection_pid, $relation global $user; $connection = new IslandoraTuque($user); $object = $connection->repository->constructObject($namespace); - foreach($content_models as $content_model) { + foreach ($content_models as $content_model) { $object->relationships->add(FEDORA_MODEL_URI, 'hasModel', $content_model['pid']); } $object->relationships->add(FEDORA_RELS_EXT_URI, $relationship, $collection_pid); diff --git a/includes/islandora_dublin_core.inc b/includes/islandora_dublin_core.inc index 41c9bbfa..25580b34 100644 --- a/includes/islandora_dublin_core.inc +++ b/includes/islandora_dublin_core.inc @@ -70,7 +70,7 @@ class Dublin_Core { /** * Serialize this object to XML and return it. * @param type $with_preamble - * @return type + * @return type */ function as_xml($with_preamble = FALSE) { $dc_xml = new DomDocument(); @@ -96,7 +96,7 @@ class Dublin_Core { * Create dc from dict ( does nothing ) */ static function create_dc_from_dict() { - + } function as_formatted_array() { @@ -108,9 +108,9 @@ class Dublin_Core { if (is_array($values)) { $value = ''; $i = 0; - foreach($values as $piece) { - if(!empty($piece)) { - if($i++) { + foreach ($values as $piece) { + if (!empty($piece)) { + if ($i++) { $value .= ", "; } $value .= $piece; @@ -121,16 +121,16 @@ class Dublin_Core { $value = $values; } $dc_label = explode(':', $field); - $element_label = ucfirst($dc_label[1]); + $element_label = drupal_ucfirst($dc_label[1]); $dc_array[$field]['label'] = $element_label; $dc_array[$field]['value'] = $value; - $dc_array[$field]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $field)); + $dc_array[$field]['class'] = drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $field)); } } } return $dc_array; } - + /** * Creates a new instance of the class by parsing dc_xml diff --git a/includes/mime.detect.inc b/includes/mime.detect.inc index f8878f68..3807c50e 100644 --- a/includes/mime.detect.inc +++ b/includes/mime.detect.inc @@ -227,7 +227,7 @@ class MimeDetect { public function getMimetype($filename, $debug = FALSE) { $file_name_and_extension = explode('.', $filename); - $ext = strtolower(array_pop($file_name_and_extension)); + $ext = drupal_strtolower(array_pop($file_name_and_extension)); if (!empty($this->protectedMimeTypes[$ext])) { if (TRUE === $debug) { diff --git a/includes/object_properties.inc b/includes/object_properties.inc index 2a521f5e..d4f7eeca 100644 --- a/includes/object_properties.inc +++ b/includes/object_properties.inc @@ -1,13 +1,20 @@ 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()))); + form_set_error('object_owner', t('Error updating owner %s', array('%s' => $e->getMessage()))); } } if (isset($state) && $state != $islandora_object->state) { @@ -40,7 +48,7 @@ function islandora_edit_properties_form_submit($form, &$form_state) { $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()))); + form_set_error('object_state', t('Error updating state %s', array('%s' => $e->getMessage()))); } } if (isset($label) && $label != $islandora_object->label) { @@ -53,18 +61,22 @@ function islandora_edit_properties_form_submit($form, &$form_state) { } } +/** + * Callback function for object properties admin form delete button. + */ function islandora_edit_properties_form_delete($form, &$form_state) { $islandora_object = $form_state['values']['pid']; drupal_goto("islandora/object/$islandora_object/delete"); } /** + * Object properties admin form. * * @param array $form * @param array $form_state * @param string $object_id * an object id - * @return array + * @return array */ function islandora_edit_properties_form($form, &$form_state, $object) { $form = array(); @@ -111,5 +123,3 @@ function islandora_edit_properties_form($form, &$form_state, $object) { ); return $form; } - -?> diff --git a/includes/purge.form.inc b/includes/purge.form.inc index 28a1854f..62c18ba9 100644 --- a/includes/purge.form.inc +++ b/includes/purge.form.inc @@ -1,5 +1,10 @@ $datastream_id, '%o' => $object->label))); drupal_goto('islandora/object/' . $object->id); } diff --git a/includes/tuque.inc b/includes/tuque.inc index 597f43fd..7693a703 100644 --- a/includes/tuque.inc +++ b/includes/tuque.inc @@ -1,5 +1,10 @@ uid == 0){ + + if (!isset($user) || $user->uid == 0) { $user_string = 'anonymous'; $pass_string = 'anonymous'; - } else { + } + else { $user_string = $user->name; $pass_string = $user->pass; } @@ -70,7 +76,7 @@ class IslandoraTuque { $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); } - if(self::exists()) { + if (self::exists()) { $this->connection = new RepositoryConnection($url, $user_string, $pass_string); $this->connection->reuseConnection = TRUE; $this->api = new FedoraApi($this->connection); @@ -87,7 +93,7 @@ class IslandoraTuque { $islandora_doc_link = l(t('Islandora documentation'), 'https://wiki.duraspace.org/display/ISLANDORA/Islandora'); $tuque_link = l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'); $message = t('Islandora requires the !tuque_url. Please install in /sites/all/libraries/tuque before continuing. See the !islandora_url.', array( '!tuque_url' => $tuque_link, '!islandora_url' => $islandora_doc_link)); - drupal_set_message($message, 'error', FALSE); + drupal_set_message(filter_xss($message), 'error', FALSE); } } diff --git a/includes/utilities.inc b/includes/utilities.inc index afcf5f94..d4cb0b40 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -1,39 +1,44 @@ = 0) && ($bytes < $kilobyte)) { - return $bytes . ' B'; +function islandora_convert_bytes_to_human_readable($bytes, $precision = 2) { + $kilobyte = 1024; + $megabyte = $kilobyte * 1024; + $gigabyte = $megabyte * 1024; + $terabyte = $gigabyte * 1024; - } 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'; - } + 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'; + } } function islandora_control_group_to_human_readable($control_group) { - switch($control_group) { + switch ($control_group) { case 'M': return 'Managed'; case 'X': @@ -54,7 +59,7 @@ function islandora_control_group_to_human_readable($control_group) { */ function islandora_validate_pid($pid) { $valid = FALSE; - if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { + if (drupal_strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { $valid = TRUE; } @@ -68,7 +73,7 @@ function islandora_validate_pid($pid) { */ function islandora_validate_dsid($dsid) { $valid = FALSE; - if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { + if (drupal_strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { $valid = TRUE; } @@ -76,9 +81,9 @@ function islandora_validate_dsid($dsid) { } /* Helper function to describe a Fedora repository. - * + * * Can be used to check if Fedora is available. - * + * * @param $url * A url to a Fedora repository. * @return @@ -86,7 +91,7 @@ function islandora_validate_dsid($dsid) { * or if the url is incorrect. */ function islandora_describe_repository($url) { - + $connection = new IslandoraTuque(NULL, $url); try { $info = $connection->api->a->describeRepository(); diff --git a/islandora.api.php b/islandora.api.php index 49085b1d..7dcfb87b 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -1,83 +1,89 @@ . */ -//Permissions +// Permissions define('FEDORA_VIEW', 'view fedora repository'); define('FEDORA_METADATA_EDIT', 'edit fedora metadata'); define('FEDORA_ADD_DS', 'add fedora datastreams'); @@ -31,12 +31,12 @@ define('FEDORA_PURGE', 'delete fedora objects and datastreams'); define('FEDORA_MODIFY_STATE', 'modify fedora state'); define('FEDORA_MANAGE', 'manage fedora items'); -//hooks +// hooks define('ISLANDORA_VIEW_HOOK', 'islandora_view_object'); define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object'); /** - * Implementation of hook_menu. + * Implements hook_menu(). * we need some standard entry points so we can have consistent urls for different Object actions */ function islandora_menu() { @@ -215,20 +215,20 @@ function islandora_admin_paths() { * @param string $op * @param string $pid * - * @return boolean + * @return boolean */ function islandora_access_callback($object = NULL, $perm = NULL) { - if(!$object || !$perm) { + if (!$object || !$perm) { return FALSE; } $isRestricted = variable_get('islandora_namespace_restriction_enforced', FALSE); - + if (!$isRestricted) { $namespace_access = TRUE; } else { - $pid_namespace = substr($object->id, 0, strpos($object->id, ':') + 1); //Get the namespace (with colon) + $pid_namespace = substr($object->id, 0, strpos($object->id, ':') + 1); // Get the namespace (with colon) $allowed_namespaces = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $namespace_access = in_array($pid_namespace, $allowed_namespaces); } @@ -238,7 +238,7 @@ function islandora_access_callback($object = NULL, $perm = NULL) { /** * returns an array listing object types provided by sub modules - * @return array + * @return array */ function islandora_get_types() { return module_invoke_all('islandora_get_types'); @@ -255,10 +255,10 @@ function islandora_init() { * that handle this function this module will build a default page. * @global object $user * @param string $object_id - * @return string + * @return string */ function islandora_edit_object($object) { - if(!$object) { + if (!$object) { return drupal_not_found(); } drupal_alter('islandora_edit_object', $object); @@ -274,7 +274,7 @@ function islandora_edit_object($object) { /** * edit properties form * @param type $object_id - * @return string + * @return string */ function islandora_edit_properties($object_id) { $object = islandora_object_load($object_id); @@ -290,7 +290,7 @@ function islandora_edit_properties($object_id) { /** * builds a default page for the edit tab * - * @param object $fedora_object + * @param object $fedora_object * A tuque Fedora Object */ function islandora_islandora_edit_object($fedora_object) { @@ -315,14 +315,14 @@ function islandora_view_default_object() { * their modules want to provide a view for. * @global object $user * @param string $object_id - * - * @return string + * + * @return string */ function islandora_view_object($fedora_object = NULL) { module_load_include('inc', 'islandora', 'includes/breadcrumb'); global $user; - if(!$fedora_object) { + if (!$fedora_object) { return drupal_not_found(); } @@ -348,10 +348,10 @@ function islandora_view_object($fedora_object = NULL) { } /** - * the default view hook. If there are no modules registered to handle this objects cmodels or there are + * the default view hook. If there are no modules registered to handle this objects cmodels or there are * not any cmodels specified this will create a default display. * @param string $object_id - * @return string + * @return string */ function islandora_islandora_view_object($object) { $supported_models = islandora_get_types(); @@ -425,17 +425,17 @@ function islandora_permission() { * a helper function to get a connection and return an object * @global object $user * @param string $object_id - * @return FedoraObject + * @return FedoraObject */ function islandora_object_load($object_id) { module_load_include('inc', 'islandora', 'includes/tuque'); static $islandora_tuque = NULL; - if(!$islandora_tuque) { + if (!$islandora_tuque) { $islandora_tuque = new IslandoraTuque(); } - if(IslandoraTuque::exists()) { + if (IslandoraTuque::exists()) { try { $fedora_object = $islandora_tuque->repository->getObject($object_id); } catch (Exception $e) { @@ -450,13 +450,13 @@ function islandora_object_load($object_id) { } function islandora_ingest_access_callback($object, $perm) { - if(islandora_access_callback($object, $perm) === FALSE) { + if (islandora_access_callback($object, $perm) === FALSE) { return FALSE; } $ingest_registry = module_invoke_all('islandora_ingest_registry', $object); - if(count($ingest_registry) > 0) { + if (count($ingest_registry) > 0) { return TRUE; } else { diff --git a/theme/islandora-object-edit.tpl.php b/theme/islandora-object-edit.tpl.php index 2d88e27e..f0005083 100644 --- a/theme/islandora-object-edit.tpl.php +++ b/theme/islandora-object-edit.tpl.php @@ -1,50 +1,24 @@ . - */ -?> -label * $object->id * to get the contents of a datastream - * $object['dsid']->content - * + * $object['dsid']->content + * * $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. - * - * - * + * */ - -//dsm($object); - -drupal_set_title($islandora_object->label); -//print($islandora_object->label . ' ' . $islandora_object->id); -print (theme_table($variables['datastream_table'])); ?> +label); ?> + + \ No newline at end of file diff --git a/theme/islandora-object.tpl.php b/theme/islandora-object.tpl.php index 0dd6a66e..d6efaac3 100644 --- a/theme/islandora-object.tpl.php +++ b/theme/islandora-object.tpl.php @@ -1,30 +1,8 @@ . - */ -?> -label - The label for this object. diff --git a/theme/islandora.theme.inc b/theme/islandora.theme.inc index 821ddf95..b0e79739 100644 --- a/theme/islandora.theme.inc +++ b/theme/islandora.theme.inc @@ -1,5 +1,10 @@ mimetype; $datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds); $datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d"); - $datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id)); + $datastreams[$id]['class'] = drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id)); + } + catch (RepositoryException $e) { + } - catch (RepositoryException $e) {} } $variables['datastreams'] = $datastreams; try {