BxDolStudioPolyglot.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 UnaStudio UNA Studio
  7. * @{
  8. */
  9. define('BX_DOL_STUDIO_PGT_TYPE_SETTINGS', 'settings');
  10. define('BX_DOL_STUDIO_PGT_TYPE_KEYS', 'keys');
  11. define('BX_DOL_STUDIO_PGT_TYPE_ETEMPLATES', 'etemplates');
  12. define('BX_DOL_STUDIO_PGT_TYPE_ETEMPLATES_HF', 'etemplates_hf');
  13. define('BX_DOL_STUDIO_PGT_TYPE_DEFAULT', BX_DOL_STUDIO_PGT_TYPE_SETTINGS);
  14. class BxDolStudioPolyglot extends BxTemplStudioPage
  15. {
  16. protected $sPage;
  17. function __construct($sPage = "")
  18. {
  19. parent::__construct('polyglot');
  20. $this->oDb = new BxDolStudioPolyglotQuery();
  21. $this->sPage = BX_DOL_STUDIO_PGT_TYPE_DEFAULT;
  22. if(is_string($sPage) && !empty($sPage))
  23. $this->sPage = $sPage;
  24. }
  25. public function init()
  26. {
  27. if(($sAction = bx_get('pgt_action')) === false)
  28. return;
  29. $sAction = bx_process_input($sAction);
  30. $oLanguages = BxDolStudioLanguagesUtils::getInstance();
  31. $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
  32. switch($sAction) {
  33. case 'get-page-by-type':
  34. $sValue = bx_process_input(bx_get('pgt_value'));
  35. if(empty($sValue))
  36. break;
  37. $this->sPage = $sValue;
  38. $aResult = array('code' => 0, 'content' => $this->getPageCode());
  39. break;
  40. /*
  41. * Available URL params:
  42. * pgt_action = recompile - action name
  43. * pgt_language - ID or name(en, ru, etc) of language.
  44. */
  45. case 'recompile':
  46. $sLanguage = bx_process_input(bx_get('pgt_language'));
  47. if($oLanguages->compileLanguage($sLanguage))
  48. $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_recompiled'));
  49. else
  50. $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_recompile_lang'));
  51. break;
  52. /*
  53. * Available URL params:
  54. * pgt_action = restore - action name
  55. * pgt_language - ID or name(en, ru, etc) of language.
  56. * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
  57. */
  58. case 'restore':
  59. $sLanguage = bx_process_input(bx_get('pgt_language'));
  60. $sModule = bx_process_input(bx_get('pgt_module'));
  61. if($oLanguages->restoreLanguage($sLanguage, $sModule))
  62. $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_restored'));
  63. else
  64. $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_restore_lang'));
  65. break;
  66. }
  67. echo json_encode($aResult);
  68. exit;
  69. }
  70. public function submitEtemplatesHf(&$oForm)
  71. {
  72. $sUnsubscribe = "{unsubscribe}";
  73. $sHeader = $oForm->getCleanValue('et_hf_header');
  74. $sFooter = $oForm->getCleanValue('et_hf_footer');
  75. if(strpos($sHeader, $sUnsubscribe) === false && strpos($sFooter, $sUnsubscribe) === false)
  76. return $this->getJsResult('_adm_pgt_err_et_hf_save_unsubscribe');
  77. $bResult = false;
  78. $bResult |= $this->oDb->setParam('site_email_html_template_header', $sHeader);
  79. $bResult |= $this->oDb->setParam('site_email_html_template_footer', $sFooter);
  80. if(!$bResult)
  81. return $this->getJsResult('_adm_pgt_err_et_hf_save');
  82. return $this->getJsResult('_adm_pgt_scs_et_hf_save', true, true, BX_DOL_URL_STUDIO . 'polyglot.php?page=' . BX_DOL_STUDIO_PGT_TYPE_ETEMPLATES_HF);
  83. }
  84. }
  85. /** @} */