BxDolStudioPolyglot.php 2.6 KB

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