Skip to content

Commit

Permalink
[BUGFIX] Fix SearchInDocument middleware (kitodo#1248)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
beatrycze-volk and sebastian-meyer authored Jul 9, 2024
1 parent e58ad14 commit 371076f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Classes/Common/Solr/SearchResult/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Region
public function __construct(int $id, array $region)
{
$this->id = $id;
$this->pageId = $region['pageIdx'];
$this->pageId = $region['pageIdx'] ?? null;
$this->xBeginPosition = $region['ulx'];
$this->xEndPosition = $region['lrx'];
$this->yBeginPosition = $region['uly'];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Common/Solr/SearchResult/ResultDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function __construct(Document $record, array $highlighting, array $fields
$this->page = $record[$fields['page']];
$this->thumbnail = $record[$fields['thumbnail']];
$this->title = $record[$fields['title']];
$this->toplevel = $record[$fields['toplevel']];
$this->toplevel = $record[$fields['toplevel']] ?? false;
$this->type = $record[$fields['type']];

if (!empty($highlighting[$this->id])) {
Expand Down
20 changes: 10 additions & 10 deletions Classes/Controller/ToolboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,17 @@ private function renderSearchInDocumentTool(): void
return;
}

// Fill markers.
$viewArray = [
'LABEL_QUERY_URL' => $this->settings['queryInputName'],
'LABEL_START' => $this->settings['startInputName'],
'LABEL_ID' => $this->settings['idInputName'],
'LABEL_PID' => $this->settings['pidInputName'],
'LABEL_PAGE_URL' => $this->settings['pageInputName'],
'LABEL_HIGHLIGHT_WORD' => $this->settings['highlightWordInputName'],
'LABEL_ENCRYPTED' => $this->settings['encryptedInputName'],
'CURRENT_DOCUMENT' => $this->getCurrentDocumentId(),
'SOLR_ENCRYPTED' => $this->getEncryptedCoreName() ? : ''
'labelQueryUrl' => $this->settings['queryInputName'],
'labelStart' => $this->settings['startInputName'],
'labelId' => $this->settings['idInputName'],
'labelPid' => $this->settings['pidInputName'],
'labelPageUrl' => $this->settings['pageInputName'],
'labelHighlightWord' => $this->settings['highlightWordInputName'],
'labelEncrypted' => $this->settings['encryptedInputName'],
'documentId' => $this->getCurrentDocumentId(),
'documentPageId' => $this->document->getPid(),
'solrEncrypted' => $this->getEncryptedCoreName() ? : ''
];

$this->view->assign('searchInDocument', $viewArray);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Middleware/SearchInDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
{
$response = $handler->handle($request);
// Get input parameters and decrypt core name.
$parameters = $request->getQueryParams();
$parameters = $request->getParsedBody();
// Return if not this middleware
if (!isset($parameters['middleware']) || ($parameters['middleware'] != 'dlf/search-in-document')) {
return $response;
Expand Down
14 changes: 7 additions & 7 deletions Resources/Private/Templates/Toolbox/Main.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@
<f:translate key="search.query"/>
</label>
<!-- Never change the @id of this input field! Otherwise search won't work! -->
<input type="text" id="tx-dlf-search-in-document-query" placeholder="{f:translate(key: 'tools.searchindocument.searchInDocument')}" name="{LABEL_QUERY_URL}" />
<input type="text" id="tx-dlf-search-in-document-query" placeholder="{f:translate(key: 'tools.searchindocument.searchInDocument')}" name="{searchInDocument.labelQueryUrl}" />
<input type="submit" id="tx-dlf-search-in-document-button" value="{f:translate(key: 'search.submit')}" onclick="resetStart();" />
<input type="hidden" id="tx-dlf-search-in-document-start" name="{searchInDocument.LABEL_START}" value="0" />
<input type="hidden" id="tx-dlf-search-in-document-id" name="{searchInDocument.LABEL_ID}" value="{searchInDocument.CURRENT_DOCUMENT}" />
<input type="hidden" id="tx-dlf-search-in-document-pid" name="{searchInDocument.LABEL_PID}" value="{viewData.pageUid}" />
<input type="hidden" id="tx-dlf-search-in-document-page" name="{searchInDocument.LABEL_PAGE_URL}" />
<input type="hidden" id="tx-dlf-search-in-document-highlight-word" name="{searchInDocument.LABEL_HIGHLIGHT_WORD}" />
<input type="hidden" id="tx-dlf-search-in-document-encrypted" name="{searchInDocument.LABEL_ENCRYPTED}" value="{searchInDocument.SOLR_ENCRYPTED}" />
<input type="hidden" id="tx-dlf-search-in-document-start" name="{searchInDocument.labelStart}" value="0" />
<input type="hidden" id="tx-dlf-search-in-document-id" name="{searchInDocument.labelId}" value="{searchInDocument.documentId}" />
<input type="hidden" id="tx-dlf-search-in-document-pid" name="{searchInDocument.labelPid}" value="{searchInDocument.documentPageId}" />
<input type="hidden" id="tx-dlf-search-in-document-page" name="{searchInDocument.labelPageUrl}" />
<input type="hidden" id="tx-dlf-search-in-document-highlight-word" name="{searchInDocument.labelHighlightWord}" />
<input type="hidden" id="tx-dlf-search-in-document-encrypted" name="{searchInDocument.labelEncrypted}" value="{searchInDocument.solrEncrypted}" />
</div>
</form>
<div id="tx-dlf-search-in-document-loading" style="display: none;"><f:translate key="tools.searchindocument.loading"/>...</div>
Expand Down

0 comments on commit 371076f

Please sign in to comment.