BxDolStudioModules.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaStudio UNA Studio
  7. * @{
  8. */
  9. class BxDolStudioModules extends BxDol
  10. {
  11. protected $sJsObject;
  12. protected $sLangPrefix;
  13. protected $sTemplPrefix;
  14. function __construct()
  15. {
  16. parent::__construct();
  17. $this->oDb = new BxDolStudioModulesQuery();
  18. $this->sJsObject = 'oBxDolStudioModules';
  19. $this->sLangPrefix = 'mod';
  20. $this->sTemplPrefix = 'mod';
  21. $this->sParamPrefix = 'mod';
  22. }
  23. function serviceGetActions($aWidget)
  24. {
  25. return array(
  26. array (
  27. 'caption' => _t('_adm_txt_uninstall'),
  28. 'link' => '',
  29. 'click' => $this->sJsObject . ".uninstall(" . $aWidget['id'] . ", '" . $aWidget['page_name'] . "', 0)",
  30. 'icon' => 'times-circle'
  31. )
  32. );
  33. }
  34. function processActions()
  35. {
  36. if(($sAction = bx_get($this->sParamPrefix . '_action')) !== false) {
  37. $sAction = bx_process_input($sAction);
  38. $aResult = array('code' => 1, 'message' => _t('_adm_' . $this->sLangPrefix . '_err_cannot_process_action'));
  39. switch($sAction) {
  40. case 'uninstall':
  41. $sPageName = bx_process_input(bx_get($this->sParamPrefix . '_page_name'));
  42. if(empty($sPageName))
  43. break;
  44. $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sPageName);
  45. if(empty($aModule) || !is_array($aModule))
  46. break;
  47. if(($iWidgetId = (int)bx_get($this->sParamPrefix . '_widget_id')) != 0 && (int)bx_get($this->sParamPrefix . '_confirmed') != 1) {
  48. $aResult['message'] = $this->getPopupConfirm($iWidgetId, $aModule);
  49. break;
  50. }
  51. $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall', array('html_response' => true));
  52. if(!empty($aResult['message']))
  53. $aResult['message'] = $this->getPopupResult($aResult['message']);
  54. break;
  55. }
  56. if(!empty($aResult['message']))
  57. $aResult['message'] = BxTemplStudioFunctions::getInstance()->transBox('', $aResult['message']);
  58. echo json_encode($aResult);
  59. exit;
  60. }
  61. }
  62. }
  63. /** @} */