1
0

BxBaseModNotificationsTemplate.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 getAddedCss($sType = '', $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 getAddedJs($sType = '', $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($sType = '', $bDynamic = false)
  38. {
  39. return $this->getAddedCss($sType, $bDynamic) . $this->getAddedJs($sType, $bDynamic);
  40. }
  41. public function getJsCode($sType, $aParams = array(), $bWrap = true, $bDynamic = false)
  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. return $this->getCssJs($sType, $bDynamic) . parent::getJsCode($sType, $aParams, $bWrap);
  51. }
  52. public function getUnit(&$aEvent, $aBrowseParams = array())
  53. {
  54. return '';
  55. }
  56. function unit($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html')
  57. {
  58. $this->getCssJs();
  59. if($sTemplateName == 'unit.html')
  60. return $this->getUnit($aData);
  61. $oModule = $this->getModule();
  62. $CNF = &$this->_oConfig->CNF;
  63. if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->isAllowedView($aData))) {
  64. $aVars = array (
  65. 'summary' => $sMsg,
  66. );
  67. return $this->parseHtmlByName('unit_private.html', $aVars);
  68. }
  69. list($sAuthorName, $sAuthorUrl, $sAuthorIcon) = $oModule->getUserInfo($aData['object_id']);
  70. $bAuthorIcon = !empty($sAuthorIcon);
  71. // generate html
  72. $aVars = array (
  73. 'id' => $aData['id'],
  74. 'author' => $sAuthorName,
  75. 'author_url' => $sAuthorUrl,
  76. 'title' => bx_process_output($aData['title'], BX_DATA_HTML),
  77. 'item_url' => $this->_oConfig->getItemViewUrl($aData),
  78. 'item_date' => bx_time_js($aData['date'], BX_FORMAT_DATE),
  79. 'module_name' => _t($CNF['T']['txt_sample_single_ext']),
  80. 'ts' => $aData['date'],
  81. 'bx_if:show_icon' => array(
  82. 'condition' => $bAuthorIcon,
  83. 'content' => array(
  84. 'author_icon' => $sAuthorIcon
  85. )
  86. ),
  87. 'bx_if:show_icon_empty' => array(
  88. 'condition' => !$bAuthorIcon,
  89. 'content' => array()
  90. ),
  91. );
  92. return $this->parseHtmlByName($sTemplateName, $aVars);
  93. }
  94. }
  95. /** @} */