Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
islandora-module-ci:
uses: digitalutsc/reusable_workflows/.github/workflows/islandora-module-ci.yml@main
with:
module_name: islandora_iiif
install_chromedriver: false
38 changes: 25 additions & 13 deletions src/Plugin/views/style/IIIFManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ protected function getTileSourceFromRow(ResultRow $row, $iiif_address, $iiif_bas
if (isset($entity->{$viewsField->definition['field_name']})) {
/** @var \Drupal\Core\Field\FieldItemListInterface $images */
$images = $entity->{$viewsField->definition['field_name']};
// phpcs:ignore -- Unused variable $i.
foreach ($images as $i => $image) {
if (!$image->entity->access('view')) {
// If the user does not have permission to view the file, skip it.
Expand Down Expand Up @@ -344,7 +345,7 @@ protected function getTileSourceFromRow(ResultRow $row, $iiif_address, $iiif_bas
],
];

$node_id = null;
$node_id = NULL;
if (preg_match('/\/node\/(\d+)/', $iiif_base_id, $matches)) {
$node_id = $matches[1];
}
Expand Down Expand Up @@ -400,9 +401,9 @@ protected function getCanvasDimensions(string $iiif_url, FieldItemInterface $ima
$jwtService = \Drupal::service('jwt.authentication.jwt');
$token = $jwtService->generateToken();
$info_json = $this->httpClient->get($iiif_url, [
'headers' => [
'Authorization' => 'Bearer ' . $token
]
'headers' => [
'Authorization' => 'Bearer ' . $token,
],
])->getBody();
}
else {
Expand All @@ -418,8 +419,8 @@ protected function getCanvasDimensions(string $iiif_url, FieldItemInterface $ima
if (empty($width) || empty($height)) {
// Get the image properties so we know the image width/height.
$properties = $image->getProperties();
$width = isset($properties['width']) ? $properties['width'] : 0;
$height = isset($properties['height']) ? $properties['height'] : 0;
$width = $properties['width'] ?? 0;
$height = $properties['height'] ?? 0;

// If this is a TIFF AND we don't know the width/height
// see if we can get the image size via PHP's core function.
Expand Down Expand Up @@ -466,12 +467,13 @@ protected function getOcrUrl(EntityInterface $entity, int $id) {
}
elseif ($structured_text_term = $this->getStructuredTextTerm()) {
$parent_node = $this->getParentNode($entity, $id);

// For items without parent node, return their id as the parent node
// This is the case for images with ocr, have not tested this case fully though!
if ($parent_node == NULL) {
// This is the case for images with ocr,
// Have not tested this case fully though!
if ($parent_node == NULL) {
return $parent_node;
}
}
$ocr_entity_array = Utils::getMediaReferencingNodeAndTerm($parent_node, $structured_text_term);
$ocr_entity_id = is_array($ocr_entity_array) ? array_shift($ocr_entity_array) : NULL;
$ocr_entity = $ocr_entity_id ? $this->entityTypeManager->getStorage('media')->load($ocr_entity_id) : NULL;
Expand All @@ -489,10 +491,14 @@ protected function getOcrUrl(EntityInterface $entity, int $id) {
/**
* Gets nodes that a media belongs to.
*
* // phpcs:ignore -- Doc comment for parameter $media does not match actual variable name $id
* @param \Drupal\media\MediaInterface $media
* The Media whose node you are searching for.
* @param int $id
* The ID of the book node.
* // phpcs:ignore -- Doc comment for parameter $entity does not match actual variable name <undefined>
* @param EntityInterface $entity
* The entity.
*
* @return \Drupal\node\NodeInterface
* Parent node.
Expand Down Expand Up @@ -520,7 +526,7 @@ protected function getParentNode(EntityInterface $entity, int $id) {
}
return NULL;
}

/**
* Pull a title from the node or media passed to this view.
*
Expand Down Expand Up @@ -578,11 +584,12 @@ protected function addSearchEndpoint(array &$json, array $url_components) {

$hocr_search_url = str_replace('%node', $url_components[1], $hocr_search_url);
$hocr_search_url = str_replace('http://', 'https://', $hocr_search_url);

$json['service'][] = [
"@context" => "http://iiif.io/api/search/0/context.json",
"@id" => $hocr_search_url,
"profile" => "http://iiif.io/api/search/0/search",
// phpcs:ignore -- t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
"label" => t("Search inside this work"),
];
}
Expand Down Expand Up @@ -687,7 +694,12 @@ public function getFormats() {
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state object.
*/
// @codingStandardsIgnoreStart

/**
* Submit handler for options form.
*
* @codingStandardsIgnoreStart
*/
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
// @codingStandardsIgnoreEnd
$style_options = $form_state->getValue('style_options');
Expand Down