diff --git a/languages/en.php b/languages/en.php index d132c2a..cafc310 100644 --- a/languages/en.php +++ b/languages/en.php @@ -133,6 +133,8 @@ 'opensearch:inspect:result:last_indexed:time' => "This entity was last indexed: %s", 'opensearch:inspect:result:reindex' => "Schedule for reindexing", 'opensearch:inspect:result:delete' => "Remove entity from index", + 'opensearch:inspect:result:not_found:elgg' => "The entity could not be found in Elgg and the OpenSearch index", + 'opensearch:inspect:result:not_found:index' => "The entity could not be found in Elgg, but still exists in the OpenSearch index", // forms 'opensearch:forms:admin_search:query:placeholder' => "Enter your search query here", diff --git a/languages/nl.php b/languages/nl.php index 582de7f..18fb660 100644 --- a/languages/nl.php +++ b/languages/nl.php @@ -1,10 +1,12 @@ 'De entiteit kon niet worden gevonden in Elgg en de OpenSearch index', + 'opensearch:inspect:result:not_found:index' => 'De entiteit kon niet worden gevonden in Elgg, maar bestaat nog wel in de OpenSearch index', 'opensearch:upgrade:2022061500:title' => 'Voeg aliassen toe aan de OpenSearch index', 'opensearch:upgrade:2022061500:description' => 'Wegens een aanpassing in de werking van de plugin moet de OpenSearch index een aantal extra aliassen krijgen. Deze upgrade zal deze toevoegen aan de index.', 'opensearch:cli:rebuild:description' => 'Herbouw de index met een nieuwe configuratie en/of mappings', diff --git a/views/default/admin/opensearch/inspect.php b/views/default/admin/opensearch/inspect.php index 0e8ad36..0194108 100644 --- a/views/default/admin/opensearch/inspect.php +++ b/views/default/admin/opensearch/inspect.php @@ -19,17 +19,36 @@ return; } +$service = SearchService::instance(); $registered_types = opensearch_get_registered_entity_types(); $entity = elgg_call(ELGG_SHOW_DELETED_ENTITIES, function() use ($guid) { return get_entity($guid); }); +$opensearch_content = $service->inspect($guid); + if (!$entity instanceof \ElggEntity) { // Entity doesn't exist in Elgg or was trashed - $result = elgg_view('output/longtext', [ - 'value' => elgg_echo('notfound'), - ]); + if (!empty($opensearch_content)) { + // entity still exists in OpenSearch index add button to delete entity from index + $result = elgg_view('output/longtext', [ + 'value' => elgg_echo('opensearch:inspect:result:not_found:index'), + ]); + + $result .= elgg_view('output/url', [ + 'icon' => 'delete', + 'text' => elgg_echo('opensearch:inspect:result:delete'), + 'href' => elgg_generate_action_url('opensearch/admin/delete_entity', [ + 'guid' => $entity->guid, + ]), + 'class' => 'elgg-button elgg-button-action', + ]); + } else { + $result = elgg_view('output/longtext', [ + 'value' => elgg_echo('opensearch:inspect:result:not_found:elgg'), + ]); + } } elseif (!array_key_exists($entity->getType(), $registered_types) || (array_key_exists($entity->getType(), $registered_types) && !empty($entity->getSubtype()) && !in_array($entity->getSubtype(), $registered_types[$entity->getType()]))) { // entity won't be exported to ES $result = elgg_view('output/longtext', [ @@ -64,9 +83,6 @@ ]); } - $service = SearchService::instance(); - - $opensearch_content = $service->inspect($guid); if (empty($opensearch_content)) { $result = elgg_view('output/longtext', [ 'value' => elgg_echo('opensearch:inspect:result:error:not_indexed'),