BxBaseStudioModule.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 DolphinView Dolphin Studio Representation classes
  7. * @ingroup DolphinStudio
  8. * @{
  9. */
  10. bx_import('BxDolStudioModule');
  11. class BxBaseStudioModule extends BxDolStudioModule
  12. {
  13. protected $aMenuItems = array(
  14. array('name' => BX_DOL_STUDIO_MOD_TYPE_SETTINGS, 'icon' => 'cogs', 'title' => '_adm_lmi_cpt_settings')
  15. );
  16. function __construct($sModule = "", $sPage = "")
  17. {
  18. parent::__construct($sModule, $sPage);
  19. }
  20. function getPageCss()
  21. {
  22. return array_merge(parent::getPageCss(), array('module.css'));
  23. }
  24. function getPageJs()
  25. {
  26. return array_merge(parent::getPageJs(), array('settings.js', 'module.js'));
  27. }
  28. function getPageJsObject()
  29. {
  30. return 'oBxDolStudioModule';
  31. }
  32. function getPageCaption()
  33. {
  34. $oTemplate = BxDolStudioTemplate::getInstance();
  35. $aTmplVars = array(
  36. 'js_object' => $this->getPageJsObject(),
  37. 'content' => parent::getPageCaption(),
  38. );
  39. return $oTemplate->parseHtmlByName('mod_page_caption.html', $aTmplVars);
  40. }
  41. function getPageAttributes()
  42. {
  43. if((int)$this->aModule['enabled'] == 0)
  44. return 'style="display:none"';
  45. return parent::getPageAttributes();
  46. }
  47. function getPageMenu($aMenu = array(), $aMarkers = array())
  48. {
  49. $sJsObject = $this->getPageJsObject();
  50. $aMenu = array();
  51. foreach($this->aMenuItems as $aItem)
  52. $aMenu[] = array(
  53. 'name' => $aItem['name'],
  54. 'icon' => $aItem['icon'],
  55. 'link' => isset($aItem['link']) ? $aItem['link'] : BX_DOL_URL_STUDIO . 'module.php?name=' . $this->sModule . '&page=' . $aItem['name'],
  56. 'title' => _t($aItem['title']),
  57. 'selected' => $aItem['name'] == $this->sPage
  58. );
  59. return parent::getPageMenu($aMenu);
  60. }
  61. function getPageCode($bHidden = false)
  62. {
  63. $sMethod = 'get' . ucfirst($this->sPage);
  64. if(!method_exists($this, $sMethod))
  65. return '';
  66. if((int)$this->aModule['enabled'] != 1)
  67. BxDolStudioTemplate::getInstance()->addInjection('injection_bg_style', 'text', ' bx-std-page-bg-empty');
  68. return $this->$sMethod();
  69. }
  70. protected function getSettings()
  71. {
  72. $oTemplate = BxDolStudioTemplate::getInstance();
  73. bx_import('BxTemplStudioSettings');
  74. $oPage = new BxTemplStudioSettings($this->sModule);
  75. $aTmplVars = array(
  76. 'bx_repeat:blocks' => $oPage->getPageCode(),
  77. );
  78. return $oTemplate->parseHtmlByName('module.html', $aTmplVars);
  79. }
  80. }
  81. /** @} */