/** * @param ApplicationFacet[] * @return FacetBase[] */ public function buildFacetList($rawFacetList) { $facets = array(); if ( is_array($rawFacetList) ) { $applicationIdentifier = $this->applicationObject()->attribute('identifier'); FacetFieldTagLanguage::$applicationIdentifier = $applicationIdentifier; FacetFieldTag::$applicationIdentifier = $applicationIdentifier; FacetPublishedSince::$applicationIdentifier = $applicationIdentifier; foreach ($rawFacetList as $rawFacet) { $usableFacet = FacetFactory::factory($rawFacet); if ( $usableFacet instanceof FacetBase ) { $facets[] = $usableFacet; if ( $usableFacet instanceof FacetFieldTagLanguage ) $usableFacet->defaultValues = ApplicationLocalized::getTagFromLanguage( $this->applicationLocalized()->getPublisherLanguages() ); } } } return $facets; }
/** * * Parse facet result list * * For now we are handling this directly here, but depending * on the additional facet types we will add may may have to * move this into the facet implementation classes if * different handling is needed * * @param SugarSeachEngineElasticResultSet $resultSet * @param array $options * @return array */ public function parseFacets(SugarSeachEngineElasticResultSet $resultSet, $options = array()) { $result = array('module_facet' => array(), 'secondary_facets' => array()); // we can only process secondary facet results if a module filter is present if ($this->isOptionsModuleFilterValid($options)) { $module = array_shift($options['moduleFilter']); $defs = $this->loadFacetDefs($module); } else { $defs = false; } foreach ($resultSet->getFacets() as $facetId => $facetData) { // module facet is hard coded for now and uses "_type" as its name (core code) if ($facetId == '_type') { // simulate facet defs $modFacetDefs = array('label' => 'LBL_MODULE_FACET', 'type' => 'terms', 'ui_type' => 'select'); $facet = FacetFactory::get('terms'); if ($parsed = $facet->parseData($facetId, $modFacetDefs, $facetData)) { $result['module_facet'] = $parsed; } continue; } // process secondary facets if defs are available if (!empty($defs[$facetId])) { $facet = FacetFactory::get($defs[$facetId]['type']); $facet->setOptions($defs[$facetId]['options']); if ($parsed = $facet->parseData($facetId, $defs[$facetId], $facetData)) { $result['secondary_facets'][$facetId] = $parsed; } } } return $result; }
/** * @return eZINI */ protected static function getMerckIni() { if ( !isset(self::$merckINI) ) { self::$merckINI = eZINI::instance('merck.ini'); } return self::$merckINI; }