BxBaseModNotificationsTemplate.php 2.9 KB

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