BxElsStudioPage.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup ElasticSearch ElasticSearch
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. define('BX_DOL_STUDIO_MOD_TYPE_MANAGE', 'manage');
  12. class BxElsStudioPage extends BxTemplStudioModule
  13. {
  14. protected $_sModule;
  15. protected $_oModule;
  16. function __construct($sModule, $mixedPageName, $sPage = "")
  17. {
  18. $this->_sModule = 'bx_elasticsearch';
  19. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  20. parent::__construct($sModule, $mixedPageName, $sPage);
  21. $this->aMenuItems[BX_DOL_STUDIO_MOD_TYPE_MANAGE] = array('name' => BX_DOL_STUDIO_MOD_TYPE_MANAGE, 'icon' => 'wrench', 'title' => '_bx_elasticsearch_lmi_cpt_manage');
  22. $this->_oModule->_oTemplate->addStudioJs(array('jquery.anim.js', 'jquery.form.min.js', 'manage.js'));
  23. }
  24. protected function getManage()
  25. {
  26. $CNF = &$this->_oModule->_oConfig->CNF;
  27. $sForm = $CNF['OBJECT_FORM_MANAGE'];
  28. $sFormDisplay = $CNF['OBJECT_FORM_MANAGE_DISPLAY_INDEX'];
  29. $oForm = BxDolForm::getObjectInstance($sForm, $sFormDisplay, $this->_oModule->_oTemplate);
  30. if(!$oForm)
  31. return '';
  32. $oForm->initChecker();
  33. if($oForm->isSubmittedAndValid()) {
  34. $sIndex = $oForm->getCleanValue('index');
  35. $sType = $oForm->getCleanValue('type');
  36. if(BxDolCronQuery::getInstance()->addTransientJobService($sFormDisplay, array($this->_sModule, 'index', array($sIndex, $sType)))) {
  37. $sJsObject = $this->_oModule->_oConfig->getJsObject('manage');
  38. $sNotification = BxTemplStudioFunctions::getInstance()->inlineBox('', $this->_oModule->_oTemplate->parseHtmlByName('manage_form_result_inline.html', array(
  39. 'content' => _t('_bx_elasticsearch_msg_index_planned')
  40. )), true);
  41. $aResult = array('code' => 0, 'notification' => $sNotification, 'eval' => $sJsObject . ".onIndex(oData);");
  42. }
  43. else
  44. $aResult = array('code' => 1, 'message' => _t('_error occured'));
  45. echoJson($aResult);
  46. exit;
  47. }
  48. return $oForm->getCode();
  49. }
  50. }
  51. /** @} */