Skip to content

Commit

Permalink
Redirect ID Links
Browse files Browse the repository at this point in the history
  • Loading branch information
cradeck committed Jul 26, 2023
1 parent 3331161 commit e1e6697
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
59 changes: 59 additions & 0 deletions Classes/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ public function indexAction()
{
if (array_key_exists('id', $this->requestArguments)) {
$this->forward('detail');
} elseif (array_key_exists('rsn', $this->requestArguments)) {
$this->forward('redirect');
} elseif (array_key_exists('bc', $this->requestArguments)) {
$this->forward('redirect');
} elseif (array_key_exists('ppn', $this->requestArguments)) {
$this->forward('redirect');
} elseif (array_key_exists('oclc', $this->requestArguments)) {
$this->forward('redirect');
} else {
$this->searchProvider->setCounter();
FrontendUtility::addQueryInformationAsJavaScript(
Expand Down Expand Up @@ -132,6 +140,57 @@ public function indexAction()
}
}

/**
* Redirect View to detail action.
*/
public function redirectAction() {
$queryArguments = ['q' => []];
$queryArgumentsDefault = '';

if (array_key_exists('rsn', $this->requestArguments)) {
$queryArguments['q']['rsn'] = $this->requestArguments['rsn'];
$queryArgumentsDefault = $this->requestArguments['rsn'];
} elseif (array_key_exists('bc', $this->requestArguments)) {
$queryArguments['q']['barcode'] = $this->requestArguments['bc'];
$queryArgumentsDefault = $this->requestArguments['bc'];
} elseif (array_key_exists('ppn', $this->requestArguments)) {
$queryArguments['q']['ppn'] = $this->requestArguments['ppn'];
$queryArgumentsDefault = $this->requestArguments['ppn'];
} elseif (array_key_exists('oclc', $this->requestArguments)) {
$queryArguments['q']['oclc'] = $this->requestArguments['oclc'];
$queryArgumentsDefault = $this->requestArguments['oclc'];
}

$selectResults =$this->searchProvider->search($queryArguments);

if (count($selectResults) === 1) {
$resultSet = $selectResults->getDocuments();

$arguments = [
'tx_find_find' => [
'action' => 'detail',
'controller' => 'Search',
'id' => $resultSet[0]['id']
]
];
} else {
$arguments = [
'tx_find_find' => [
'action' => 'index',
'controller' => 'Search',
'q' => [
'default' => $queryArgumentsDefault
]
]
];
}

$uri = $this->uriBuilder->reset()->setTargetPageUid(intval($GLOBALS['TSFE']->id))->setCreateAbsoluteUri(true)->setArguments($arguments)->build();
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($uri);

die();
}

/**
* Initialisation and setup.
*/
Expand Down
7 changes: 6 additions & 1 deletion Classes/Service/SolrServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,12 @@ public function isExtendedSearch()
*/
public function search($query)
{
// TODO: Implement search() method.
$this->createQueryForArguments($query);

/** @var Result $selectResults */
$selectResults = $this->connection->select($this->query);

return $selectResults;
}

/**
Expand Down

0 comments on commit e1e6697

Please sign in to comment.