BxBaseModNotificationsTemplate.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 BaseNotifications Base classes for Notifications like modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModNotificationsTemplate extends BxBaseModGeneralTemplate
  12. {
  13. function __construct(&$oConfig, &$oDb)
  14. {
  15. parent::__construct($oConfig, $oDb);
  16. }
  17. public function addLocationBase()
  18. {
  19. parent::addLocationBase();
  20. $this->addLocation('mod_notifications', BX_DIRECTORY_PATH_MODULES . 'base' . DIRECTORY_SEPARATOR . 'notifications' . DIRECTORY_SEPARATOR, BX_DOL_URL_MODULES . 'base/notifications/');
  21. }
  22. public function getAddedCss($sType = '', $bDynamic = false)
  23. {
  24. $mixedResult = $this->addCss(array(
  25. 'view.css',
  26. 'view-media-tablet.css',
  27. 'view-media-desktop.css',
  28. ), $bDynamic);
  29. if($bDynamic)
  30. return $mixedResult;
  31. }
  32. public function getAddedJs($sType = '', $bDynamic = false)
  33. {
  34. $mixedResult = $this->addJs(array(
  35. 'jquery.anim.js',
  36. 'main.js',
  37. 'view.js',
  38. ), $bDynamic);
  39. if($bDynamic)
  40. return $mixedResult;
  41. }
  42. public function getCssJs($sType = '', $bDynamic = false)
  43. {
  44. return $this->getAddedCss($sType, $bDynamic) . $this->getAddedJs($sType, $bDynamic);
  45. }
  46. public function getJsCode($sType, $aParams = array(), $bWrap = true, $bDynamic = false)
  47. {
  48. $oModule = $this->getModule();
  49. $aParams = array_merge(array(
  50. 'iOwnerId' => $oModule->_iOwnerId,
  51. 'sAnimationEffect' => $this->_oConfig->getAnimationEffect(),
  52. 'iAnimationSpeed' => $this->_oConfig->getAnimationSpeed(),
  53. 'aHtmlIds' => $this->_oConfig->getHtmlIds($sType)
  54. ), $aParams);
  55. return $this->getCssJs($sType, $bDynamic) . parent::getJsCode($sType, $aParams, $bWrap);
  56. }
  57. public function getUnit(&$aEvent, $aBrowseParams = array())
  58. {
  59. return '';
  60. }
  61. function unit($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html')
  62. {
  63. $this->getCssJs();
  64. if($sTemplateName == 'unit.html')
  65. return $this->getUnit($aData);
  66. $oModule = $this->getModule();
  67. $CNF = &$this->_oConfig->CNF;
  68. if ($isCheckPrivateContent && !$oModule->isAllowedView($aData))
  69. return $this->parseHtmlByName('unit_private.html', array (
  70. 'summary' => _t('_sys_access_denied_to_private_content'),
  71. ));
  72. list($sAuthorName, $sAuthorUrl, $sAuthorIcon) = $oModule->getUserInfo($aData['object_id']);
  73. $bAuthorIcon = !empty($sAuthorIcon);
  74. // generate html
  75. $aVars = array (
  76. 'id' => $aData['id'],
  77. 'author' => $sAuthorName,
  78. 'author_url' => $sAuthorUrl,
  79. 'title' => bx_process_output($aData['title'], BX_DATA_HTML),
  80. 'item_url' => $this->_oConfig->getItemViewUrl($aData),
  81. 'item_date' => bx_time_js($aData['date'], BX_FORMAT_DATE),
  82. 'module_name' => _t($CNF['T']['txt_sample_single_ext']),
  83. 'ts' => $aData['date'],
  84. 'bx_if:show_icon' => array(
  85. 'condition' => $bAuthorIcon,
  86. 'content' => array(
  87. 'author_icon' => $sAuthorIcon
  88. )
  89. ),
  90. 'bx_if:show_icon_empty' => array(
  91. 'condition' => !$bAuthorIcon,
  92. 'content' => array()
  93. ),
  94. );
  95. return $this->parseHtmlByName($sTemplateName, $aVars);
  96. }
  97. }
  98. /** @} */