luceneapi_node.inc 809 B

12345678910111213141516171819202122232425262728293031
  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. */
  16. function _custom_search_lucenapi_search($variables) {
  17. $type = 'search/' . variable_get('luceneapi:default_search', 0) . '/' . $variables['keywords'];
  18. $keys = array();
  19. if (count($variables['types']) && !in_array('all', $variables['types'])) {
  20. foreach ($variables['types'] as $t) $keys["type[$t]"] = $t;
  21. }
  22. if (module_exists('taxonomy') && count($variables['terms'])) {
  23. foreach ($variables['terms'] as $t) $keys["category[$t]"] = $t;
  24. }
  25. return array('path' => $type, 'query' => $keys);
  26. }