111.include.cache.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Show the search form
  4. *
  5. * @var modX $modx
  6. * @var array $scriptProperties
  7. * @package simplesearch
  8. */
  9. require_once $modx->getOption(
  10. 'simplesearch.core_path',
  11. null,
  12. $modx->getOption('core_path') . 'components/simplesearch/'
  13. ) . 'model/simplesearch/simplesearch.class.php';
  14. $search = new SimpleSearch($modx, $scriptProperties);
  15. /* Setup default options. */
  16. $scriptProperties = array_merge(
  17. array(
  18. 'tpl' => 'SearchForm',
  19. 'method' => 'get',
  20. 'searchIndex' => 'search',
  21. 'toPlaceholder' => false,
  22. 'landing' => $modx->resource->get('id'),
  23. ), $scriptProperties);
  24. if (empty($scriptProperties['landing'])) {
  25. $scriptProperties['landing'] = $modx->resource->get('id');
  26. }
  27. /* If get value already exists, set it as default. */
  28. $searchValue = isset($_REQUEST[$scriptProperties['searchIndex']]) ? $_REQUEST[$scriptProperties['searchIndex']] : '';
  29. $searchValues = explode(' ', $searchValue);
  30. array_map(array($modx, 'sanitizeString'), $searchValues);
  31. $searchValue = implode(' ', $searchValues);
  32. $placeholders = array(
  33. 'method' => $scriptProperties['method'],
  34. 'landing' => $scriptProperties['landing'],
  35. 'searchValue' => strip_tags(htmlspecialchars($searchValue, ENT_QUOTES, 'UTF-8')),
  36. 'searchIndex' => $scriptProperties['searchIndex'],
  37. );
  38. $output = $search->getChunk($scriptProperties['tpl'], $placeholders);
  39. return $search->output($output, $scriptProperties['toPlaceholder']);
  40. return;