BxDolStudioModules.php 2.8 KB

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