BxDolStudioModules.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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('BxDol');
  10. bx_import('BxDolStudioModulesQuery');
  11. class BxDolStudioModules extends BxDol
  12. {
  13. protected $sJsObject;
  14. protected $sLangPrefix;
  15. protected $sTemplPrefix;
  16. function __construct()
  17. {
  18. parent::__construct();
  19. $this->oDb = new BxDolStudioModulesQuery();
  20. $this->sJsObject = 'oBxDolStudioModules';
  21. $this->sLangPrefix = 'mod';
  22. $this->sTemplPrefix = 'mod';
  23. $this->sParamPrefix = 'mod';
  24. }
  25. function serviceGetActions($aWidget)
  26. {
  27. return array(
  28. array (
  29. 'caption' => _t('_adm_txt_uninstall'),
  30. 'link' => '',
  31. 'click' => $this->sJsObject . ".uninstall(" . $aWidget['id'] . ", '" . $aWidget['page_name'] . "', 0)",
  32. 'icon' => 'times-circle'
  33. )
  34. );
  35. }
  36. function processActions()
  37. {
  38. if(($sAction = bx_get($this->sParamPrefix . '_action')) !== false) {
  39. $sAction = bx_process_input($sAction);
  40. $aResult = array('code' => 1, 'message' => _t('_adm_' . $this->sLangPrefix . '_err_cannot_process_action'));
  41. switch($sAction) {
  42. case 'uninstall':
  43. $sPageName = bx_process_input(bx_get($this->sParamPrefix . '_page_name'));
  44. if(empty($sPageName))
  45. break;
  46. bx_import('BxDolModuleQuery');
  47. $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sPageName);
  48. if(empty($aModule) || !is_array($aModule))
  49. break;
  50. if(($iWidgetId = (int)bx_get($this->sParamPrefix . '_widget_id')) != 0 && (int)bx_get($this->sParamPrefix . '_confirmed') != 1) {
  51. $aResult['message'] = $this->getPopupConfirm($iWidgetId, $aModule);
  52. break;
  53. }
  54. bx_import('BxDolStudioInstallerUtils');
  55. $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall', array('html_response' => true));
  56. if(!empty($aResult['message']))
  57. $aResult['message'] = $this->getPopupResult($aResult['message']);
  58. break;
  59. }
  60. if(!empty($aResult['message'])) {
  61. bx_import('BxTemplStudioFunctions');
  62. $aResult['message'] = BxTemplStudioFunctions::getInstance()->transBox('', $aResult['message']);
  63. }
  64. echo json_encode($aResult);
  65. exit;
  66. }
  67. }
  68. }
  69. /** @} */