BxBaseModNotificationsTemplate.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 TridentModules
  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. $sBaseUri = $this->_oConfig->getBaseUri();
  34. $sJsClass = $this->_oConfig->getJsClass($sType);
  35. $sJsObject = $this->_oConfig->getJsObject($sType);
  36. $aParams = array_merge(array(
  37. 'iOwnerId' => $oModule->_iOwnerId,
  38. 'sAnimationEffect' => $this->_oConfig->getAnimationEffect(),
  39. 'iAnimationSpeed' => $this->_oConfig->getAnimationSpeed(),
  40. 'aHtmlIds' => $this->_oConfig->getHtmlIds($sType)
  41. ), $aParams);
  42. $this->getCssJs();
  43. return parent::getJsCode($sType, $aParams, $bWrap);
  44. }
  45. public function getPost(&$aEvent, $aBrowseParams = array())
  46. {
  47. return '';
  48. }
  49. function unit($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html')
  50. {
  51. $this->getCssJs();
  52. if($sTemplateName == 'unit.html')
  53. return $this->getPost($aData);
  54. $oModule = $this->getModule();
  55. $CNF = &$this->_oConfig->CNF;
  56. if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->isAllowedView($aData))) {
  57. $aVars = array (
  58. 'summary' => $sMsg,
  59. );
  60. return $this->parseHtmlByName('unit_private.html', $aVars);
  61. }
  62. list($sAuthorName, $sAuthorUrl, $sAuthorIcon) = $oModule->getUserInfo($aData['object_id']);
  63. $bAuthorIcon = !empty($sAuthorIcon);
  64. // generate html
  65. $aVars = array (
  66. 'id' => $aData['id'],
  67. 'author' => $sAuthorName,
  68. 'author_url' => $sAuthorUrl,
  69. 'title' => bx_process_output($aData['title']),
  70. 'item_url' => $this->_oConfig->getItemViewUrl($aData),
  71. 'item_date' => bx_time_js($aData['date'], BX_FORMAT_DATE),
  72. 'module_name' => _t($CNF['T']['txt_sample_single_ext']),
  73. 'ts' => $aData['date'],
  74. 'bx_if:show_icon' => array(
  75. 'condition' => $bAuthorIcon,
  76. 'content' => array(
  77. 'author_icon' => $sAuthorIcon
  78. )
  79. ),
  80. 'bx_if:show_icon_empty' => array(
  81. 'condition' => !$bAuthorIcon,
  82. 'content' => array()
  83. ),
  84. );
  85. return $this->parseHtmlByName($sTemplateName, $aVars);
  86. }
  87. }
  88. /** @} */