Skip to content

Commit

Permalink
Install drush with composer (#714)
Browse files Browse the repository at this point in the history
- Install Drush with composer and update to use latest phpcs sniffs. 
- Update codebase to to be compliant with new sniffs
  • Loading branch information
whikloj authored and jonathangreen committed Feb 12, 2019
1 parent f457a4a commit a46936c
Show file tree
Hide file tree
Showing 53 changed files with 652 additions and 437 deletions.
2 changes: 1 addition & 1 deletion includes/add_datastream.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function islandora_add_datastream_form_autocomplete_callback(AbstractObject $obj
$dsids = array_combine($dsids, $dsids);
$query = trim($query);
if (!empty($query)) {
$filter = function($id) use($query) {
$filter = function ($id) use ($query) {
return stripos($id, $query) !== FALSE;
};
$dsids = array_filter($dsids, $filter);
Expand Down
13 changes: 9 additions & 4 deletions includes/admin.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ function islandora_repository_admin(array $form, array &$form_state) {
'#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 <br/> !confirmation_message', array(
'!confirmation_message' => $confirmation_message)),
'!confirmation_message' => $confirmation_message,
)),
'#required' => TRUE,
'#ajax' => array(
'callback' => 'islandora_update_url_div',
Expand Down Expand Up @@ -225,17 +226,21 @@ function islandora_admin_settings_form_repository_access_message($url) {
if ($info && $dc) {
$confirmation_message = theme_image(array('path' => 'misc/watchdog-ok.png', 'attributes' => array()));
$confirmation_message .= t('Successfully connected to Fedora Server (Version !version).', array(
'!version' => $info['repositoryVersion']));
'!version' => $info['repositoryVersion'],
));
}
elseif ($info) {
$confirmation_message = theme_image(array('path' => 'misc/watchdog-warning.png', 'attributes' => array()));
$confirmation_message .= t('Unable to authenticate when connecting to to Fedora Server (Version !version). Please configure the !filter.', array(
'!version' => $info['repositoryVersion'], '!filter' => 'Drupal Filter'));
'!version' => $info['repositoryVersion'],
'!filter' => 'Drupal Filter',
));
}
else {
$confirmation_message = theme_image(array('path' => 'misc/watchdog-error.png', 'attributes' => array()));
$confirmation_message .= t('Unable to connect to Fedora server at !islandora_url', array(
'!islandora_url' => $url));
'!islandora_url' => $url,
));
}
return $confirmation_message;
}
Expand Down
10 changes: 5 additions & 5 deletions includes/authtokens.inc
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ function islandora_validate_object_token($pid, $dsid, $token) {
// Decrement authentication token uses.
else {
db_update("islandora_authtokens")
->fields(array('remaining_uses' => $remaining_uses))
->condition('token', $token, '=')
->condition('pid', $pid, '=')
->condition('dsid', $dsid, '=')
->execute();
->fields(array('remaining_uses' => $remaining_uses))
->condition('token', $token, '=')
->condition('pid', $pid, '=')
->condition('dsid', $dsid, '=')
->execute();
}
unset($result[0]->remaining_uses);
$accounts[$pid][$dsid][$token] = $result[0];
Expand Down
3 changes: 2 additions & 1 deletion includes/content_model.autocomplete.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file
* Autocomplete functionality for content models in Islandora.
Expand Down Expand Up @@ -46,7 +47,7 @@ function islandora_get_content_model_names() {
* @return array
* An array of results in a more usable format.
*/
function islandora_parse_query($content) {
function islandora_parse_query(array $content) {
$content_models = array();
foreach ($content as $model) {
$content_models[] = $model['object']['value'];
Expand Down
30 changes: 15 additions & 15 deletions includes/datastream.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ function islandora_download_datastream(AbstractDatastream $datastream) {
/**
* Callback function to view or download a datastream.
*
* @note
* This function calls exit().
*
* @param AbstractDatastream $datastream
* The datastream to view/download.
* @param bool $download
* If TRUE the file is download to the user computer for viewing otherwise it
* will attempt to display in the browser natively.
* @param int $version
* The version of the datastream to display
* The version of the datastream to display.
*
* @note
* This function calls exit().
*/
function islandora_view_datastream(AbstractDatastream $datastream, $download = FALSE, $version = NULL) {
module_load_include('inc', 'islandora', 'includes/mimetype.utils');
Expand Down Expand Up @@ -124,14 +124,14 @@ function islandora_view_datastream(AbstractDatastream $datastream, $download = F
* - fdsa
* - 2132
*
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26
*
* @param string $header_value
* The value from the headers.
*
* @return array
* An array containing all the etags present.
*
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26
*/
function islandora_parse_http_match_headers($header_value) {
$matches = array();
Expand Down Expand Up @@ -282,7 +282,7 @@ function islandora_datastream_get_human_readable_size(AbstractDatastream $datast
* @param string $type
* One of:
* - download
* - view
* - view.
* @param int $version
* (Optional) The version of the datastream to get a URL for.
*
Expand Down Expand Up @@ -394,7 +394,7 @@ function islandora_view_datastream_set_chunk_headers(AbstractDatastream $datastr
$c_start = $size - substr($range, 1);
}
else {
$range = explode('-', $range);
$range = explode('-', $range);
$c_start = $range[0];
$c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
}
Expand All @@ -409,8 +409,8 @@ function islandora_view_datastream_set_chunk_headers(AbstractDatastream $datastr
header("Content-Range: bytes $start-$end/$size");
exit;
}
$start = $c_start;
$end = $c_end;
$start = $c_start;
$end = $c_end;
// Calculate new content length.
$length = $end - $start + 1;
header('HTTP/1.1 206 Partial Content');
Expand All @@ -432,7 +432,7 @@ function islandora_view_datastream_set_chunk_headers(AbstractDatastream $datastr
* @param array $params
* An associate array containing the start and ending chunk bytes.
*/
function islandora_view_datastream_deliver_chunks(AbstractDatastream $datastream, $params) {
function islandora_view_datastream_deliver_chunks(AbstractDatastream $datastream, array $params) {
$file_uri = islandora_view_datastream_retrieve_file_uri($datastream);
// The meat of this has been taken from:
// http://mobiforge.com/design-development/content-delivery-mobile-devices.
Expand All @@ -459,14 +459,14 @@ function islandora_view_datastream_deliver_chunks(AbstractDatastream $datastream
* File locks are used to ensure the datastream is completely downloaded before
* attempting to serve up chunks from the file.
*
* @throws RepositoryException|Exception
* Exceptions may be thrown if the file was unable to be reliably acquired.
*
* @param AbstractDatastream $datastream
* An AbstractDatastream representing a datastream on a Fedora object.
*
* @return string
* The URI of the file.
*
* @throws RepositoryException|Exception
* Exceptions may be thrown if the file was unable to be reliably acquired.
*/
function islandora_view_datastream_retrieve_file_uri(AbstractDatastream $datastream) {
module_load_include('inc', 'islandora', 'includes/mimetype.utils');
Expand Down
31 changes: 17 additions & 14 deletions includes/datastream.version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,17 @@ function islandora_delete_datastream_version_form_submit(array $form, array &$fo
}
catch (Exception $e) {
drupal_set_message(t('Error deleting version %v of %s datastream from object %o %e', array(
'%v' => $version,
'%s' => $datastream_id,
'%o' => $object->label,
'%e' => $e->getMessage())), 'error');
'%v' => $version,
'%s' => $datastream_id,
'%o' => $object->label,
'%e' => $e->getMessage(),
)), 'error');
}

drupal_set_message(t('%d datastream version successfully deleted from Islandora object %o', array(
'%d' => $datastream_id,
'%o' => $object->label)));
'%d' => $datastream_id,
'%o' => $object->label,
)));

$form_state['redirect'] = "islandora/object/{$object->id}/datastream/{$datastream->id}/version";
}
Expand Down Expand Up @@ -224,9 +226,10 @@ function islandora_revert_datastream_version_form_submit(array $form, array &$fo
}

drupal_set_message(t('%d datastream successfully reverted to version %v for Islandora object %o', array(
'%d' => $datastream_to_revert->id,
'%v' => $version,
'%o' => $islandora_object->label)));
'%d' => $datastream_to_revert->id,
'%v' => $version,
'%o' => $islandora_object->label,
)));

$form_state['redirect'] = "islandora/object/{$islandora_object->id}/datastream/{$datastream_to_revert->id}/version";
}
Expand All @@ -235,9 +238,9 @@ function islandora_revert_datastream_version_form_submit(array $form, array &$fo
* Process available dsids, mime and extensions for a given object.
*
* @param AbstractObject $object
* The FedoraObject to process available extensions
* The FedoraObject to process available extensions.
*
* @return array()
* @return array
* An associative array, merged from calls to
* islandora_get_datastreams_requirements_from_content_models()
* and an objects dsid's.
Expand Down Expand Up @@ -272,7 +275,7 @@ function islandora_get_object_extensions(AbstractObject $object) {
* @return array
* The drupal form definition.
*/
function islandora_datastream_version_replace_form($form, &$form_state, AbstractDatastream $datastream) {
function islandora_datastream_version_replace_form(array $form, array &$form_state, AbstractDatastream $datastream) {
module_load_include('inc', 'islandora', 'includes/content_model');
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/mimetype.utils');
Expand Down Expand Up @@ -337,7 +340,7 @@ function islandora_datastream_version_replace_form($form, &$form_state, Abstract
* @param array $form_state
* The Drupal form state.
*/
function islandora_datastream_version_replace_form_submit($form, &$form_state) {
function islandora_datastream_version_replace_form_submit(array $form, array &$form_state) {
$object = islandora_object_load($form_state['object_id']);
$form_state['redirect'] = "islandora/object/{$object->id}";
$file = file_load($form_state['values']['file']);
Expand Down Expand Up @@ -370,7 +373,7 @@ function islandora_datastream_version_replace_form_submit($form, &$form_state) {
* Gets Audit datastream values from foxml.
*
* @param string $pid
* PID of parent object
* PID of parent object.
*
* @return array
* Array of audit values
Expand Down
17 changes: 10 additions & 7 deletions includes/delete_datastream.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,22 @@ function islandora_delete_datastream_form_submit(array $form, array &$form_state
}
catch (Exception $e) {
drupal_set_message(t('Error deleting %s datastream from object %o %e', array(
'%s' => $datastream_id,
'%o' => $object->label,
'%e' => $e->getMessage())), 'error');
'%s' => $datastream_id,
'%o' => $object->label,
'%e' => $e->getMessage(),
)), 'error');
}
if ($deleted) {
drupal_set_message(t('%d datastream sucessfully deleted from Islandora object %o', array(
'%d' => $datastream_id,
'%o' => $object->label)));
'%d' => $datastream_id,
'%o' => $object->label,
)));
}
else {
drupal_set_message(t('Error deleting %s datastream from object %o', array(
'%s' => $datastream_id,
'%o' => $object->label)), 'error');
'%s' => $datastream_id,
'%o' => $object->label,
)), 'error');
}
$form_state['redirect'] = "islandora/object/{$object->id}";
}
7 changes: 4 additions & 3 deletions includes/derivatives.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file
* Defines functions used when constructing derivatives.
Expand Down Expand Up @@ -221,7 +222,7 @@ function islandora_do_batch_derivatives(AbstractObject $object, array $options)
* @return array
* Returns the filtered array of hooks to be ran.
*/
function islandora_filter_derivatives($hooks, $options, AbstractObject $object) {
function islandora_filter_derivatives(array $hooks, array $options, AbstractObject $object) {
if (array_key_exists('source_dsid', $options)) {
$hooks = array_filter($hooks, function ($filter_hook) use ($options) {
return array_key_exists('source_dsid', $filter_hook) &&
Expand Down Expand Up @@ -296,10 +297,10 @@ function islandora_remove_defer_derivatives_flag(AbstractObject $object) {
*
* @param AbstractObject $object
* The object to find derivatives for.
* @param &array $options
* @param array $options
* Options for derivatives, will be updated to default force to FALSE.
*/
function islandora_get_derivative_list(AbstractObject $object, &$options) {
function islandora_get_derivative_list(AbstractObject $object, array &$options) {
module_load_include('inc', 'islandora', 'includes/utilities');

$ds_modified_params = isset($options['ds_modified_params']) ? $options['ds_modified_params'] : array();
Expand Down
8 changes: 4 additions & 4 deletions includes/dublin_core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

/**
* Dublin Core Class
* Dublin Core Class.
*/
class DublinCore {

Expand Down Expand Up @@ -40,7 +40,7 @@ class DublinCore {
*/
public function __construct($dc_xml = NULL) {
if (!empty($dc_xml)) {
$this->dc = self::importFromXMLString($dc_xml);
$this->dc = self::importFromXmlString($dc_xml);
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ class DublinCore {
* @return string
* The serialized XML.
*/
public function asXML() {
public function asXml() {
$dc_xml = new DomDocument();
$oai_dc = $dc_xml->createElementNS('http://www.openarchives.org/OAI/2.0/oai_dc/', 'oai_dc:dc');
$oai_dc->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
Expand Down Expand Up @@ -152,7 +152,7 @@ class DublinCore {
* @return DublinCore
* The instantiated object.
*/
public static function importFromXMLString($dc_xml) {
public static function importFromXmlString($dc_xml) {
$dc_doc = new DomDocument();
if (!empty($dc_xml) && $dc_doc->loadXML($dc_xml)) {
$oai_dc = $dc_doc->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', '*');
Expand Down
Loading

0 comments on commit a46936c

Please sign in to comment.