BxBaseModNotificationsTemplate.php 3.3 KB

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