1
0

BxBaseStudioModule.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioModule extends BxDolStudioModule
  11. {
  12. protected $oHelper;
  13. protected $aMenuItems = array(
  14. BX_DOL_STUDIO_MOD_TYPE_SETTINGS => array('name' => BX_DOL_STUDIO_MOD_TYPE_SETTINGS, 'icon' => 'cogs', 'title' => '_adm_lmi_cpt_settings')
  15. );
  16. protected $sTmplNamePopupSettings;
  17. protected $sTmplNamePopupConfirmUninstall;
  18. function __construct($sModule, $mixedPageName, $sPage = "")
  19. {
  20. parent::__construct($sModule, $mixedPageName, $sPage);
  21. $this->oHelper = BxTemplStudioModules::getInstance();
  22. $this->sTmplNamePopupSettings = 'mod_popup_settings.html';
  23. $this->sTmplNamePopupConfirmUninstall = 'mod_popup_confirm_uninstall.html';
  24. }
  25. function getPageCss()
  26. {
  27. return array_merge(parent::getPageCss(), $this->oHelper->getCss());
  28. }
  29. function getPageJs()
  30. {
  31. return array_merge(parent::getPageJs(), $this->oHelper->getJs());
  32. }
  33. function getPageJsClass()
  34. {
  35. return $this->oHelper->getJsClass();
  36. }
  37. function getPageJsObject()
  38. {
  39. return $this->oHelper->getJsObject();
  40. }
  41. function getPageJsCode($aParams = array(), $mixedWrap = true)
  42. {
  43. return $this->oHelper->getJsCode($aParams, $mixedWrap);
  44. }
  45. function getPageCaption()
  46. {
  47. return BxDolStudioTemplate::getInstance()->parseHtmlByName('mod_page_caption.html', array(
  48. 'js_object' => $this->getPageJsObject(),
  49. 'content' => parent::getPageCaption(),
  50. 'js_code' => $this->getPageJsCode()
  51. ));
  52. }
  53. function getPageAttributes()
  54. {
  55. if((int)$this->aModule['enabled'] == 0)
  56. return 'style="display:none"';
  57. return parent::getPageAttributes();
  58. }
  59. function getPageMenu($aMenu = array(), $aMarkers = array())
  60. {
  61. $sJsObject = $this->getPageJsObject();
  62. $aMenu = array();
  63. foreach($this->aMenuItems as $sName => $aItem)
  64. $aMenu[] = array(
  65. 'name' => $sName,
  66. 'icon' => $aItem['icon'],
  67. 'link' => isset($aItem['link']) ? $aItem['link'] : bx_append_url_params($this->sManageUrl, array('page' => $sName)),
  68. 'title' => _t(!empty($aItem['title']) ? $aItem['title'] : $aItem['caption']),
  69. 'selected' => $sName == $this->sPage
  70. );
  71. return parent::getPageMenu($aMenu);
  72. }
  73. protected function getSettings()
  74. {
  75. $oOptions = new BxTemplStudioOptions($this->sModule);
  76. $this->aPageCss = array_merge($this->aPageCss, $oOptions->getCss());
  77. $this->aPageJs = array_merge($this->aPageJs, $oOptions->getJs());
  78. return BxDolStudioTemplate::getInstance()->parseHtmlByName('module.html', array(
  79. 'content' => $oOptions->getCode(),
  80. ));
  81. }
  82. protected function getPopupSettings($sPage, $iWidgetId)
  83. {
  84. $sActions = $this->getPageActions($iWidgetId);
  85. if(empty($sActions))
  86. return '';
  87. $sPrefix = 'bx-std-mod-popup-settings';
  88. $sName = $sPrefix . '-' . $sPage;
  89. $sContent = BxDolStudioTemplate::getInstance()->parseHtmlByName($this->sTmplNamePopupSettings, array(
  90. 'content' => $sActions
  91. ));
  92. return BxTemplStudioFunctions::getInstance()->transBox($sName, array(
  93. 'wrapper_class' => $sPrefix . '-wrapper',
  94. 'content' => $sContent
  95. ));
  96. }
  97. protected function getPopupConfirmUninstall($iWidgetId, &$aModule)
  98. {
  99. $sJsObject = $this->getPageJsObject();
  100. $sName = 'bx-std-mod-popup-confirm';
  101. $sContent = BxDolStudioTemplate::getInstance()->parseHtmlByName($this->sTmplNamePopupConfirmUninstall, array(
  102. 'content' => _t('_adm_' . $this->sLangPrefix . '_cnf_uninstall', $aModule['title']),
  103. 'click' => $sJsObject . ".uninstall('" . $aModule['name'] . "', " . $iWidgetId . ", 1)"
  104. ));
  105. return BxTemplStudioFunctions::getInstance()->transBox($sName, $sContent);
  106. }
  107. }
  108. /** @} */