63 $this->searchResults = $results;
68 Cache::invalidate(
"fakoli_search_map");
73 Settings::setDefaultValue(
"search",
"search_result_format",
"Combined List",
"String",
"Specifies the display format to use when displaying results",
"",
"Combined List\nGrouped by Type");
74 Settings::setDefaultValue(
"search",
"results_per_page",
"20",
"Number",
"Specifies the number of results to show per page. Set to zero for no pagination.");
75 Settings::setDefaultValue(
"search",
"show_text_fragment",
false,
"Boolean",
"Specifies whether to show with the search results. Note that not all search types will return a text fragment");
91 Cache::put(
"fakoli_search_map",
$map);
104 trace(
"Search Handler: ".get_class($searchHandler), 3);
105 $this->searchResults = $searchHandler->search($params, $this);
109 trace(
"Search Handler: Using built-in SearchManager", 3);
118 switch($this->displayMode)
121 $this->list =
new DataListView($this->
extractDataItems(),
"search_results");
122 $this->list->emptyMessage =
"Your search did not match any items.";
123 $this->list->writeIdTag =
true;
124 $this->list->sortable =
true;
125 $this->list->filter =
false;
131 $this->list->emptyList =
"Your search did not match any items.";
132 $this->list->writeIdTag =
true;
135 if ($this->enableFacetFilter)
137 $this->facetManager =
new FacetManager(
'facet_manager', $this->list);
139 trace(
"Facet Classes: ".implode(
", ",
$classes), 3);
141 if ($this->searchResultTypeFacet)
156 if (is_object($params))
158 $class_array = $_REQUEST[
"searchable_classes:"];
162 $params = trim($params);
168 $this->searchResults = array();
178 foreach($searchables as $searchable)
180 if ($class_array && !array_key_exists($searchable, $class_array))
continue;
182 $obj =
new $searchable;
183 $results =
$obj->search($params);
199 if (isset($_REQUEST[
"searchable_classes:"]))
201 $class_array = $_REQUEST[
"searchable_classes:"];
208 foreach($searchables as $searchable)
210 if ($class_array && !array_key_exists($searchable, $class_array))
continue;
222 foreach($this->searchResults as
$result)
232 trace(
"Sorting ".count($this->searchResults).
" items by relevance", 3);
239 return ($item1->relevance() > $item2->relevance())?-1:1;
244 trace(
"Sorting ".count($this->searchResults).
" items by title", 3);
251 return strcmp($item1->title(), $item2->title());
256 trace(
"Sorting ".count($this->searchResults).
" items by date", 3);
263 return strtotime($item2->date()) - strtotime($item1->date());
268 return $item->summary();
273 trace(
"Drawing Facets", 3);
274 trace(getBacktrace(0), 3);
277 if ($this->drawnFacets || !$this->facetManager)
return;
281 $this->facetManager->id =
$id;
284 $script .= $this->facetManager->writeScript();
285 echo $this->facetManager->drawForm();
287 $this->drawnFacets =
true;
303 $script .= $this->list->writeScript();
305 $num = count($this->searchResults);
309 echo
"<p><em>$num ".pluralize(
"match", $num).
" found.</em></p>";
314 switch($this->displayMode)
317 $this->list->drawView();
322 $this->list->drawList();
335 $result =
new $resultClass($item);
337 $result->innerClass = get_class($item);
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
static usingFeature()
Uses the specified framework feature(s).
static using()
Import the datamodels, views and manifest for the specified component(s).
The SearchManager class provides a simple API for searching across all Searchable records in the appl...
static compareDate($item1, $item2)
SearchManager($results=null)
static compareTitle($item1, $item2)
static wrap($items, $resultClass)
static compareRelevance($item1, $item2)
static formatSearchResult($item)
static upgradeComponent($version)
static getValue($component, $name)
Retrieve the value of the specified Setting.
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
static addFacets($manager, $classes, $dropdown=true, $max_width="200px", $width="200px", $height="120px")