Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2100 remove override facets js #870

Closed
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
16 changes: 0 additions & 16 deletions modules/islandora_advanced_search/islandora_advanced_search.module
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,6 @@ function islandora_advanced_search_theme() {
];
}

/**
* Implements hook_library_info_alter().
*/
function islandora_advanced_search_library_info_alter(&$libraries, $extension) {
if ($extension == 'facets') {
// Override facets module javascript with customizations.
$path = '/' . drupal_get_path('module', 'islandora_advanced_search') . '/js/facets';
$libraries['soft-limit']['js'] = [
"$path/soft-limit.js" => [],
];
$libraries['drupal.facets.views-ajax']['js'] = [
"$path/facets-views-ajax.js" => [],
];
}
}

/**
* Implements hook_search_api_solr_converted_query_alter().
*/
Expand Down
147 changes: 0 additions & 147 deletions modules/islandora_advanced_search/js/facets/facets-views-ajax.js

This file was deleted.

70 changes: 0 additions & 70 deletions modules/islandora_advanced_search/js/facets/soft-limit.js

This file was deleted.

29 changes: 23 additions & 6 deletions modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\islandora_iiif\Plugin\views\style;

use Drupal\Core\Entity\EntityManager;
use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
Expand Down Expand Up @@ -85,7 +86,7 @@ class IIIFManifest extends StylePluginBase {
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, FileSystemInterface $file_system, Client $http_client, MessengerInterface $messenger) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, FileSystemInterface $file_system, Client $http_client, MessengerInterface $messenger, \Drupal\islandora\IslandoraUtils $utils) {
parent::__construct($configuration, $plugin_id, $plugin_definition);

$this->serializer = $serializer;
Expand All @@ -94,6 +95,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
$this->fileSystem = $file_system;
$this->httpClient = $http_client;
$this->messenger = $messenger;
$this->utils = $utils;
}

/**
Expand All @@ -109,7 +111,8 @@ public static function create(ContainerInterface $container, array $configuratio
$container->get('config.factory')->get('islandora_iiif.settings'),
$container->get('file_system'),
$container->get('http_client'),
$container->get('messenger')
$container->get('messenger'),
$container->get('islandora.utils')
);
}

Expand Down Expand Up @@ -151,6 +154,18 @@ public function render() {
$json['sequences'][0]['canvases'][] = $tile_source;
}
}
if (count($this->view->result) < 1) {
$pathinfo = $this->request->getPathInfo();
$node_id_str = str_replace(['/node/', '/manifest'], '', $pathinfo);
if ($node_id_str) {
$node = \Drupal::entityTypeManager()->getStorage('node')->load($node_id_str);
// Get the node's media that is a "Service File" since that is what
// the view is restricted to.
$service_file_term = array_pop(\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['field_external_uri' => 'http://pcdm.org/use#ServiceFile', 'vid' => 'islandora_media_use']));
$node_media = $this->utils->getMediaWithTerm($node, $service_file_term);
$json['sequences'][0]['canvases'][] = $this->getTileSourceFromRow(NULL, $iiif_address, $iiif_base_id, $node_media);
}
}
}
unset($this->view->row_index);

Expand All @@ -162,22 +177,24 @@ public function render() {
/**
* Render array from views result row.
*
* @param \Drupal\views\ResultRow $row
* Result row.
* @param MIXED $row
* Result row \Drupal\views\ResultRow usually coming from the view - or can be NULL when overridden.
* @param string $iiif_address
* The URL to the IIIF server endpoint.
* @param string $iiif_base_id
* The URL for the request, minus the last part of the URL,
* which is likely "manifest".
* @param object $override_media
* The "result's" media when not coming from the view results.
*
* @return array
* List of IIIF URLs to display in the Openseadragon viewer.
*/
protected function getTileSourceFromRow(ResultRow $row, $iiif_address, $iiif_base_id) {
protected function getTileSourceFromRow($row, $iiif_address, $iiif_base_id, $override_media = NULL) {
$canvases = [];
foreach ($this->options['iiif_tile_field'] as $iiif_tile_field) {
$viewsField = $this->view->field[$iiif_tile_field];
$entity = $viewsField->getEntity($row);
$entity = is_null($override_media) ? $viewsField->getEntity($row) : $override_media;

if (isset($entity->{$viewsField->definition['field_name']})) {

Expand Down