diff --git a/classes/ezfmodulefunctioncollection.php b/classes/ezfmodulefunctioncollection.php index be308534..afe127af 100644 --- a/classes/ezfmodulefunctioncollection.php +++ b/classes/ezfmodulefunctioncollection.php @@ -82,7 +82,7 @@ public function getFilterParameters() public function search( $query, $offset = 0, $limit = 10, $facets = null, $filters = null, $sortBy = null, $classID = null, $sectionID = null, $subtreeArray = null, $ignoreVisibility = null, $limitation = null, $asObjects = true, $spellCheck = null, $boostFunctions = null, $queryHandler = 'ezpublish', - $enableElevation = true, $forceElevation = false, $publishDate = null, $distributedSearch = null, $fieldsToReturn = null, $searchResultClustering = null, $extendedAttributeFilter = array() ) + $enableElevation = true, $forceElevation = false, $publishDate = null, $distributedSearch = null, $fieldsToReturn = null, $searchResultClustering = null, $extendedAttributeFilter = array(), $pluginParameters = array() ) { $solrSearch = new eZSolr(); $params = array( 'SearchOffset' => $offset, @@ -105,7 +105,9 @@ public function search( $query, $offset = 0, $limit = 10, $facets = null, 'DistributedSearch' => $distributedSearch, 'FieldsToReturn' => $fieldsToReturn, 'SearchResultClustering' => $searchResultClustering, - 'ExtendedAttributeFilter' => $extendedAttributeFilter ); + 'ExtendedAttributeFilter' => $extendedAttributeFilter, + 'PluginParameters' => $pluginParameters, + ); return array( 'result' => $solrSearch->search( $query, $params ) ); } diff --git a/classes/queryplugins/ezfquerysearchplugin.php b/classes/queryplugins/ezfquerysearchplugin.php new file mode 100644 index 00000000..1395b70a --- /dev/null +++ b/classes/queryplugins/ezfquerysearchplugin.php @@ -0,0 +1,26 @@ + diff --git a/classes/queryplugins/ezftestqueryplugin.php b/classes/queryplugins/ezftestqueryplugin.php new file mode 100644 index 00000000..df464eac --- /dev/null +++ b/classes/queryplugins/ezftestqueryplugin.php @@ -0,0 +1,39 @@ + 'extended_attribute_filter', 'type' => 'array', 'required' => false, - 'default' => array() )) ); + 'default' => array() ), + array ( 'name' => 'plugin_parameters', + 'type' => 'array', + 'required' => false, + 'default' => array() ) )); $FunctionList['getDefaultSearchFacets'] = array( 'name' => 'getDefaultSearchFacets', diff --git a/search/plugins/ezsolr/ezsolr.php b/search/plugins/ezsolr/ezsolr.php index 19c2ae31..3b84da11 100644 --- a/search/plugins/ezsolr/ezsolr.php +++ b/search/plugins/ezsolr/ezsolr.php @@ -1021,6 +1021,33 @@ function search( $searchText, $params = array(), $searchTypes = array() ) eZDebug::createAccumulator( 'Engine time', 'eZ Find' ); eZDebug::accumulatorStart( 'Engine time' ); + + // Since 2015-04-12 PBo : query time plugins + $generalSearchPlugins = $this->FindINI->variable('QueryPlugins', 'Search'); + if (!empty($generalSearchPlugins)) + { + $pluginParameters = isset( $params['PluginParameters'] ) ? $params['PluginParameters'] : array(); + foreach ($generalSearchPlugins as $pluginClassString) + { + if (!class_exists($pluginClassString)) + { + eZDebug::writeError("Unable to find the PHP class '$pluginClassString' defined for query time plugins for eZ Find", __METHOD__); + continue; + } + $plugin = new $pluginClassString; + if ($plugin instanceof ezfQuerySearchPlugin) + { + $plugin->modify( $queryParams, $pluginParameters ); + eZDebugSetting::writeDebug( 'extension-ezfind-query', $queryParams, 'Query plugin modified parameters sent to Solr backend' ); + } + else + { + eZDebug::writeError("Provided plugin '$pluginClassString' is not of the correct type: ezfQuerySearchPlugin", __METHOD__); + continue; + } + } + } + $resultArray = $coreToUse->rawSearch( $queryParams ); eZDebug::accumulatorStop( 'Engine time' ); } @@ -1380,7 +1407,7 @@ static function engineText() $extensionInfo = ezpExtension::getInstance( 'ezfind' )->getInfo(); return ezpI18n::tr( 'ezfind', - 'eZ Find %version search plugin © 1999-2014 eZ Systems AS, powered by Apache Solr 4.7.0', + 'eZ Find %version search plugin © 1999-2014 eZ Systems AS, powered by Apache Solr 4.10.1', null, array( '%version' => $extensionInfo['version'] ) ); diff --git a/settings/ezfind.ini b/settings/ezfind.ini index 8ef3cb06..7bfda0b5 100644 --- a/settings/ezfind.ini +++ b/settings/ezfind.ini @@ -330,4 +330,8 @@ FiltersList[geodist]=eZFindGeoDistExtendedAttributeFilter [QueryBoost] RawBoostQueries[] -#RawBoostQueries[]=meta_class_identifier_ms:folder^10 \ No newline at end of file +#RawBoostQueries[]=meta_class_identifier_ms:folder^10 + +[QueryPlugins] +Search[] +//Search[]=ezfTestQueryPlugin