Allow in-collection searching
This commit is contained in:
parent
f93017f97f
commit
5a3bba810e
|
@ -250,16 +250,16 @@ class tx_dlf_solr {
|
|||
public function search($query = '*') {
|
||||
|
||||
// Sanitize query string.
|
||||
$query = (string) $query;
|
||||
$queryString = (string) $query;
|
||||
|
||||
if (empty($query)) {
|
||||
if (empty($queryString)) {
|
||||
|
||||
$query = '*';
|
||||
$queryString = '*';
|
||||
|
||||
}
|
||||
|
||||
// Perform search.
|
||||
$results = $this->service->search($query, 0, $this->limit, $this->params);
|
||||
$results = $this->service->search($queryString, 0, $this->limit, $this->params);
|
||||
|
||||
$this->numberOfHits = count($results->response->docs);
|
||||
|
||||
|
|
|
@ -354,6 +354,15 @@ class tx_dlf_search extends tx_dlf_plugin {
|
|||
|
||||
}
|
||||
|
||||
// Build label for result list.
|
||||
$label = $this->pi_getLL('search', '', TRUE);
|
||||
|
||||
if (!empty($this->piVars['query'])) {
|
||||
|
||||
$label .= htmlspecialchars(printf($this->pi_getLL('for', ''), $this->piVars['query']));
|
||||
|
||||
}
|
||||
|
||||
// Set search parameters.
|
||||
$solr->limit = max(intval($this->conf['limit']), 1);
|
||||
|
||||
|
@ -370,9 +379,30 @@ class tx_dlf_search extends tx_dlf_plugin {
|
|||
}
|
||||
|
||||
// Add filter query for in-document searching.
|
||||
if ($this->conf['docSearch'] && !empty($this->piVars['id']) && t3lib_div::testInt($this->piVars['id'])) {
|
||||
if ($this->conf['searchIn'] == 'document' || $this->conf['searchIn'] == 'all') {
|
||||
|
||||
$params['fq'][] = 'uid:'.$this->piVars['id'].' OR partof:'.$this->piVars['id'];
|
||||
if (!empty($this->piVars['id']) && t3lib_div::testInt($this->piVars['id'])) {
|
||||
|
||||
$params['fq'][] = 'uid:'.$this->piVars['id'].' OR partof:'.$this->piVars['id'];
|
||||
|
||||
$label .= htmlspecialchars(printf($this->pi_getLL('in', ''), tx_dlf_document::getTitle($this->piVars['id'])));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add filter query for in-collection searching.
|
||||
if ($this->conf['searchIn'] == 'collection' || $this->conf['searchIn'] == 'all') {
|
||||
|
||||
$list = t3lib_div::makeInstance('tx_dlf_list');
|
||||
|
||||
if (!empty($list->metadata['options']['source']) && $list->metadata['options']['source'] == 'collection') {
|
||||
|
||||
$params['fq'][] = $list->metadata['options']['params']['fq'][0];
|
||||
|
||||
$label .= printf($this->pi_getLL('in', '', TRUE), $list->metadata['label']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -382,7 +412,7 @@ class tx_dlf_search extends tx_dlf_plugin {
|
|||
$results = $solr->search($this->piVars['query']);
|
||||
|
||||
$results->metadata = array (
|
||||
'label' => htmlspecialchars(sprintf($this->pi_getLL('searchfor', ''), $this->piVars['query'])),
|
||||
'label' => $label,
|
||||
'description' => '<p class="tx-dlf-search-numHits">'.htmlspecialchars(sprintf($this->pi_getLL('hits', ''), $solr->numberOfHits, $results->count)).'</p>',
|
||||
'options' => $results->metadata['options']
|
||||
);
|
||||
|
|
|
@ -54,16 +54,36 @@
|
|||
</config>
|
||||
</TCEforms>
|
||||
</limit>
|
||||
<docSearch>
|
||||
<searchIn>
|
||||
<TCEforms>
|
||||
<exclude>1</exclude>
|
||||
<label>LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.docSearch</label>
|
||||
<label>LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.searchIn</label>
|
||||
<config>
|
||||
<type>check</type>
|
||||
<default>0</default>
|
||||
<type>select</type>
|
||||
<items type="array">
|
||||
<numIndex index="0" type="array">
|
||||
<numIndex index="0">LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.searchIn.none</numIndex>
|
||||
<numIndex index="1">none</numIndex>
|
||||
</numIndex>
|
||||
<numIndex index="1" type="array">
|
||||
<numIndex index="0">LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.searchIn.document</numIndex>
|
||||
<numIndex index="1">document</numIndex>
|
||||
</numIndex>
|
||||
<numIndex index="2" type="array">
|
||||
<numIndex index="0">LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.searchIn.collection</numIndex>
|
||||
<numIndex index="1">collection</numIndex>
|
||||
</numIndex>
|
||||
<numIndex index="3" type="array">
|
||||
<numIndex index="0">LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.searchIn.all</numIndex>
|
||||
<numIndex index="1">all</numIndex>
|
||||
</numIndex>
|
||||
</items>
|
||||
<size>1</size>
|
||||
<maxitems>1</maxitems>
|
||||
<minitems>0</minitems>
|
||||
</config>
|
||||
</TCEforms>
|
||||
</docSearch>
|
||||
</searchIn>
|
||||
<facets>
|
||||
<TCEforms>
|
||||
<displayCond>FIELD:pages:REQ:true</displayCond>
|
||||
|
|
|
@ -9,7 +9,11 @@
|
|||
<label index="tt_content.pi_flexform.sheet_general">Options</label>
|
||||
<label index="tt_content.pi_flexform.solrcore">Solr Core</label>
|
||||
<label index="tt_content.pi_flexform.limit">Maximum results</label>
|
||||
<label index="tt_content.pi_flexform.docSearch">Allow in-document searching?</label>
|
||||
<label index="tt_content.pi_flexform.searchIn">Allow searching in current document or collection?</label>
|
||||
<label index="tt_content.pi_flexform.searchIn.none">none</label>
|
||||
<label index="tt_content.pi_flexform.searchIn.document">document only</label>
|
||||
<label index="tt_content.pi_flexform.searchIn.collection">collection only</label>
|
||||
<label index="tt_content.pi_flexform.searchIn.all">both</label>
|
||||
<label index="tt_content.pi_flexform.facets">Show these facets</label>
|
||||
<label index="tt_content.pi_flexform.limitFacets">Maximum facet values</label>
|
||||
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: List View" plugin)</label>
|
||||
|
@ -17,14 +21,20 @@
|
|||
<label index="tt_content.pi_flexform.templateFile">Template file</label>
|
||||
<label index="label.query">Search for:</label>
|
||||
<label index="label.submit">Search</label>
|
||||
<label index="searchfor">Search for: "%s"</label>
|
||||
<label index="search">Search</label>
|
||||
<label index="for"> for "%s"</label>
|
||||
<label index="in"> in "%s"</label>
|
||||
<label index="hits">%d hits found in %d documents.</label>
|
||||
</languageKey>
|
||||
<languageKey index="de" type="array">
|
||||
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
|
||||
<label index="tt_content.pi_flexform.solrcore">Solr Kern</label>
|
||||
<label index="tt_content.pi_flexform.limit">Maximale Ergebnismenge</label>
|
||||
<label index="tt_content.pi_flexform.docSearch">Erlaube Suche im Dokument?</label>
|
||||
<label index="tt_content.pi_flexform.searchIn">Erlaube Suche in aktuellem Dokument oder Kollektion?</label>
|
||||
<label index="tt_content.pi_flexform.searchIn.none">nein</label>
|
||||
<label index="tt_content.pi_flexform.searchIn.document">nur Dokument</label>
|
||||
<label index="tt_content.pi_flexform.searchIn.collection">nur Kollektion</label>
|
||||
<label index="tt_content.pi_flexform.searchIn.all">beides</label>
|
||||
<label index="tt_content.pi_flexform.facets">Diese Facetten anzeigen</label>
|
||||
<label index="tt_content.pi_flexform.limitFacets">Maximale Facettenwerte</label>
|
||||
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Listenansicht")</label>
|
||||
|
@ -32,7 +42,9 @@
|
|||
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
|
||||
<label index="label.query">Suchen nach:</label>
|
||||
<label index="label.submit">Suchen</label>
|
||||
<label index="searchfor">Suche nach: "%s"</label>
|
||||
<label index="search">Suche</label>
|
||||
<label index="for"> nach "%s"</label>
|
||||
<label index="in"> in "%s"</label>
|
||||
<label index="hits">Die Suche ergab %d Treffer in %d Dokumenten.</label>
|
||||
</languageKey>
|
||||
</data>
|
||||
|
|
Loading…
Reference in New Issue