Esempio n. 1
0
 /**
  */
 public function prepareViewFacets($result, $request)
 {
     $facets = $result->getFacets();
     $facetLimit = Opus_Search_Config::getFacetLimits();
     $facetArray = array();
     $selectedFacets = array();
     $facetNumberContainer = array();
     $showFacetExtender = array();
     foreach ($facets as $key => $facet) {
         $showFacetExtender[$key] = $facetLimit[$key] <= sizeof($facet);
         $this->getLogger()->debug("found {$key} facet in search results");
         $facetNumberContainer[$key] = sizeof($facet);
         $facetValue = $request->getParam($key . 'fq', '');
         if ($facetValue !== '') {
             $selectedFacets[$key] = $facetValue;
             $showFacetExtender[$key] = false;
         }
         if (count($facets[$key]) > 1 || $facetValue !== '') {
             $facetArray[$key] = $facet;
         }
     }
     // Hide institutes facet if collection does not exist or is hidden
     $institutes = Opus_CollectionRole::fetchByName('institutes');
     if (is_null($institutes) || !$institutes->getVisible()) {
         unset($facetArray['institute']);
     }
     $this->_facets = $facetArray;
     $this->_selectedFacets = $selectedFacets;
     $this->_facetNumberContainer = $facetNumberContainer;
     $this->_showFacetExtender = $showFacetExtender;
 }
Esempio n. 2
0
 public function testGetFacetLimitsFromConfigWithYearInverted()
 {
     $model = new Solrsearch_Model_FacetMenu();
     $config = Zend_Registry::get('Zend_Config');
     if (isset($config->searchengine->solr->facets)) {
         $config->searchengine->solr->facets = 'year_inverted,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute';
     } else {
         $testConfig = new Zend_Config(array('searchengine' => array('solr' => array('facets' => 'year_inverted,doctype,author_facet,language,has_fulltext,belongs_to_bibliography,subject,institute'))), true);
         // Include the above made configuration changes in the application configuration.
         $testConfig->merge($config);
     }
     $config->merge(new Zend_Config(array('searchengine' => array('solr' => array('facetlimit' => array('author_facet' => 3, 'year_inverted' => 15))))));
     $facetLimits = Opus_Search_Config::getFacetLimits();
     $this->assertEquals(3, $facetLimits['author_facet']);
     $this->assertEquals(15, $facetLimits['year']);
     $this->assertEquals(10, $facetLimits['doctype']);
     $this->assertEquals(10, $facetLimits['has_fulltext']);
     $this->assertEquals(10, $facetLimits['belongs_to_bibliography']);
     $this->assertEquals(10, $facetLimits['subject']);
     $this->assertEquals(10, $facetLimits['institute']);
 }