BxDolStudioPolyglot.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentStudio Trident 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_DEFAULT', BX_DOL_STUDIO_PGT_TYPE_SETTINGS);
  13. class BxDolStudioPolyglot extends BxTemplStudioPage
  14. {
  15. protected $sPage;
  16. function __construct($sPage = "")
  17. {
  18. parent::__construct('polyglot');
  19. $this->oDb = new BxDolStudioPolyglotQuery();
  20. $this->sPage = BX_DOL_STUDIO_PGT_TYPE_DEFAULT;
  21. if(is_string($sPage) && !empty($sPage))
  22. $this->sPage = $sPage;
  23. }
  24. public function init()
  25. {
  26. if(($sAction = bx_get('pgt_action')) === false)
  27. return;
  28. $sAction = bx_process_input($sAction);
  29. $oLanguages = BxDolStudioLanguagesUtils::getInstance();
  30. $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
  31. switch($sAction) {
  32. case 'get-page-by-type':
  33. $sValue = bx_process_input(bx_get('pgt_value'));
  34. if(empty($sValue))
  35. break;
  36. $this->sPage = $sValue;
  37. $aResult = array('code' => 0, 'content' => $this->getPageCode());
  38. break;
  39. /*
  40. * Available URL params:
  41. * pgt_action = recompile - action name
  42. * pgt_language - ID or name(en, ru, etc) of language.
  43. */
  44. case 'recompile':
  45. $sLanguage = bx_process_input(bx_get('pgt_language'));
  46. if($oLanguages->compileLanguage($sLanguage))
  47. $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_recompiled'));
  48. else
  49. $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_recompile_lang'));
  50. break;
  51. /*
  52. * Available URL params:
  53. * pgt_action = restore - action name
  54. * pgt_language - ID or name(en, ru, etc) of language.
  55. * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
  56. */
  57. case 'restore':
  58. $sLanguage = bx_process_input(bx_get('pgt_language'));
  59. $sModule = bx_process_input(bx_get('pgt_module'));
  60. if($oLanguages->restoreLanguage($sLanguage, $sModule))
  61. $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_restored'));
  62. else
  63. $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_restore_lang'));
  64. break;
  65. }
  66. echo json_encode($aResult);
  67. exit;
  68. }
  69. }
  70. /** @} */