BxDolStudioPolyglot.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_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. //--- Check actions ---//
  26. if(($sAction = bx_get('pgt_action')) !== false) {
  27. $sAction = bx_process_input($sAction);
  28. bx_import('BxDolStudioLanguagesUtils');
  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. }
  71. /** @} */