/** * Extracts the configuration stored in the DB and turns it into a Solr-compliant XML string. * Stores the result string in the local property $configurationXML * * @see $configurationXML * @return boolean true if the generation run correctly, false otherwise. * */ protected static function generateConfiguration() { $db = eZDB::instance(); $def = self::definition(); $query = "SELECT DISTINCT search_query FROM " . $def['name']; $limit = 50; $offset = 0; $solr = new eZSolr(); $xml = new SimpleXMLElement(self::XML_SKELETON); self::$configurationXML = $xml->asXML(); while (true) { // fetch distinct search queries $rows = $db->arrayQuery($query, array('limit' => $limit, 'offset' => $offset)); if (empty($rows)) { break; } // For each query string, generate the corresponding bloc in elevate.xml // Looks like this : // // <query text="foo bar"> // <doc id="1" /> // <doc id="2" /> // <doc id="3" /> // </query> $xml = new SimpleXMLElement(self::$configurationXML); foreach ($rows as $row) { $searchQuery = $xml->addChild('query'); $searchQuery->addAttribute('text', $row['search_query']); $results = self::fetchObjectsForQueryString($row['search_query']); foreach ($results as $languageCode => $objects) { foreach ($objects as $object) { if ($languageCode === self::WILDCARD) { $currentVersion = $object->currentVersion(); foreach ($currentVersion->translationList(false, false) as $lang) { $guid = $solr->guid($object, $lang); $doc = $searchQuery->addChild('doc'); $doc->addAttribute('id', $guid); } } else { $guid = $solr->guid($object, $languageCode); $doc = $searchQuery->addChild('doc'); $doc->addAttribute('id', $guid); } } } } $offset += $limit; self::$configurationXML = $xml->asXML(); } return true; }
public function fetchElevateConfiguration( $countOnly = false, $offset = 0, $limit = 10, $searchQuery = null, $languageCode = null ) { $conds = null; $limit = array( 'offset' => $offset, 'limit' => $limit ); $fieldFilters = null; $custom = null; // START polymorphic part if ( $searchQuery !== null ) { $results = eZFindElevateConfiguration::fetchObjectsForQueryString( $searchQuery, false, $languageCode, $limit, $countOnly ); } else { if ( $languageCode ) $conds = array( 'language_code' => $languageCode ); if ( $countOnly ) { $results = eZPersistentObject::count( eZFindElevateConfiguration::definition(), $conds ); } else { $sorts = array( 'search_query' => 'asc' ); $results = eZPersistentObject::fetchObjectList( eZFindElevateConfiguration::definition(), $fieldFilters, $conds, $sorts, $limit, false, false, $custom ); } } // END polymorphic part if ( $results === null ) { // @TODO : return a more explicit error code and info. return array( 'error' => array( 'error_type' => 'extension/ezfind/elevate', 'error_code' => eZError::KERNEL_NOT_FOUND ) ); } else { return array( 'result' => $results ); } }
// validate elevation language if ( !$http->hasPostVariable( 'ezfind-elevate-language' ) ) { $feedback['missing_language'] = true; $doStorage = false; } // Do storage, and create the associated feedback if ( $doStorage ) { // Filter the not yet filtered fields $queryString = htmlspecialchars( $http->postVariable( 'ezfind-elevate-searchquery' ), ENT_QUOTES ); $languageCode = htmlspecialchars( $http->postVariable( 'ezfind-elevate-language' ), ENT_QUOTES ); // Do actual storage here. $conf = eZFindElevateConfiguration::add( $queryString, $http->postVariable( 'elevateObjectID' ), $languageCode ); // Give feedback message if ( $conf instanceof eZFindElevateConfiguration ) { $feedback['creation_ok'] = $conf; $tpl->resetVariables(); // redirect to the original page if any. // Useful to not duplicate storage code and input validation : the storage form can be submitted from another place. // Pseudo-code example: redirectURI='/ezfind/elevation_detail/86' if ( $http->hasPostVariable( 'redirectURI' ) ) { $module->redirectTo( $http->postVariable( 'redirectURI' ) ); } }
/** * Search on the Solr search server * * @param string search term * @param array parameters. * Example: * <code> * array( 'SearchOffset' => <offset>, * 'SearchLimit' => <limit>, * 'SearchSubTreeArray' => array( <node ID1>[, <node ID2>]... ), * 'SearchContentClassID' => array( <class ID1>[, <class ID2>]... ), * 'SearchContentClassAttributeID' => <class attribute ID>, * 'Facet' => array( array( 'field' => <class identifier>/<attribute identifier>[/<option>], ... ) ) ), * 'Filter' => array( <base_name> => <value>, <base_name2> => <value2> ), * 'SortBy' => array( <field> => <asc|desc> [, <field2> => <asc|desc> [,...]] ) | * array( array( <field> => <asc|desc> )[, array( <field2> => <asc|desc> )[,...]] ), * 'BoostFunctions' => array( 'fields' => array( * 'article/title' => 2, * 'modified:5' * ), * 'functions' => array( 'rord(meta_modified_dt)^10' ) * ), * 'ForceElevation' => false, * 'EnableElevation' => true * 'DistributedSearch" => array ( 'shards', array( 'shard1', 'shard2' , ... ) * 'searchfields', array ( 'myfield1, 'myfield2', ... ) * 'returnfields', array ( 'myfield1, 'myfield2', ... ) * 'rawfilterlist, array ( 'foreignfield:a', '(foreignfield:b AND otherfield:c)', ... ) * ) * ); * </code> * For full facet description, see facets design document. * For full description about 'ForceElevation', see elevate support design document ( elevate_support.rst.txt ) * * the rawFilterList in distributed search is appended to the policyfilterlist with an 'OR' for each entry, as the policy list will * in general not be applicable to foreign indexes. To be used with care! * * @param array Search types. Reserved. * * @return array Solr query results. * * @see ezfeZPSolrQueryBuilder::buildBoostFunctions() */ public function buildSearch($searchText, $params = array(), $searchTypes = array()) { eZDebugSetting::writeDebug('extension-ezfind-query', $params, 'search params'); $searchCount = 0; $eZFindIni = eZINI::instance('ezfind.ini'); $solrIni = eZINI::instance('solr.ini'); $siteIni = eZINI::instance('site.ini'); $offset = isset($params['SearchOffset']) ? $params['SearchOffset'] : 0; $limit = isset($params['SearchLimit']) ? $params['SearchLimit'] : 10; $subtrees = isset($params['SearchSubTreeArray']) ? $params['SearchSubTreeArray'] : array(); $contentClassID = isset($params['SearchContentClassID']) && $params['SearchContentClassID'] != -1 ? $params['SearchContentClassID'] : false; $contentClassAttributeID = isset($params['SearchContentClassAttributeID']) && $params['SearchContentClassAttributeID'] != -1 ? $params['SearchContentClassAttributeID'] : false; $sectionID = isset($params['SearchSectionID']) && $params['SearchSectionID'] > 0 ? $params['SearchSectionID'] : false; $dateFilter = isset($params['SearchDate']) && $params['SearchDate'] > 0 ? $params['SearchDate'] : false; $asObjects = isset($params['AsObjects']) ? $params['AsObjects'] : true; $spellCheck = isset($params['SpellCheck']) && $params['SpellCheck'] > 0 ? $params['SpellCheck'] : array(); $queryHandler = isset($params['QueryHandler']) ? $params['QueryHandler'] : $eZFindIni->variable('SearchHandler', 'DefaultSearchHandler'); // eZFInd 2.3: check ini setting and take it as a default instead of false $visibilityDefaultSetting = $siteIni->variable('SiteAccessSettings', 'ShowHiddenNodes'); $visibilityDefault = $visibilityDefaultSetting === 'true' ? true : false; $ignoreVisibility = isset($params['IgnoreVisibility']) ? $params['IgnoreVisibility'] : $visibilityDefault; $this->searchPluginInstance->postSearchProcessingData['ignore_visibility'] = $ignoreVisibility; $limitation = isset($params['Limitation']) ? $params['Limitation'] : null; $boostFunctions = isset($params['BoostFunctions']) ? $params['BoostFunctions'] : null; $forceElevation = isset($params['ForceElevation']) ? $params['ForceElevation'] : false; $enableElevation = isset($params['EnableElevation']) ? $params['EnableElevation'] : true; $distributedSearch = isset($params['DistributedSearch']) ? $params['DistributedSearch'] : false; $fieldsToReturn = isset($params['FieldsToReturn']) ? $params['FieldsToReturn'] : array(); $highlightParams = isset($params['HighLightParams']) ? $params['HighLightParams'] : array(); $searchResultClusterParams = isset($params['SearchResultClustering']) ? $params['SearchResultClustering'] : array(); $extendedAttributeFilter = isset($params['ExtendedAttributeFilter']) ? $params['ExtendedAttributeFilter'] : array(); // distributed search option // @since ezfind 2.2 $extraFieldsToSearch = array(); $extraFieldsToReturn = array(); $shardURLs = array(); $iniShards = $solrIni->variable('SolrBase', 'Shards'); $shardQuery = NULL; $shardFilterQuery = array(); if (isset($distributedSearch['shards'])) { foreach ($distributedSearch['shards'] as $shard) { $shardURLs[] = $iniShards[$shard]; } $shardQuery = implode(',', $shardURLs); } if (isset($distributedSearch['searchfields'])) { $extraFieldsToSearch = $distributedSearch['searchfields']; } if (isset($distributedSearch['returnfields'])) { $extraFieldsToReturn = $distributedSearch['returnfields']; } if (isset($distributedSearch['rawfilterlist'])) { $shardFilterQuery = $distributedSearch['rawfilterlist']; } // check if filter parameter is indeed an array, and set it otherwise if (isset($params['Filter']) && !is_array($params['Filter'])) { $params['Filter'] = array($params['Filter']); } $pathFieldName = eZSolr::getMetaFieldName($ignoreVisibility ? 'path' : 'visible_path'); $filterQuery = array(); // Add subtree query filter if (!empty($subtrees)) { $this->searchPluginInstance->postSearchProcessingData['subtree_array'] = $subtrees; $subtreeQueryParts = array(); foreach ($subtrees as $subtreeNodeID) { $subtreeQueryParts[] = $pathFieldName . ':' . $subtreeNodeID; } $filterQuery[] = implode(' OR ', $subtreeQueryParts); } // Add policy limitation query filter $policyLimitationFilterQuery = $this->policyLimitationFilterQuery($limitation, $ignoreVisibility); if ($policyLimitationFilterQuery !== false) { $filterQuery[] = $policyLimitationFilterQuery; } // Add time/date query filter if ($dateFilter > 0) { switch ($dateFilter) { // last day case 1: $searchTimestamp = strtotime('-1 day'); break; // last week // last week case 2: $searchTimestamp = strtotime('-1 week'); break; // last month // last month case 3: $searchTimestamp = strtotime('-1 month'); break; // last three month // last three month case 4: $searchTimestamp = strtotime('-3 month'); break; // last year // last year case 5: $searchTimestamp = strtotime('-1 year'); break; } $filterQuery[] = eZSolr::getMetaFieldName('published') . ':[' . ezfSolrDocumentFieldBase::preProcessValue($searchTimestamp, 'date') . '/DAY TO *]'; } if ((!eZContentObjectTreeNode::showInvisibleNodes() || !$ignoreVisibility) && $eZFindIni->variable('SearchFilters', 'FilterHiddenFromDB') == 'enabled') { $db = eZDB::instance(); $invisibleNodeIDArray = $db->arrayQuery('SELECT node_id FROM ezcontentobject_tree WHERE ezcontentobject_tree.is_invisible = 1', array('column' => 0)); $hiddenNodesQueryText = 'meta_main_node_id_si:[* TO *] -meta_main_node_id_si:('; foreach ($invisibleNodeIDArray as $element) { $hiddenNodesQueryText = $hiddenNodesQueryText . $element['node_id'] . ' '; } $hiddenNodesQueryText = $hiddenNodesQueryText . ')'; // only add filter if there are hidden nodes after all if ($invisibleNodeIDArray) { $filterQuery[] = $hiddenNodesQueryText; } } // Add content class query filter $classLimitationFilter = $this->getContentClassFilterQuery($contentClassID); if ($classLimitationFilter !== null) { $filterQuery[] = $classLimitationFilter; } // Add section to query filter. if ($sectionID) { $filterQuery[] = eZSolr::getMetaFieldName('section_id') . ':' . $sectionID; } $languageFilterQuery = $this->buildLanguageFilterQuery(); if ($languageFilterQuery) { $filterQuery[] = $languageFilterQuery; } $paramFilterQuery = $this->getParamFilterQuery($params); if (!empty($paramFilterQuery)) { $filterQuery = array_merge($filterQuery, $paramFilterQuery); } //add raw filters if ($eZFindIni->hasVariable('SearchFilters', 'RawFilterList')) { $rawFilters = $eZFindIni->variable('SearchFilters', 'RawFilterList'); if (is_array($rawFilters)) { $filterQuery = array_merge($filterQuery, $rawFilters); } } // Build and get facet query prameters. $facetQueryParamList = $this->buildFacetQueryParamList($params); // search only text type declared fields $fieldTypeExcludeList = $this->fieldTypeExludeList(NULL); // Create sort parameters based on the parameters. $sortParameter = $this->buildSortParameter($params); //the array_unique below is necessary because attribute identifiers are not unique .. and we get as //much highlight snippets as there are duplicate attribute identifiers //these are also in the list of query fields (dismax, ezpublish) request handlers $queryFields = array_unique($this->getClassAttributes($contentClassID, $contentClassAttributeID, $fieldTypeExcludeList)); //highlighting only in the attributes, otherwise the object name is repeated in the highlight, which is already //partly true as it is mostly composed of one or more attributes. //maybe we should add meta data to the index to filter them out. $highLightFields = $queryFields; //@since eZ Find 2.3 //when dedicated attributes are searched for, don't add meta-fields to the $queryfields list if (!$contentClassAttributeID) { $queryFields[] = eZSolr::getMetaFieldName('name'); if (!$eZFindIni->hasVariable('SearchFilters', 'ExcludeOwnerName') || $eZFindIni->variable('SearchFilters', 'ExcludeOwnerName') !== 'enabled') { $queryFields[] = eZSolr::getMetaFieldName('owner_name'); } } $spellCheckParamList = array(); // @param $spellCheck expects array (true|false, dictionary identifier, ...) if (isset($spellCheck[0]) and $spellCheck[0] or $eZFindIni->variable('SpellCheck', 'SpellCheck') == 'enabled' and (isset($spellCheck[0]) and !$spellCheck[0])) { $dictionary = isset($spellCheck[1]) ? $spellCheck[1] : $eZFindIni->variable('SpellCheck', 'DefaultDictionary'); $spellCheckParamList = array('spellcheck' => 'true', 'spellcheck.q' => $searchText, 'spellcheck.dictionary' => $dictionary, 'spellcheck.collate' => 'true', 'spellcheck.extendedResults' => 'true', 'spellcheck.onlyMorePopular' => 'true', 'spellcheck.count' => 1); } // Create the Elevate-related parameters here : $elevateParamList = eZFindElevateConfiguration::getRuntimeQueryParameters($forceElevation, $enableElevation, $searchText); // process query handler: standard, simplestandard, ezpublish, heuristic // first determine which implemented handler to use when heuristic is specified if (strtolower($queryHandler) === 'heuristic') { // @todo: this code will evolve of course if (preg_match('/[\\^\\*\\~]|AND|OR/', $searchText) > 0) { $queryHandler = 'simplestandard'; } else { $queryHandler = 'ezpublish'; } } $handlerParameters = array(); $queryHandler = strtolower($queryHandler); switch ($queryHandler) { case 'standard': // @todo: this is more complicated // build the query against all "text" like fields // should take into account all the filter fields and class filters to shorten the query // need to build: Solr q if (array_key_exists('fields', $boostFunctions)) { $handlerParameters = array('q' => $this->buildMultiFieldQuery($searchText, array_merge($queryFields, $extraFieldsToSearch), $boostFunctions['fields']), 'qt' => 'standard'); } else { $handlerParameters = array('q' => $this->buildMultiFieldQuery($searchText, array_merge($queryFields, $extraFieldsToSearch)), 'qt' => 'standard'); } break; case 'simplestandard': // not to do much, searching is against the default aggregated field // only highlightfields $highLightFields = array('ezf_df_text'); $handlerParameters = array('q' => $searchText, 'qt' => 'standard', 'hl.usePhraseHighlighter' => 'true', 'hl.highlightMultiTerm' => 'true'); break; case 'ezpublish': // the dismax based handler, just keywordss input, most useful for ordinary queries by users // need to build: Solr q, qf, dismax specific parameters // the dismax based handler, just keywordss input, most useful for ordinary queries by users // need to build: Solr q, qf, dismax specific parameters default: // ezpublish of course, this to not break BC and is the most "general" // if another value is specified, it is supposed to be a dismax like handler // with possible other tuning variables then the stock provided 'ezpublish' in solrconfi.xml // remark it should be lowercase in solrconfig.xml! $boostQueryString = $this->boostQuery(); $rawBoostQueries = $eZFindIni->variable('QueryBoost', 'RawBoostQueries'); if (is_array($rawBoostQueries) && !empty($rawBoostQueries)) { $boostQueryString .= ' ' . implode(' ', $rawBoostQueries); } $handlerParameters = array('q' => $searchText, 'bq' => $boostQueryString, 'qf' => implode(' ', array_merge($queryFields, $extraFieldsToSearch)), 'qt' => $queryHandler); } // Handle boost functions : $boostFunctionsParamList = $this->buildBoostFunctions($boostFunctions, $handlerParameters); // special handling of filters in the case of distributed search filters // incorporate distributed search filters if defined with an OR expression, and AND-ing all others // need to do this as multiple fq elements are otherwise AND-ed by the Solr backend // when using this to search across a dedicated set of languages, it will still be valid with the ezp permission // scheme if (!empty($shardFilterQuery)) { $fqString = '((' . implode(') AND (', $filterQuery) . ')) OR ((' . implode(') OR (', $shardFilterQuery) . '))'; // modify the filterQuery array with this single string as the only element $filterQuery = array($fqString); } // Document transformer fields since eZ Find 5.4 $docTransformerFields = array('[elevated]'); $fieldsToReturnString = eZSolr::getMetaFieldName('guid') . ' ' . eZSolr::getMetaFieldName('installation_id') . ' ' . eZSolr::getMetaFieldName('main_url_alias') . ' ' . eZSolr::getMetaFieldName('installation_url') . ' ' . eZSolr::getMetaFieldName('id') . ' ' . eZSolr::getMetaFieldName('main_node_id') . ' ' . eZSolr::getMetaFieldName('language_code') . ' ' . eZSolr::getMetaFieldName('name') . ' score ' . eZSolr::getMetaFieldName('published') . ' ' . eZSolr::getMetaFieldName('path_string') . ' ' . eZSolr::getMetaFieldName('main_path_string') . ' ' . eZSolr::getMetaFieldName('is_invisible') . ' ' . implode(' ', $docTransformerFields) . ' ' . implode(' ', $extraFieldsToReturn); if (!$asObjects) { if (empty($fieldsToReturn)) { // @todo: needs to be refined with Solr supporting globbing in fl argument, otherwise requests will be to heavy for large fields as for example binary file content $fieldsToReturnString = 'score, *'; } else { $fieldsToReturnString .= ' ' . implode(',', $fieldsToReturn); } } $searchResultClusterParamList = array('clustering' => 'true'); $searchResultClusterParamList = $this->buildSearchResultClusterQuery($searchResultClusterParams); eZDebugSetting::writeDebug('extension-ezfind-query', $searchResultClusterParamList, 'Cluster params'); $queryParams = array_merge($handlerParameters, array('start' => $offset, 'rows' => $limit, 'sort' => $sortParameter, 'indent' => 'on', 'version' => '2.2', 'fl' => $fieldsToReturnString, 'fq' => $filterQuery, 'hl' => $eZFindIni->variable('HighLighting', 'Enabled'), 'hl.fl' => implode(' ', $highLightFields), 'hl.snippets' => $eZFindIni->variable('HighLighting', 'SnippetsPerField'), 'hl.fragsize' => $eZFindIni->variable('HighLighting', 'FragmentSize'), 'hl.requireFieldMatch' => $eZFindIni->variable('HighLighting', 'RequireFieldMatch'), 'hl.simple.pre' => $eZFindIni->variable('HighLighting', 'SimplePre'), 'hl.simple.post' => $eZFindIni->variable('HighLighting', 'SimplePost'), 'wt' => 'php'), $facetQueryParamList, $spellCheckParamList, $boostFunctionsParamList, $elevateParamList, $searchResultClusterParamList); if (isset($extendedAttributeFilter['id']) && isset($extendedAttributeFilter['params'])) { //single filter $extendedAttributeFilter = array($extendedAttributeFilter); } foreach ($extendedAttributeFilter as $filterDefinition) { if (isset($filterDefinition['id'])) { $filter = eZFindExtendedAttributeFilterFactory::getInstance($filterDefinition['id']); if ($filter) { $filterParams = isset($filterDefinition['params']) ? $filterDefinition['params'] : array(); $queryParams = $filter->filterQueryParams($queryParams, $filterParams); } } } return $queryParams; }
if ( $http->hasPostVariable( 'ezfind-elevationdetail-filter-searchquery' ) ) $searchQuery = $http->postVariable( 'ezfind-elevationdetail-filter-searchquery' ); elseif ( $Params['SearchQuery'] !== false ) $searchQuery = $Params['SearchQuery']; if ( $searchQuery ) { $searchQuery = htmlspecialchars( $searchQuery, ENT_QUOTES ); $searchQueryArray = array( 'searchQuery' => $searchQuery, 'fuzzy' => $fuzzyFilter ); $viewParameters = array_merge( $viewParameters, array( 'search_query' => $searchQuery ) ); } // fetch configurations associated to the object : $configurations = eZFindElevateConfiguration::fetchConfigurationForObject( $object->attribute( 'id' ), false, @$viewParameters['language'], $limitArray, false, $searchQueryArray ); $configurationsCount = eZFindElevateConfiguration::fetchConfigurationForObject( $object->attribute( 'id' ), false, @$viewParameters['language'], null, true, $searchQueryArray ); $tpl->setVariable( 'configurations', $configurations ); $tpl->setVariable( 'configurations_count', $configurationsCount ); } //$viewParameters = array_merge( $viewParameters, array( 'offset' => ( isset( $Params['Offset'] ) and is_numeric( $Params['Offset'] ) ) ? $Params['Offset'] : 0, // 'limit' => $Params['Limit'] ) ); $tpl->setVariable( 'view_parameters', $viewParameters ); $tpl->setVariable( 'feedback', $feedback ); $tpl->setVariable( 'language_wildcard', $wildcard ); $tpl->setVariable( 'baseurl', $thisUrl ); $Result = array(); $Result['content'] = $tpl->fetch( "design:ezfind/elevation_detail.tpl" );
/** * test for fetchConfigurationForObject() */ public function testFetchConfigurationForObject() { // clean up the table beforehand $db = eZDB::instance(); $rows = $db->query('TRUNCATE TABLE ezfind_elevate_configuration;'); # start 1 : invalid object ID $expected1 = null; $configuration1 = eZFindElevateConfiguration::fetchConfigurationForObject('non numeric'); self::assertEquals($expected1, $configuration1); # end 1 # start 2 : simple fetch with default parameters. $queryString = "test 1"; $objectID = 1; $language = "eng-GB"; eZFindElevateConfiguration::add($queryString, $objectID, $language); $expected2 = array($language => array(new eZFindElevateConfiguration(array('search_query' => $queryString, 'contentobject_id' => $objectID, 'language_code' => $language)))); $configuration2 = eZFindElevateConfiguration::fetchConfigurationForObject($objectID); self::assertEquals($expected2, $configuration2); # end 2 # start 3 : group by language disabled. $expected3 = array(new eZFindElevateConfiguration(array('search_query' => $queryString, 'contentobject_id' => $objectID, 'language_code' => $language))); $configuration3 = eZFindElevateConfiguration::fetchConfigurationForObject($objectID, false); self::assertEquals($expected3, $configuration3); # end 3 # start 4 : filtering by language code $additionalLanguage = "esl-ES"; eZFindElevateConfiguration::add($queryString, $objectID, $additionalLanguage); $expected4 = array($additionalLanguage => array(new eZFindElevateConfiguration(array('search_query' => $queryString, 'contentobject_id' => $objectID, 'language_code' => $additionalLanguage)))); $configuration4 = eZFindElevateConfiguration::fetchConfigurationForObject($objectID, true, $additionalLanguage); self::assertEquals($expected4, $configuration4); # end 4 # start 5 : testing the countOnly parameter $expected5 = 1; $configuration5 = eZFindElevateConfiguration::fetchConfigurationForObject($objectID, true, $additionalLanguage, null, true); self::assertEquals($expected5, $configuration5); # end 5 # start 6 : testing the limit parameter $expected6 = 2; $configuration6 = eZFindElevateConfiguration::fetchConfigurationForObject($objectID, true, null, 1, true); self::assertEquals($expected6, $configuration6); # end 6 # start 7 : filtering by search query $additionalQueryString = "test 2"; eZFindElevateConfiguration::add($additionalQueryString, $objectID, $language); $expected7 = 2; $configuration7 = eZFindElevateConfiguration::fetchConfigurationForObject($objectID, true, null, null, true, $queryString); self::assertEquals($expected7, $configuration7); # end 7 }
public static function getConfiguration() { return parent::getConfiguration(); }
/** * synchronises elevate configuration across language shards in case of * multiple lnguage indexes, or the default one * * @TODO: handle exceptions properly */ public function pushElevateConfiguration() { if ( $this->UseMultiLanguageCores == true ) { foreach ( $this->SolrLanguageShards as $shard ) { eZFindElevateConfiguration::synchronizeWithSolr( $shard ); } return true; } else { return eZFindElevateConfiguration::synchronizeWithSolr( $this->Solr ); } }
// Identify which object is concerned. $object = false; if ($Params['ObjectID'] !== false and is_numeric($Params['ObjectID'])) { $object = eZContentObject::fetch($Params['ObjectID']); } if (!$object) { //error. Redirect to the elevate configuration landing page. $module->redirectTo('/ezfind/elevate'); } elseif ($object and $http->hasPostVariable('ezfind-removeelevation-cancel')) { // Redirect to the detail elevate configuration page for this object : $module->redirectTo('/ezfind/elevation_detail/' . $object->attribute('id')); } elseif ($object and $http->hasPostVariable('ezfind-removeelevation-do')) { $tpl->setVariable('elevatedObject', $object); $searchQuery = htmlspecialchars($http->postVariable("ezfind-removeelevation-searchquery"), ENT_QUOTES); $languageCode = htmlspecialchars($http->postVariable("ezfind-removeelevation-languagecode"), ENT_QUOTES); eZFindElevateConfiguration::purge($searchQuery, $object->attribute('id'), $languageCode); $feedback['removal_back_link'] = '/ezfind/elevate/'; $feedback['confirm_remove'] = array('contentobject_id' => $object->attribute('id'), 'search_query' => $searchQuery, 'language_code' => $languageCode); } else { $thisUrl .= '/' . $object->attribute('id'); $tpl->setVariable('elevatedObject', $object); // check search query $searchQuery = false; if ($Params['SearchQuery'] !== false and $Params['SearchQuery'] != '') { $searchQuery = $Params['SearchQuery']; $thisUrl .= '/' . $searchQuery; } else { // error, redirect to the detail elevate configuration page for this object : $module->redirectTo('/ezfind/elevation_detail/' . $object->attribute('id')); } if ($Params['LanguageCode'] !== false and $Params['LanguageCode'] != '') {