-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfaceted_search.inc
executable file
·1833 lines (1646 loc) · 54.2 KB
/
faceted_search.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* @file
* Provides base classes for implementing filters and facets, and classes needed
* by other modules.
*/
/**
* The base class for filters.
*
* Filters actually impact results only when they have an active category (a
* "category" is a filtering value). The filtering is delegated to the active
* category.
*/
class faceted_search_filter {
/**
* The key identifying this class of filter. Keys are used in the form of
* 'key:text' tokens in the search text.
*/
var $_key = '';
/**
* The status of this filter.
*/
var $_status = FALSE;
/**
* The weight of this filter, for sorting purposes.
*/
var $_weight = 0;
/**
* An array representing the path of categories leading to the active category
* of this facet. This path includes the active category itself.
*/
var $_path = array();
/**
* Constructor.
*
* @param $key
* Key corresponding to this class of filter. This should be the same string
* as used to construct the filter from the search text in the module's
* implementation of hook_faceted_search_parse().
* @param $active_path
* Array representing the path leading to the active category, including the
* active category itself. Defaults to an empty array, meaning no active
* category.
*/
function faceted_search_filter($key, $active_path = array()) {
$this->_key = $key;
$this->_path = $active_path;
}
/**
* Return TRUE if this filter offers browsable categories, or FALSE otherwise.
*/
function is_browsable() {
return FALSE;
}
/**
* Assign settings to this filter.
*
* @param $settings
* Array of settings.
*/
function set($settings) {
if (isset($settings['status'])) {
$this->_status = $settings['status'];
}
if (isset($settings['weight'])) {
$this->_weight = $settings['weight'];
}
}
/**
* Return the key for this class of filter.
*/
function get_key() {
return $this->_key;
}
/**
* Return a help text for site administrators.
*/
function get_help() {
return '';
}
/**
* Return the status of this filter.
*
* @return
* TRUE when the filter is enabled, FALSE otherwise.
*/
function get_status() {
return $this->_status;
}
/**
* Change the status of this filter.
*
* @param $status
* TRUE to enable the filter, FALSE to disable it.
*/
function set_status($status) {
$this->_status = $status;
}
/**
* Return the configured weight of this filter, for sorting purposes.
*/
function get_weight() {
return $this->_weight;
}
/**
* Assign the weight of this filter.
*/
function set_weight($weight) {
$this->_weight = $weight;
}
/**
* Return TRUE if this facet has an active category. If a facet is active, it
* normally means that it is used in the current search.
*/
function is_active() {
return count($this->_path) > 0;
}
/**
* Return an array representing the path to the active category, including the
* active category itself. Return an empty array if there is no active
* category.
*/
function get_active_path() {
return $this->_path;
}
/**
* Set the path of the active category, including the active category itself.
*
* @param $path
* The path of the category (array of categories). Defaults to no active
* path.
*/
function set_active_path($path = array()) {
$this->_path = $path;
}
/**
* Return the active category, or NULL if there is no active category.
*/
function get_active_category() {
return end($this->_path);
}
/**
* Append keywords used by this filter into the specified array.
*/
function get_keywords(&$keywords) {
// Does nothing by default.
}
}
/**
* Base class for facet categories.
*/
class faceted_search_category {
/**
* The number of nodes associated to this category.
*/
var $_count = NULL;
/**
* Constructor.
*
* @param $count
* The number of nodes associated to this category within the current
* search.
*/
function faceted_search_category($count = NULL) {
$this->_count = $count;
}
/**
* Return the number of nodes associated to this category within the current
* search.
*
* @return The number of matching nodes, or NULL is count is unknown.
*/
function get_count() {
return $this->_count;
}
/**
* Return weight of this category, for sorting purposes.
*/
function get_weight() {
return 0;
}
/**
* Updates a query for retrieving the subcategories of this category and their
* associated nodes within the current search results.
*
* This only needs to be overridden for hierarchical facets.
*
* @param $query
* The query object to update.
* @return
* FALSE if this facet can't have subcategories.
*/
function build_subcategories_query(&$query) {
return FALSE;
}
}
/**
* The parent class for facets.
*
* A facet is a filter with browsable categories.
*/
class faceted_search_facet extends faceted_search_filter {
/**
* The current sort criteria to use for this facet. This determines how to
* sort the facet's categories.
*/
var $_sort = 'count';
/**
* The maximum number of categories to show in this facet.
*/
var $_max_categories = 10;
/**
* Constructor.
*
* @param $key
* Key corresponding to this class of facet. This should be the same string
* as used to construct the facet from the search text in the module's
* implementation of hook_faceted_search_parse().
*/
function faceted_search_facet($key, $active_path = array()) {
parent::faceted_search_filter($key, $active_path);
}
/**
* Return TRUE if this filter offers browsable categories, or FALSE otherwise.
*
* A browsable filter implies that categories retrieval and sorting methods
* are available.
*/
function is_browsable() {
return TRUE;
}
/**
* Assign settings to this facet.
*
* @param $settings
* Array of settings.
*/
function set($settings) {
parent::set($settings);
if (isset($settings['sort'])) {
$this->_sort = $settings['sort'];
}
if (isset($settings['max_categories'])) {
$this->_max_categories = $settings['max_categories'];
}
}
/**
* Return the available sort options for this facet. Each option is a key =>
* label pair.
*
* Each key must have a corresponding handler method in the form
* 'build_sort_query_key'.
*/
function get_sort_options() {
return array('count' => t('Count'));
}
/**
* Return the current sort criteria for this facet.
*/
function get_sort() {
return $this->_sort;
}
/**
* Assigns the current sort criteria for this facet.
*/
function set_sort($sort) {
// Assign value only if a corresponding handler exists.
if (method_exists($this, 'build_sort_query_'. $sort)) {
$this->_sort = $sort;
}
}
/**
* Handler for the 'count' sort criteria.
*/
function build_sort_query_count(&$query) {
$query->add_orderby('count', 'DESC');
}
/**
* Applies the facet's current sort option to the given query.
*/
function build_sort_query(&$query) {
$method = 'build_sort_query_'. $this->_sort;
if (method_exists($this, $method)) {
$this->$method($query);
}
}
/**
* Return the configured maximum number of categories to show in this facet.
*
* @return
* The maximum number of categories, or 0 for no limit.
*/
function get_max_categories() {
return $this->_max_categories;
}
/**
* Assign the maximum number of categories to show in this facet.
*
* @param $max_categories
* The maximum number of categories, or 0 for no limit.
*/
function set_max_categories($max_categories) {
$this->_max_categories = $max_categories;
}
/**
* Updates a query for retrieving the root categories of this filter and their
* associated nodes within the current search results.
*
* @param $query
* The query object to update.
* @return
* FALSE if this filter can't have root categories.
*/
function build_root_categories_query() {
return FALSE;
}
/**
* This factory method creates categories given query results that include the
* fields selected in get_root_categories_query() or get_subcategories_query().
*
* @param $results
* $results A database query result resource.
* @return
* Array of categories.
*/
function build_categories($results) {
return array();
}
/**
* Inject components into the query for selecting nodes matching this facet's
* active category.
*
* @param $query
* Query to inject the components into.
* @param $words
* Array keyed by search index type, each element being an array of positive
* words to lookup for that index type. This method should insert any words
* it cares about.
* @param $matches
* Minimum number of words that should match in query results for each index type.
*/
function build_results_query(&$query, &$words, &$matches) {
// Note: Facets ignore $words and $matches.
if ($category = $this->get_active_category()) {
$category->build_results_query($query);
}
}
}
/**
* The base class of keyword categories.
*/
class faceted_search_keyword_category {
/**
* Append keywords used by this category into the specified array.
*/
function get_keywords(&$keywords) {
// Does nothing by default.
}
/**
* Check whether a given word is allowed for searching.
*
* @return
* The allowed word, or NULL if it is not allowed.
*/
function check_word($word) {
if (is_numeric($word)) {
return (int)ltrim($word, '-0');
}
return $word;
}
/**
* Prepare a label for output.
*/
function check_label($label, $html = FALSE) {
if (!$html) {
return strip_tags($label);
}
return $label;
}
}
/**
* The keyword AND category.
*/
class faceted_search_keyword_and_category extends faceted_search_keyword_category {
var $_word = '';
/**
* Constructor.
*
* @param $phrase
* String containing the word to search.
*/
function faceted_search_keyword_and_category($word) {
$this->_word = $word;
}
/**
* Return the label for this category.
*
* @param $html
* TRUE when HTML is allowed in the label, FALSE otherwise.
*/
function get_label($html = FALSE) {
return $this->check_label(theme('faceted_search_keyword_and_label', $this->_word), $html);
}
/**
* Return the search text for this category.
*/
function get_text() {
return $this->_word;
}
/**
* Append keywords used by this category into the specified array.
*/
function get_keywords(&$keywords) {
$keywords[] = $this->_word;
}
/**
* Return the weight of this category, for sorting purposes.
*/
function get_weight() {
return 0;
}
/**
* Inject components into the query for selecting nodes matching this category.
*
* @param $query
* Query to inject the components into.
* @param $words
* Array keyed by search index type, each element being an array of positive
* words to lookup for that index type. This method should insert any words
* it cares about.
* @param $matches
* Minimum number of words that should match in query results for each index type.
* @param $type
* Type of search index entry to be searched.
*/
function build_results_query(&$query, &$words, &$matches, $type) {
if (($word = $this->check_word($this->_word)) && !isset($words[$type][$word])) {
if (strlen($word) >= variable_get('minimum_word_size', 3)) {
$words[$type][$word] = $word;
$matches[$type]++;
}
else {
// Short words are only searched against the dataset.
$query->enable_part("{$type}_search_dataset");
// Ensure this type will be searched even though it has no "long" word.
if (!isset($words[$type])) {
$words[$type] = array();
}
}
// The dataset will have to be looked up as well if the query becomes more
// complex because of other keyword search operators.
$query->set_current_part("{$type}_search_dataset");
$query->add_where("{$type}_search_dataset.data LIKE '%% %s %%'", $word);
$query->set_current_part(); // Back to default part.
}
}
}
/**
* The keyword phrase category.
*/
class faceted_search_keyword_phrase_category extends faceted_search_keyword_category {
var $_phrase = '';
/**
* Constructor.
*
* @param $phrase
* String containing the phrase to search.
*/
function faceted_search_keyword_phrase_category($phrase) {
$this->_phrase = $phrase;
}
/**
* Return the label for this category.
*
* @param $html
* TRUE when HTML is allowed in the label, FALSE otherwise.
*/
function get_label($html = FALSE) {
return $this->check_label(theme('faceted_search_keyword_phrase_label', $this->_phrase), $html);
}
/**
* Return the search text for this operator.
*/
function get_text() {
return '"'. $this->_phrase .'"';
}
/**
* Append keywords used by this category into the specified array.
*/
function get_keywords(&$keywords) {
$keywords[] = $this->_phrase;
}
/**
* Return the weight of this category, for sorting purposes.
*/
function get_weight() {
return 1;
}
/**
* Inject components into the query for selecting nodes matching this category.
*
* @param $query
* Query to inject the components into.
* @param $words
* Array keyed by search index type, each element being an array of positive
* words to lookup for that index type. This method should insert any words
* it cares about.
* @param $matches
* Minimum number of words that should match in query results for each index type.
* @param $type
* Type of search index entry to be searched.
*/
function build_results_query(&$query, &$words, &$matches, $type) {
$split = explode(' ', $this->_phrase);
foreach ($split as $word) {
if ($word = $this->check_word($word)) {
$words[$type][$word] = $word;
}
}
if (count($split) > 0) {
$matches[$type]++; // A phrase counts as one match.
if (count($split) > 1) {
// Real phrase. We'll have to verify it against the dataset.
$query->enable_part("{$type}_search_dataset");
}
// Add phrase match conditions.
$query->set_current_part("{$type}_search_dataset");
$query->add_where("{$type}_search_dataset.data LIKE '%% %s %%'", $this->_phrase);
$query->set_current_part(); // Back to default part.
}
}
}
/**
* The keyword OR category.
*/
class faceted_search_keyword_or_category extends faceted_search_keyword_category {
var $_words = array();
/**
* Constructor.
*
* @param $words
* Array containing the words to search.
*/
function faceted_search_keyword_or_category($words) {
$this->_words = $words;
}
/**
* Return the label for this category.
*
* @param $html
* TRUE when HTML is allowed in the label, FALSE otherwise.
*/
function get_label($html = FALSE) {
return $this->check_label(theme('faceted_search_keyword_or_label', $this->_words), $html);
}
/**
* Return the search text for this category.
*/
function get_text() {
return implode(' OR ', $this->_words);
}
/**
* Append keywords used by this category into the specified array.
*/
function get_keywords(&$keywords) {
$keywords = array_merge($keywords, $this->_words);
}
/**
* Return the weight of this category, for sorting purposes.
*/
function get_weight() {
return 2;
}
/**
* Inject components into the query for selecting nodes matching this category.
*
* @param $query
* Query to inject the components into.
* @param $words
* Array keyed by search index type, each element being an array of positive
* words to lookup for that index type. This method should insert any words
* it cares about.
* @param $matches
* Minimum number of words that should match in query results for each index type.
* @param $type
* Type of search index entry to be searched.
*/
function build_results_query(&$query, &$words, &$matches, $type) {
$where = '';
$where_args = array();
foreach ($this->_words as $word) {
if (($word = $this->check_word($word)) && !isset($words[$type][$word])) {
$words[$type][$word] = $word;
if (!empty($where)) {
$where .= ' OR ';
}
$where .= "{$type}_search_dataset.data LIKE '%% %s %%'";
$where_args[] = $word;
}
}
if (!empty($where)) {
$matches[$type]++;
// Matches will have to be checked against the dataset.
$query->enable_part("{$type}_search_dataset");
$query->set_current_part("{$type}_search_dataset");
array_unshift($where_args, $where);
call_user_func_array(array(&$query, 'add_where'), $where_args);
$query->set_current_part(); // Back to default part.
}
}
}
/**
* The keyword NOT category.
*/
class faceted_search_keyword_not_category extends faceted_search_keyword_category {
var $_word = '';
/**
* Constructor.
*
* @param $word
* String containing the word to exclude from the search.
*/
function faceted_search_keyword_not_category($word) {
$this->_word = $word;
}
/**
* Return the label for this category.
*
* @param $html
* TRUE when HTML is allowed in the label, FALSE otherwise.
*/
function get_label($html = FALSE) {
return $this->check_label(theme('faceted_search_keyword_not_label', $this->_word), $html);
}
/**
* Return the search text for this operator.
*/
function get_text() {
return '-'. $this->_word;
}
/**
* Return the weight of this category, for sorting purposes.
*/
function get_weight() {
return 3;
}
/**
* Inject components into the query for selecting nodes matching this category.
*
* @param $query
* Query to inject the components into.
* @param $words
* Array keyed by search index type, each element being an array of positive
* words to lookup for that index type. This method should insert any words
* it cares about.
* @param $matches
* Minimum number of words that should match in query results for each index type.
* @param $type
* Type of search index entry to be searched.
*/
function build_results_query(&$query, &$words, &$matches, $type) {
if ($word = $this->check_word($this->_word)) {
// This is a negative word; do not insert it, but mark the type as used.
if (!isset($words[$type])) {
$words[$type] = array();
}
// Negative words are checked against the dataset.
$query->enable_part("{$type}_search_dataset");
$query->set_current_part("{$type}_search_dataset");
$query->add_where("{$type}_search_dataset.data NOT LIKE '%% %s %%'", $word);
$query->set_current_part(); // Back to default part.
}
}
}
/**
* The filter for keyword search.
*
* Note: For keyword filters, the key corresponds to the type of search index
* entry, and the id is always 'keyword'.
*/
class faceted_search_keyword_filter extends faceted_search_filter {
var $_label = ''; // Label of the field.
/**
* Constructor.
*
* @param $type
* Type of the search index entries corresponding to the field.
* @param $label
* Label of the field.
* @param $category
* Active category of the field.
*/
function faceted_search_keyword_filter($type, $label, $category = NULL) {
parent::faceted_search_filter($type, isset($category) ? array($category) : array());
$this->_label = $label;
}
/**
* Returns the id of this filter.
*/
function get_id() {
return 'keyword';
}
/**
* Return the search text corresponding to this filter.
*/
function get_text() {
if ($category = $this->get_active_category()) {
return $category->get_text();
}
return '';
}
/**
* Return the label of this filter. This method is responsible for ensuring
* adequate security filtering.
*/
function get_label() {
return check_plain($this->_label);
}
/**
* Append keywords used by this filter into the specified array.
*/
function get_keywords(&$keywords) {
if ($category = $this->get_active_category()) {
$category->get_keywords($keywords);
}
}
/**
* Inject components into the query for selecting nodes matching this filter.
*
* @param $query
* Query to inject the components into.
* @param $words
* Array keyed by search index type, each element being an array of positive
* words to lookup for that index type. This method should insert any words
* it cares about.
* @param $matches
* Minimum number of words that should match in query results for each index type.
*/
function build_results_query(&$query, &$words, &$matches) {
if ($category = $this->get_active_category()) {
$category->build_results_query($query, $words, $matches, $this->get_key());
}
}
}
/**
* This class stores and processes data related to a search.
*/
class faceted_search {
// TODO: Remove the '_' prefix from data members. These are not so convenient
// for working with the schema.
/**
* The environment id for this search. Each search environment has its own
* settings which make it possible to use multiple distinct search
* interfaces. It is this id that allows to select the proper settings.
*/
var $env_id = 0;
/**
* The full, unprocessed search text.
*/
var $_text = '';
/**
* An array with all keywords found in the search text.
*/
var $_keywords = array();
/**
* Name of the temporary results table. While it exists, this table can be
* queried for various purposes, such as building the search interface.
*/
var $_results_table = '';
/**
* Number of results in the results table. May be used only after a call to
* execute().
*/
var $_results_count = 0;
/**
* Flag to indicate whether the search has been executed.
*/
var $_ready = FALSE;
/**
* Collection of filters currently used by this search.
*/
var $_filters = array();
/**
* Constructor. Initialize the search environment.
*
* @param $record
* Optional for this environment, as fetched from the database. Defaults to
* NULL (for new environment).
*/
function faceted_search($record = NULL) {
// Assign default settings, ensuring that all "blanks" are properly filled.
$this->init();
if (isset($record)) {
$this->init_from_record($record);
}
}
/**
* Initialize this search environment with default settings.
*/
function init() {
$this->name = '';
$this->description = '';
$this->settings['title'] = t('Search');
$this->settings['ignore_status'] = FALSE;
$this->settings['types'] = array();
// Provide other modules an opportunity to add their own default settings.
$hook = 'faceted_search_init';
foreach (module_implements($hook) as $module) {
$function = $module .'_'. $hook;
$function($this);
}
}
/**
* Assign this search environment's settings from a record fetched from the
* database. Existing settings will be overwritten only if they are present in
* the record.
*
* @param $record
* Optional for this environment, as fetched from the database.
*/
function init_from_record($record) {
if (isset($record->settings)) {
// The schema has this field serialized.
$settings = unserialize($record->settings);
if (is_array($settings)) {
// Load the settings from the record while preserving any default
// settings that are not present in the record.
$this->settings = $settings + $this->settings;
}
unset($record->settings);
}
// Load the remaining data from the record.
foreach ($record as $key => $value) {
$this->$key = $value;
}
}
/**
* Return the original search text of this search (i.e. the text that was
* passed to the constructor).
*/
function get_text() {
return $this->_text;
}
/**
* Return an array with keywords used in the search.
*/
function get_keywords() {
return $this->_keywords;
}
/**
* Return the filters used by this search.
*/
function get_filters() {
return $this->_filters;
}
/**
* Return the specified filter.
*/
function get_filter($index) {
return $this->_filters[$index];
}
/**
* Return the index of a filter given its key and id.
*/
function get_filter_by_id($key, $id) {
foreach ($this->_filters as $index => $filter) {
if ($filter->get_key() == $key && $filter->get_id() == $id) {
return array($index, $filter);
}
}
}
/**
* Prepare the complete search environment (with its filters), parsing the
* given search text. Requires that an env_id has been assigned previously.
*
* @param $text
* Optional search text. Defaults to the empty string.
* @return
* TRUE is the search environment could be successfully built.
*/
function prepare($text = '') {
if (!$this->env_id) {
return FALSE;
}
$this->_text = $text;
$this->_results_table = 'temp_faceted_search_results_'. $this->env_id;
// Load settings for all enabled filters in this search environment.
$all_filter_settings = faceted_search_load_filter_settings($this);
// Make a selection with all enabled filters.
$selection = faceted_search_get_filter_selection($all_filter_settings);