BxDolStudioPolyglot.php 3.2 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 DolphinStudio Dolphin Studio
  7. * @{
  8. */
  9. bx_import('BxTemplStudioPage');
  10. bx_import('BxDolStudioPolyglotQuery');
  11. define('BX_DOL_STUDIO_PGT_TYPE_GENERAL', 'general');
  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_GENERAL);
  15. class BxDolStudioPolyglot extends BxTemplStudioPage {
  16. protected $sPage;
  17. function __construct($sPage = "") {
  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. //--- Check actions ---//
  24. if(($sAction = bx_get('pgt_action')) !== false) {
  25. $sAction = bx_process_input($sAction);
  26. bx_import('BxDolStudioLanguagesUtils');
  27. $oLanguages = BxDolStudioLanguagesUtils::getInstance();
  28. $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
  29. switch($sAction) {
  30. case 'get-page-by-type':
  31. $sValue = bx_process_input(bx_get('pgt_value'));
  32. if(empty($sValue))
  33. break;
  34. $this->sPage = $sValue;
  35. $aResult = array('code' => 0, 'content' => $this->getPageCode());
  36. break;
  37. /*
  38. * Available URL params:
  39. * pgt_action = recompile - action name
  40. * pgt_language - ID or name(en, ru, etc) of language.
  41. */
  42. case 'recompile':
  43. $sLanguage = bx_process_input(bx_get('pgt_language'));
  44. if($oLanguages->compileLanguage($sLanguage))
  45. $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_recompiled'));
  46. else
  47. $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_recompile_lang'));
  48. break;
  49. /*
  50. * Available URL params:
  51. * pgt_action = restore - action name
  52. * pgt_language - ID or name(en, ru, etc) of language.
  53. * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
  54. */
  55. case 'restore':
  56. $sLanguage = bx_process_input(bx_get('pgt_language'));
  57. $sModule = bx_process_input(bx_get('pgt_module'));
  58. if($oLanguages->restoreLanguage($sLanguage, $sModule))
  59. $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_restored'));
  60. else
  61. $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_restore_lang'));
  62. break;
  63. }
  64. $oJson = new Services_JSON();
  65. echo $oJson->encode($aResult);
  66. exit;
  67. }
  68. }
  69. }
  70. /** @} */