BxBaseVoteReactionsMenuDo.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * Menu representation.
  11. * @see BxDolMenu
  12. */
  13. class BxBaseVoteReactionsMenuDo extends BxTemplMenu
  14. {
  15. protected $_iValue;
  16. protected $_oObject;
  17. public function __construct($aObject, $oTemplate)
  18. {
  19. parent::__construct ($aObject, $oTemplate);
  20. }
  21. public function setParams($aParams)
  22. {
  23. if(empty($aParams['object']) || !is_a($aParams['object'], 'BxTemplVoteReactions'))
  24. return;
  25. $this->_oObject = $aParams['object'];
  26. $this->_iValue = isset($aParams['value']) ? (int)$aParams['value'] : $this->_oObject->getValue();
  27. }
  28. protected function getMenuItemsRaw()
  29. {
  30. $sJsObject = $this->_oObject->getJsObjectName();
  31. $aReactions = $this->_oObject->getReactions(true);
  32. $aMenuItems = array();
  33. foreach($aReactions as $sName => $aReaction) {
  34. $aMenuItems[] = array(
  35. 'id' => $sName,
  36. 'name' => $sName,
  37. 'class' => '',
  38. 'link' => 'javascript:void(0)',
  39. 'onclick' => 'javascript:' . $this->_oObject->getJsClickDo($sName, $this->_iValue),
  40. 'target' => '_self',
  41. 'title' => _t($aReaction['title']),
  42. 'icon' => $aReaction['icon'],
  43. 'active' => 1
  44. );
  45. }
  46. return $aMenuItems;
  47. }
  48. protected function _getMenuItem ($a)
  49. {
  50. $aResult = parent::_getMenuItem($a);
  51. if(empty($aResult) || !is_array($aResult))
  52. return $aResult;
  53. $aResult['title'] = '';
  54. $aResult['bx_if:title']['condition'] = false;
  55. return $aResult;
  56. }
  57. }
  58. /** @} */