connector.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. $webActions = [
  3. 'web/autosuggestions'
  4. ];
  5. if (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], $webActions)) {
  6. define('MODX_REQP', false);
  7. }
  8. require_once dirname(dirname(dirname(__DIR__))) . '/config.core.php';
  9. require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
  10. require_once MODX_CONNECTORS_PATH . 'index.php';
  11. if (in_array($_REQUEST['action'], $webActions, true)) {
  12. if ($modx->user->hasSessionContext($modx->context->get('key'))) {
  13. $_SERVER['HTTP_MODAUTH'] = $_SESSION["modx.{$modx->context->get('key')}.user.token"];
  14. } else {
  15. $_SESSION["modx.{$modx->context->get('key')}.user.token"] = 0;
  16. $_SERVER['HTTP_MODAUTH'] = 0;
  17. }
  18. $_REQUEST['HTTP_MODAUTH'] = $_SERVER['HTTP_MODAUTH'];
  19. }
  20. $instance = $modx->getService(
  21. 'simplesearch',
  22. 'SimpleSearch',
  23. $modx->getOption(
  24. 'simplesearch.core_path',
  25. null,
  26. $modx->getOption('core_path') . 'components/simplesearch/'
  27. ) . 'model/simplesearch/'
  28. );
  29. if ($instance instanceof SimpleSearch) {
  30. $modx->request->handleRequest([
  31. 'processors_path' => $instance->config['processors_path'],
  32. 'location' => ''
  33. ]);
  34. }