1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8class Search_ResultSet_FacetFilter 9{ 10 private $facet; 11 private $data; 12 13 function __construct(Search_Query_Facet_Interface $facet, array $data) 14 { 15 $this->facet = $facet; 16 $this->data = $data; 17 } 18 19 function isFacet(Search_Query_Facet_Interface $facet) 20 { 21 return $this->facet->getName() === $facet->getName(); 22 } 23 24 function getName() 25 { 26 return $this->facet->getName(); 27 } 28 29 function getLabel() 30 { 31 return $this->facet->getLabel(); 32 } 33 34 function getOperator() 35 { 36 if (is_a($this->facet, 'Search_Query_Facet_Term')) { 37 return $this->facet->getOperator(); 38 } else { 39 return null; 40 } 41 } 42 43 function getOptions() 44 { 45 $out = []; 46 47 foreach ($this->data as $entry) { 48 $out[$entry['value']] = tr('%0 (%1)', tra($this->facet->render($entry['value'])), $entry['count']); 49 } 50 51 return $out; 52 } 53} 54