1
0

BxBaseStudioModule.php 2.8 KB

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