BxTimelineMenuItemCounters.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Timeline Timeline
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. require_once('BxTimelineMenuItemActions.php');
  12. /**
  13. * 'Item' menu.
  14. */
  15. class BxTimelineMenuItemCounters extends BxTimelineMenuItemActions
  16. {
  17. public function __construct($aObject, $oTemplate = false)
  18. {
  19. parent::__construct($aObject, $oTemplate);
  20. $this->_sMode = self::$_sModeCounters;
  21. $this->_bShowCounters = true;
  22. $this->_aItem2CheckFunc = array_merge($this->_aItem2CheckFunc, array(
  23. 'item-vote' => 'isAllowedVoteView',
  24. 'item-reaction' => 'isAllowedReactionView',
  25. ));
  26. }
  27. protected function _getMenuItemItemComment($aItem)
  28. {
  29. if(!isset($this->_aEvent['comments']) || !is_array($this->_aEvent['comments']) || !isset($this->_aEvent['comments']['system']))
  30. return false;
  31. $sCommentsSystem = $this->_aEvent['comments']['system'];
  32. $iCommentsObject = $this->_aEvent['comments']['object_id'];
  33. $aCommentsParams = array(
  34. 'overwrite_counter_link_href' => 'javascript:void(0)',
  35. 'overwrite_counter_link_onclick' => bx_replace_markers('{comment_onclick}', $this->_aMarkers),
  36. 'show_do_comment_label' => $this->_bShowTitles,
  37. 'show_counter' => $this->_bShowCounters,
  38. 'show_counter_empty' => $this->_bShowCountersEmpty,
  39. 'show_counter_label_icon' => true,
  40. 'dynamic_mode' => $this->_bDynamicMode,
  41. );
  42. switch($this->_sMode) {
  43. case self::$_sModeActions:
  44. $sCommentsMethod = 'getElementInline';
  45. break;
  46. case self::$_sModeCounters:
  47. $sCommentsMethod = 'getCounter';
  48. break;
  49. }
  50. $oObject = $this->_oModule->getCmtsObject($sCommentsSystem, $iCommentsObject);
  51. if($this->_bIsApi)
  52. return $this->_getMenuItemElementApi($aItem, $oObject->getElementApi(array_merge($aCommentsParams, [
  53. 'show_counter' => true,
  54. ])));
  55. return $oObject->$sCommentsMethod($aCommentsParams);
  56. }
  57. }
  58. /** @} */