BxEventsMenuViewActionsAll.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 Events Events
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. use Spatie\CalendarLinks\Link;
  12. /**
  13. * View entry all actions menu
  14. */
  15. class BxEventsMenuViewActionsAll extends BxBaseModGroupsMenuViewActionsAll
  16. {
  17. public function __construct($aObject, $oTemplate = false)
  18. {
  19. $this->_sModule = 'bx_events';
  20. parent::__construct($aObject, $oTemplate);
  21. }
  22. public function setContentId($iContentId)
  23. {
  24. parent::setContentId($iContentId);
  25. if (!isset($this->_aContentInfo['date_start']) || !$this->_aContentInfo['date_start'] || !isset($this->_aContentInfo['date_end']) || !$this->_aContentInfo['date_end'])
  26. return;
  27. $oDateStart = new DateTime('@' . $this->_aContentInfo['date_start']);
  28. $oDateEnd = new DateTime('@' . ($this->_aContentInfo['date_end'] > $this->_aContentInfo['repeat_stop'] ? $this->_aContentInfo['date_end'] : $this->_aContentInfo['repeat_stop']));
  29. $CNF = $this->_oModule->_oConfig->CNF;
  30. if ($this->_aContentInfo[$CNF['FIELD_TIMEZONE']]) {
  31. $oTz = new DateTimeZone($this->_aContentInfo[$CNF['FIELD_TIMEZONE']]);
  32. $oDateStart->setTimezone($oTz);
  33. $oDateEnd->setTimezone($oTz);
  34. }
  35. $oICalLink = $oDateStart && $oDateEnd ? Link::create(
  36. $this->_aContentInfo[$CNF['FIELD_TITLE']],
  37. $oDateStart,
  38. $oDateEnd
  39. ) : null;
  40. if (!empty($CNF['OBJECT_METATAGS'])) {
  41. $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  42. if ($oMetatags->locationsIsEnabled()) {
  43. $sLocation = $oMetatags->locationsString($this->_aContentInfo[$CNF['FIELD_ID']], false);
  44. if ($sLocation)
  45. $oICalLink->address($sLocation);
  46. }
  47. }
  48. $this->addMarkers([
  49. 'ical_url' => $oICalLink ? $oICalLink->ics() : '',
  50. ]);
  51. }
  52. protected function _getMenuAttrs ($aMenuItem)
  53. {
  54. $s = parent::_getMenuAttrs ($aMenuItem);
  55. if ('ical-export' == $aMenuItem['name']) {
  56. $CNF = $this->_oModule->_oConfig->CNF;
  57. $s .= ' download="' . title2uri($this->_aContentInfo[$CNF['FIELD_TITLE']]) . '.ics"';
  58. }
  59. return $s;
  60. }
  61. protected function _getMenuItemJoinEventProfile($aItem)
  62. {
  63. return $this->_getMenuItemByNameActions($aItem);
  64. }
  65. protected function _getMenuItemEditEventCover($aItem)
  66. {
  67. return $this->_getMenuItemByNameActionsMore($aItem);
  68. }
  69. protected function _getMenuItemEditEventProfile($aItem)
  70. {
  71. return $this->_getMenuItemByNameActionsMore($aItem);
  72. }
  73. protected function _getMenuItemEditEventPricing($aItem)
  74. {
  75. return $this->_getMenuItemByNameActionsMore($aItem);
  76. }
  77. protected function _getMenuItemInviteToEvent($aItem)
  78. {
  79. return $this->_getMenuItemByNameActionsMore($aItem);
  80. }
  81. protected function _getMenuItemDeleteEventProfile($aItem)
  82. {
  83. return $this->_getMenuItemByNameActionsMore($aItem);
  84. }
  85. protected function _getMenuItemApproveEventProfile($aItem)
  86. {
  87. return $this->_getMenuItemByNameActionsMore($aItem);
  88. }
  89. protected function _getMenuItemProfileSetBadges($aItem)
  90. {
  91. return $this->_getMenuItemByNameActions($aItem);
  92. }
  93. }
  94. /** @} */