luceneapi_node.inc 835 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * @file
  4. * Path generation for Lucene API Search.
  5. *
  6. * Available vars:
  7. * $keywords: user input
  8. * $types: content types (machine names[])
  9. * $terms: taxonomy terms (tids[])
  10. * $keys: complete search phrase, as core would have done it
  11. *
  12. * To return:
  13. * the complete search path
  14. */
  15. function _custom_search_lucenapi_search($variables) {
  16. $type = 'search/' . variable_get('luceneapi:default_search', 0) . '/' . $variables['keywords'];
  17. $keys = array();
  18. if (count($variables['types']) && !in_array('all', $variables['types'])) {
  19. foreach ($variables['types'] as $t) {
  20. $keys["type[$t]"] = $t;
  21. }
  22. }
  23. if (module_exists('taxonomy') && count($variables['terms'])) {
  24. foreach ($variables['terms'] as $t) {
  25. $keys["category[$t]"] = $t;
  26. }
  27. }
  28. return array('path' => $type, 'query' => $keys);
  29. }