Skip to content

Commit

Permalink
Merge pull request Islandora#6 from adam-vessey/8.x-coder-pass
Browse files Browse the repository at this point in the history
Coder pass.
  • Loading branch information
jordandukart authored Jan 3, 2018
2 parents 0946c87 + 3b5b965 commit 4f5a3bc
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 184 deletions.
98 changes: 55 additions & 43 deletions includes/solution_packs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,9 @@ function islandora_viewers_form($variable_id = NULL, $mimetype = NULL, $model =
$viewers = array_merge_recursive($no_viewer, $viewers);
}
// @FIXME
// // @FIXME
// // The correct configuration object could not be determined. You'll need to
// // rewrite this call manually.
// $viewers_config = variable_get($variable_id, array());

// The correct configuration object could not be determined. You'll need to
// rewrite this call manually.
// $viewers_config = variable_get($variable_id, array());
$form['viewers'] = [
'#type' => 'fieldset',
'#title' => t('Viewers'),
Expand Down Expand Up @@ -409,29 +407,31 @@ function islandora_viewers_form($variable_id = NULL, $mimetype = NULL, $model =
'#markup' => $profile['description'],
];
// @FIXME
// l() expects a Url object, created from a route name or external URI.
// $form['viewers'][$variable_id]['configuration'][$name] = array(
// '#type' => 'item',
// '#markup' => (isset($profile['configuration']) AND $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '',
// );

// l() expects a Url object, created from a route name or external URI.
// @codingStandardsIgnoreStart
// $form['viewers'][$variable_id]['configuration'][$name] = [
// '#type' => 'item',
// '#markup' => (isset($profile['configuration']) AND $profile['configuration'] != '') ? l(t('configure'), $profile['configuration']) : '',
// ];
// @codingStandardsIgnoreEnd
}
$form['viewers'][$variable_id]['default'] = [
'#type' => 'radios',
'#options' => isset($options) ? $options : [],
// @codingStandardsIgnoreStart
'#default_value' => !empty($viewers_config) ? $viewers_config['default'] : 'none',
// @codingStandardsIgnoreEnd
];
}
else {
$form['viewers'][$variable_id . '_no_viewers'] = [
'#markup' => t('No viewers detected.'),
];
// @FIXME
// // @FIXME
// // The correct configuration object could not be determined. You'll need to
// // rewrite this call manually.
// variable_del($variable_id);

// @FIXME
// The correct configuration object could not be determined. You'll need to
// rewrite this call manually.
// variable_del($variable_id);
}
return $form;
}
Expand Down Expand Up @@ -482,6 +482,8 @@ function islandora_get_viewers(array $mimetype = [], $content_model = NULL) {
*/
function theme_islandora_viewers_table($variables) {
$form = $variables['form'];
// @codingStandardsIgnoreStart
// XXX Usage is commented out below.
$rows = [];
foreach ($form['name'] as $key => $element) {
if (is_array($element) && \Drupal\Core\Render\Element::child($key)) {
Expand All @@ -493,36 +495,42 @@ function theme_islandora_viewers_table($variables) {
$rows[] = ['data' => $row];
}
}
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreStart
// XXX Usage is commented out below.
$header = [];
$header[] = ['data' => t('Default')];
$header[] = ['data' => t('Label')];
$header[] = ['data' => t('Description')];
$header[] = ['data' => t('Configuration')];

// @codingStandardsIgnoreEnd
$output = '';
// @FIXME
// theme() has been renamed to _theme() and should NEVER be called directly.
// Calling _theme() directly can alter the expected output and potentially
// introduce security issues (see https://www.drupal.org/node/2195739). You
// should use renderable arrays instead.
//
//
// @see https://www.drupal.org/node/2195739
// $output .= theme('table', array(
// 'header' => $header,
// 'rows' => $rows,
// 'attributes' => array('id' => 'islandora-viewers-table'),
// ));

// theme() has been renamed to _theme() and should NEVER be called directly.
// Calling _theme() directly can alter the expected output and potentially
// introduce security issues (see https://www.drupal.org/node/2195739). You
// should use renderable arrays instead.
//
// Remove coding standard annotations above.
//
// @see https://www.drupal.org/node/2195739
// @codingStandardsIgnoreStart
// $output .= theme('table', array(
// 'header' => $header,
// 'rows' => $rows,
// 'attributes' => array('id' => 'islandora-viewers-table'),
// ));
// @codingStandardsIgnoreEnd
$output .= drupal_render_children($form);
return $output;
}

/**
* Gather information and return a rendered viewer.
*
* @param array/string $params
* Array or string with data the module needs in order to render a full viewer.
* @param mixed $params
* Array or string with data the module needs in order to render a full
* viewer.
* @param string $variable_id
* The id of the Drupal variable the viewer settings are saved in.
* @param AbstractObject $fedora_object
Expand All @@ -532,13 +540,14 @@ function theme_islandora_viewers_table($variables) {
* The callback to the viewer module. Returns a rendered viewer. Returns FALSE
* if no viewer is set.
*/
function islandora_get_viewer($params = NULL, $variable_id = NULL, $fedora_object = NULL) {
// @FIXME
// // @FIXME
// // The correct configuration object could not be determined. You'll need to
// // rewrite this call manually.
// $settings = variable_get($variable_id, array());
function islandora_get_viewer($params = NULL, $variable_id = NULL, AbstractObject $fedora_object = NULL) {

// @FIXME
// The correct configuration object could not be determined. You'll need to
// rewrite this call manually.
// $settings = variable_get($variable_id, array());
// @codingStandardsIgnoreStart
// XXX $settings is commented out and thus undefined.
if (!empty($settings) and $settings['default'] !== 'none') {
$viewer_id = islandora_get_viewer_id($variable_id);
if ($viewer_id and $params !== NULL) {
Expand All @@ -548,6 +557,7 @@ function islandora_get_viewer($params = NULL, $variable_id = NULL, $fedora_objec
}
}
}
// @codingStandardsIgnoreEnd
return FALSE;
}

Expand All @@ -561,15 +571,17 @@ function islandora_get_viewer($params = NULL, $variable_id = NULL, $fedora_objec
* The enabled viewer id. Returns FALSE if no viewer config is set.
*/
function islandora_get_viewer_id($variable_id) {
// @FIXME
// // @FIXME
// // The correct configuration object could not be determined. You'll need to
// // rewrite this call manually.
// $viewers_config = variable_get($variable_id, array());

// @FIXME
// The correct configuration object could not be determined. You'll need to
// rewrite this call manually.
// $viewers_config = variable_get($variable_id, array());
// @codingStandardsIgnoreStart
// XXX $viewers_config is undefined, commented out above.
if (!empty($viewers_config)) {
return $viewers_config['default'];
}
// @codingStandardsIgnoreEnd
return FALSE;
}

Expand Down
8 changes: 8 additions & 0 deletions includes/tuque.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ use Drupal\user\Entity\User;

/**
* A class to include the Tuque library.
*
* @codingStandardsIgnoreStart
* XXX: Poorly implemented sniff indicates class should begin with
* "Islandora.info" instead of just "Islandora"... ideally, this should move
* somewhere under the Drupal\islandora\Tuque namespace at somepoint...
* Possibly as a service such that Dependency Injection can happen as
* necessary.
*/
class IslandoraTuque {
// @codingStandardsIgnoreEnd

/**
* Connection to the repository.
Expand Down
30 changes: 15 additions & 15 deletions includes/utilities.inc
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ function islandora_get_datastreams_requirements_from_content_model(AbstractObjec
* @return NewFedoraObject
* An ingestable NewFedoraObject.
*/
function islandora_prepare_new_object($name_source = NULL, $label = NULL, $datastreams = [], $content_models = [], $relationships = []) {
function islandora_prepare_new_object($name_source = NULL, $label = NULL, array $datastreams = [], array $content_models = [], array $relationships = []) {
$user = \Drupal::currentUser();
$tuque = islandora_get_tuque_connection();
$object = isset($name_source) ? $tuque->repository->constructObject($name_source) : new IslandoraNewFedoraObject(NULL, $tuque->repository);
Expand Down Expand Up @@ -529,10 +529,7 @@ function islandora_prepare_new_object($name_source = NULL, $label = NULL, $datas
// Schema does not match available php stream wrapper. Attempt to
// set datastream_file by url for the given scheme. Https (SSL) can
// cause this to fail, and trigger an output log in watchdog.
// @FIXME
// url() expects a route name or an external URI.
// $datastream_file = url($ds['datastream_file'], array('absolute' => TRUE));
\Drupal::logger('islandora')->warning('Attempting to ingest %file in islandora_prepare_new_object(), but it does not appear to be readable. We will pass the path through url(), and pass along as such.', array('%file' => $datastream_file));
throw new Exception('Unsupported operation: Attempted to ingest non-readable file as datastream.');
}
}

Expand Down Expand Up @@ -597,7 +594,7 @@ function islandora_executable_available_message($path, $version = NULL, $require
if ($available) {
$image = [
'#theme' => 'image',
'#uri' =>'/core/misc/icons/73b355/check.svg' ,
'#uri' => '/core/misc/icons/73b355/check.svg',
];
$message = t('Executable found at @path', ['@path' => $path]);
if ($version) {
Expand All @@ -607,7 +604,7 @@ function islandora_executable_available_message($path, $version = NULL, $require
if (version_compare($version, $required_version) < 0) {
$image = [
'#theme' => 'image',
'#uri' =>'/core/misc/icons/e32700/error.svg' ,
'#uri' => '/core/misc/icons/e32700/error.svg',
];
}
$message .= t('<br/>Required Version: @version', ['@version' => $required_version]);
Expand All @@ -616,7 +613,7 @@ function islandora_executable_available_message($path, $version = NULL, $require
else {
$image = [
'#theme' => 'image',
'#uri' =>'/core/misc/icons/e32700/error.svg' ,
'#uri' => '/core/misc/icons/e32700/error.svg',
];
$message = t('Unable to locate executable at @path', ['@path' => $path]);
}
Expand All @@ -637,14 +634,14 @@ function islandora_directory_exists_message($path) {
if ($available) {
$image = [
'#theme' => 'image',
'#uri' =>'/core/misc/icons/73b355/check.svg' ,
'#uri' => '/core/misc/icons/73b355/check.svg',
];
$message = t('Directory found at @path', ['@path' => $path]);
}
else {
$image = [
'#theme' => 'image',
'#uri' =>'/core/misc/icons/e32700/error.svg' ,
'#uri' => '/core/misc/icons/e32700/error.svg',
];
$message = t('Unable to locate directory at @path', ['@path' => $path]);
}
Expand Down Expand Up @@ -766,11 +763,13 @@ function islandora_content_model_select_table_form_element($drupal_variable, arr
}

// @FIXME
// // @FIXME
// // The correct configuration object could not be determined. You'll need to
// // rewrite this call manually.
// $selected = array_values(variable_get($drupal_variable, $default_values_array));

// @FIXME
// The correct configuration object could not be determined. You'll need to
// rewrite this call manually.
// @codingStandardsIgnoreStart
// XXX Commenting out the line below is throwing errors in the code block because $selected
// is undefined.
// $selected = array_values(variable_get($drupal_variable, $default_values_array));
$comparator = function ($a, $b) use ($selected) {
$a_val = $b_val = 0;
if (in_array($a, $selected)) {
Expand All @@ -789,6 +788,7 @@ function islandora_content_model_select_table_form_element($drupal_variable, arr
];
$defaults[$pid] = in_array($pid, $selected);
}
// @codingStandardsIgnoreEnd
$header = [
'pid' => ['data' => t('PID')],
'title' => ['data' => t('Content Model')],
Expand Down
4 changes: 2 additions & 2 deletions islandora.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Islandora
description: 'View and manage Fedora objects'
package: Islandora
dependencies:
- image
- file
- drupal:image
- drupal:file
core: 8.x
php: '5.5.9'
type: module
70 changes: 36 additions & 34 deletions islandora.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,54 @@
use Drupal\islandora\DublinCore;
use Drupal\islandora\Authentication\Provider\IslandoraTokenAuth;

// @codingStandardsIgnoreStart
// Common datastreams.
define('ISLANDORA_DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
const ISLANDORA_DS_COMP_STREAM = 'DS-COMPOSITE-MODEL';

// Permissions.
define('ISLANDORA_VIEW_OBJECTS', 'view fedora repository objects');
define('ISLANDORA_METADATA_EDIT', 'edit fedora metadata');
define('ISLANDORA_ADD_DS', 'add fedora datastreams');
define('ISLANDORA_INGEST', 'ingest fedora objects');
const ISLANDORA_VIEW_OBJECTS = 'view fedora repository objects';
const ISLANDORA_METADATA_EDIT = 'edit fedora metadata';
const ISLANDORA_ADD_DS = 'add fedora datastreams';
const ISLANDORA_INGEST = 'ingest fedora objects';
const ISLANDORA_PURGE = 'delete fedora objects and datastreams';
define('ISLANDORA_MANAGE_PROPERTIES', 'manage object properties');
define('ISLANDORA_VIEW_DATASTREAM_HISTORY', 'view old datastream versions');
define('ISLANDORA_MANAGE_DELETED_OBJECTS', 'manage deleted objects');
define('ISLANDORA_REVERT_DATASTREAM', 'revert to old datastream');
define('ISLANDORA_REGENERATE_DERIVATIVES', 'regenerate derivatives for an object');
define('ISLANDORA_REPLACE_DATASTREAM_CONTENT', 'replace a datastream with new content, preserving version history');
const ISLANDORA_MANAGE_PROPERTIES = 'manage object properties';
const ISLANDORA_VIEW_DATASTREAM_HISTORY = 'view old datastream versions';
const ISLANDORA_MANAGE_DELETED_OBJECTS = 'manage deleted objects';
const ISLANDORA_REVERT_DATASTREAM = 'revert to old datastream';
const ISLANDORA_REGENERATE_DERIVATIVES = 'regenerate derivatives for an object';
const ISLANDORA_REPLACE_DATASTREAM_CONTENT = 'replace a datastream with new content, preserving version history';

// Hooks.
define('ISLANDORA_VIEW_HOOK', 'islandora_view_object');
define('ISLANDORA_PRINT_HOOK', 'islandora_view_print_object');
define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object');
define('ISLANDORA_OVERVIEW_HOOK', 'islandora_overview_object');
define('ISLANDORA_PRE_INGEST_HOOK', 'islandora_ingest_pre_ingest');
define('ISLANDORA_POST_INGEST_HOOK', 'islandora_ingest_post_ingest');
define('ISLANDORA_PRE_PURGE_OBJECT_HOOK', 'islandora_pre_purge_object');
define('ISLANDORA_POST_PURGE_OBJECT_HOOK', 'islandora_post_purge_object');
const ISLANDORA_VIEW_HOOK = 'islandora_view_object';
const ISLANDORA_PRINT_HOOK = 'islandora_view_print_object';
const ISLANDORA_EDIT_HOOK = 'islandora_edit_object';
const ISLANDORA_OVERVIEW_HOOK = 'islandora_overview_object';
const ISLANDORA_PRE_INGEST_HOOK = 'islandora_ingest_pre_ingest';
const ISLANDORA_POST_INGEST_HOOK = 'islandora_ingest_post_ingest';
const ISLANDORA_PRE_PURGE_OBJECT_HOOK = 'islandora_pre_purge_object';
const ISLANDORA_POST_PURGE_OBJECT_HOOK = 'islandora_post_purge_object';
const ISLANDORA_UPDATE_RELATED_OBJECTS_PROPERTIES_HOOK = 'islandora_update_related_objects_properties';
define('ISLANDORA_METADATA_OBJECT_ALTER', 'islandora_metadata_object');
define('ISLANDORA_METADATA_OBJECT_DESCRIPTION_ALTER', 'islandora_metadata_object_description');
define('ISLANDORA_BREADCRUMB_FILTER_PREDICATE_HOOK', 'islandora_get_breadcrumb_query_predicates');
define('ISLANDORA_EDIT_DATASTREAM_REGISTRY_HOOK', 'islandora_edit_datastream_registry');
const ISLANDORA_METADATA_OBJECT_ALTER = 'islandora_metadata_object';
const ISLANDORA_METADATA_OBJECT_DESCRIPTION_ALTER = 'islandora_metadata_object_description';
const ISLANDORA_BREADCRUMB_FILTER_PREDICATE_HOOK = 'islandora_get_breadcrumb_query_predicates';
const ISLANDORA_EDIT_DATASTREAM_REGISTRY_HOOK = 'islandora_edit_datastream_registry';

// @todo Add Documentation.
define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested');
define('ISLANDORA_OBJECT_MODIFIED_HOOK', 'islandora_object_modified');
define('ISLANDORA_OBJECT_PURGED_HOOK', 'islandora_object_purged');
define('ISLANDORA_DATASTREAM_INGESTED_HOOK', 'islandora_datastream_ingested');
define('ISLANDORA_DATASTREAM_MODIFIED_HOOK', 'islandora_datastream_modified');
define('ISLANDORA_DATASTREAM_PURGED_HOOK', 'islandora_datastream_purged');
define('ISLANDORA_INGEST_STEP_HOOK', 'islandora_ingest_steps');
define('ISLANDORA_DERIVATIVE_CREATION_HOOK', 'islandora_derivative');
const ISLANDORA_OBJECT_INGESTED_HOOK = 'islandora_object_ingested';
const ISLANDORA_OBJECT_MODIFIED_HOOK = 'islandora_object_modified';
const ISLANDORA_OBJECT_PURGED_HOOK = 'islandora_object_purged';
const ISLANDORA_DATASTREAM_INGESTED_HOOK = 'islandora_datastream_ingested';
const ISLANDORA_DATASTREAM_MODIFIED_HOOK = 'islandora_datastream_modified';
const ISLANDORA_DATASTREAM_PURGED_HOOK = 'islandora_datastream_purged';
const ISLANDORA_INGEST_STEP_HOOK = 'islandora_ingest_steps';
const ISLANDORA_DERIVATIVE_CREATION_HOOK = 'islandora_derivative';

// Autocomplete paths.
define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models');
define('ISLANDORA_MIME_TYPES_AUTOCOMPLETE', 'islandora/autocomplete/mime-types');
const ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE = 'islandora/autocomplete/content-models';
const ISLANDORA_MIME_TYPES_AUTOCOMPLETE = 'islandora/autocomplete/mime-types';

const ISLANDORA_BREADCRUMB_LEGACY_BACKEND = 'islandora_breadcrumbs_legacy_sparql';
// @codingStandardsIgnoreEnd

/**
* Implements hook_theme().
Expand Down Expand Up @@ -394,7 +396,7 @@ function islandora_default_islandora_printer_object(AbstractObject $object, $alt

try {
$dc = $islandora_object['DC']->content;
$dc_object = DublinCore::importFromXMLString($dc);
$dc_object = DublinCore::importFromXmlString($dc);
}
catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', ['%s' => $islandora_object->id, '%t' => $e->getMessage()]), 'error', FALSE);
Expand Down
Loading

0 comments on commit 4f5a3bc

Please sign in to comment.