BxBaseModNotificationsTemplate.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 BaseNotifications Base classes for Notifications like modules
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolModuleTemplate');
  12. class BxBaseModNotificationsTemplate extends BxDolModuleTemplate
  13. {
  14. function __construct(&$oConfig, &$oDb)
  15. {
  16. parent::__construct($oConfig, $oDb);
  17. }
  18. public function getCssJs()
  19. {
  20. $this->addCss(array(
  21. 'view.css',
  22. 'view-media-tablet.css',
  23. 'view-media-desktop.css',
  24. ));
  25. $this->addJs(array(
  26. 'jquery.anim.js',
  27. 'main.js',
  28. 'view.js',
  29. ));
  30. }
  31. public function getJsCode($sType, $aRequestParams = array(), $bWrap = true)
  32. {
  33. $oModule = $this->getModule();
  34. $sBaseUri = $this->_oConfig->getBaseUri();
  35. $sJsClass = $this->_oConfig->getJsClass($sType);
  36. $sJsObject = $this->_oConfig->getJsObject($sType);
  37. $aParams = array(
  38. 'sActionUri' => $sBaseUri,
  39. 'sActionUrl' => BX_DOL_URL_ROOT . $sBaseUri,
  40. 'sObjName' => $sJsObject,
  41. 'iOwnerId' => $oModule->_iOwnerId,
  42. 'sAnimationEffect' => $this->_oConfig->getAnimationEffect(),
  43. 'iAnimationSpeed' => $this->_oConfig->getAnimationSpeed(),
  44. 'aHtmlIds' => $this->_oConfig->getHtmlIds($sType),
  45. 'oRequestParams' => !empty($aRequestParams) ? $aRequestParams : array()
  46. );
  47. $sContent = "var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode($aParams) . ");";
  48. $this->getCssJs();
  49. return !$bWrap ? $sContent : $this->_wrapInTagJsCode($sContent);
  50. }
  51. protected function getModule()
  52. {
  53. $sName = $this->_oConfig->getName();
  54. return BxDolModule::getInstance($sName);
  55. }
  56. }
  57. /** @} */