BxDolStudioPolyglot.php 3.2 KB

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