$dependency !== 'islandora_mirador/mirador' )); if (!in_array('islandora_mirador_annotations/annotated_mirador', $libraries['viewer']['dependencies'], TRUE)) { $libraries['viewer']['dependencies'][] = 'islandora_mirador_annotations/annotated_mirador'; } } /** * Implements hook_js_settings_alter(). */ function islandora_mirador_annotations_js_settings_alter(array &$settings, AttachedAssetsInterface $assets) { if (empty($settings['mirador']['viewers']) || !is_array($settings['mirador']['viewers'])) { return; } $account = \Drupal::currentUser(); if (!$account->hasPermission('view mirador annotations')) { return; } $endpoint = Url::fromRoute('islandora_mirador_annotations.collection', [], ['absolute' => TRUE])->toString(); $can_manage = $account->hasPermission('manage mirador annotations'); $all_endpoint = Url::fromRoute('islandora_mirador_annotations.manifest_collection', [], ['absolute' => TRUE])->toString(); foreach ($settings['mirador']['viewers'] as &$viewer) { $viewer['annotation'] = [ 'adapter' => 'drupal', 'endpoint' => $endpoint, 'allEndpoint' => $all_endpoint, 'csrfTokenUrl' => Url::fromRoute('system.csrftoken', [], ['absolute' => TRUE])->toString(), 'user' => $account->isAuthenticated() ? $account->getDisplayName() : 'Anonymous', 'readonly' => !$can_manage, 'allowTargetShapesStyling' => TRUE, 'exportLocalStorageAnnotations' => FALSE, ]; $viewer['annotations'] = [ 'htmlSanitizationRuleSet' => 'liberal', ]; $viewer['window'] = $viewer['window'] ?? []; $viewer['window']['defaultSideBarPanel'] = 'annotations'; $viewer['window']['sideBarOpenByDefault'] = TRUE; // Keep Mirador's annotation overlay mounted even when our custom All annotations panel is open. // Core otherwise only draws annotations while the stock annotations companion window is open. $viewer['window']['forceDrawAnnotations'] = TRUE; $viewer['window']['panels'] = $viewer['window']['panels'] ?? []; $viewer['window']['panels']['allAnnotations'] = TRUE; $viewer['translations'] = $viewer['translations'] ?? []; $viewer['translations']['en'] = $viewer['translations']['en'] ?? []; $viewer['translations']['en']['openCompanionWindow_allAnnotations'] = 'All annotations'; } }