1
0

BxTimelineMenuItemManage.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 BxTimelineMenuItemManage extends BxTimelineMenuItemActions
  16. {
  17. public function __construct($aObject, $oTemplate = false)
  18. {
  19. parent::__construct($aObject, $oTemplate);
  20. $this->setDynamicMode(true);
  21. $iContentId = 0;
  22. if(bx_get('content_id') !== false)
  23. $iContentId = bx_process_input(bx_get('content_id'), BX_DATA_INT);
  24. $aBrowseParams = array('name' => '', 'view' => '', 'type' => '');
  25. foreach($aBrowseParams as $sKey => $sValue)
  26. if(bx_get($sKey) !== false)
  27. $aBrowseParams[$sKey] = $this->_oModule->_oConfig->prepareParam($sKey);
  28. $this->setEventById($iContentId, $aBrowseParams);
  29. $this->_bShowTitles = true;
  30. $this->_bShowCounters = true;
  31. $this->_sTmplNameItem = 'menu_custom_item_ver.html';
  32. $this->addMarkers(array(
  33. 'module' => $this->_oModule->_oConfig->getName(),
  34. 'module_uri' => $this->_oModule->_oConfig->getUri(),
  35. ));
  36. }
  37. public function initContentParams()
  38. {
  39. parent::initContentParams();
  40. $this->_aContentParams = array_merge($this->_aContentParams, [
  41. 'content_id' => $this->_iEvent
  42. ]);
  43. }
  44. public function setContentParams($aParams)
  45. {
  46. if(!isset($aParams['content_id']))
  47. return false;
  48. $aBrowseParams = [];
  49. foreach(['name', 'view', 'type'] as $sKey)
  50. if(isset($aParams[$sKey]) && $aParams[$sKey] !== '')
  51. $aBrowseParams[$sKey] = $aParams[$sKey];
  52. $this->setEventById($aParams['content_id'], $aBrowseParams);
  53. return parent::setContentParams($aParams);
  54. }
  55. public function setEvent($aEvent, $aBrowseParams = [])
  56. {
  57. $bResult = parent::setEvent($aEvent, $aBrowseParams);
  58. if($bResult) {
  59. $aContentParams = [
  60. 'content_id' => $this->_iEvent
  61. ];
  62. foreach(['name', 'view', 'type'] as $sKey) {
  63. if(!empty($aBrowseParams[$sKey]))
  64. $aContentParams[$sKey] = $aBrowseParams[$sKey];
  65. }
  66. if(empty($aContentParams['type']) && !empty($this->_sType))
  67. $aContentParams['type'] = $this->_sType;
  68. if(empty($aContentParams['view']) && !empty($this->_sView))
  69. $aContentParams['view'] = $this->_sView;
  70. $this->_aContentParams = array_merge($this->_aContentParams, $aContentParams);
  71. }
  72. return $bResult;
  73. }
  74. }
  75. /** @} */