1
0

BxBaseModNotificationsTemplate.php 3.3 KB

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