BxTimelineMenuPostAttachments.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. class BxTimelineMenuPostAttachments extends BxTemplMenu
  12. {
  13. protected $_oModule;
  14. protected $_iEvent;
  15. /**
  16. * An array with uploaders, which are
  17. * available (active) in create form.
  18. */
  19. protected $_aUploadersInfo;
  20. public function __construct($aObject, $oTemplate = false)
  21. {
  22. parent::__construct($aObject, $oTemplate);
  23. $this->_oModule = BxDolModule::getInstance('bx_timeline');
  24. $this->addMarkers(array(
  25. 'js_object' => $this->_oModule->_oConfig->getJsObject('post'),
  26. ));
  27. }
  28. public function setEventById($iEventId, $aBrowseParams = array())
  29. {
  30. $this->_iEvent = $iEventId;
  31. $this->addMarkers(array(
  32. 'content_id' => $this->_iEvent,
  33. ));
  34. }
  35. public function setUploadersInfo($aUploadersInfo)
  36. {
  37. $this->_aUploadersInfo = $aUploadersInfo;
  38. }
  39. public function isMenuItem($sName)
  40. {
  41. if(empty($this->_aObject['menu_items'][$sName]) || !is_array($this->_aObject['menu_items'][$sName]))
  42. return false;
  43. $aMenuItem = $this->_aObject['menu_items'][$sName];
  44. if(isset($aMenuItem['active']) && !$aMenuItem['active'])
  45. return false;
  46. return $this->_isVisible($aMenuItem);
  47. }
  48. protected function _getMenuItem($a)
  49. {
  50. if(isset($a['active']) && !$a['active'])
  51. return false;
  52. if(isset($a['visible_for_levels']) && !$this->_isVisible($a))
  53. return false;
  54. if(($sUploader = $this->_oModule->_oConfig->getUploaderByMenuItem($a['name'])) !== false) {
  55. if(!isset($this->_aUploadersInfo[$sUploader]))
  56. return false;
  57. $this->addMarkers(array(
  58. 'js_object_' . str_replace('-', '_', $a['name']) => $this->_aUploadersInfo[$sUploader]['js_object']
  59. ));
  60. }
  61. $aResult = parent::_getMenuItem($a);
  62. switch($a['name']) {
  63. case 'add-link':
  64. if($this->_oModule->_oConfig->isMediaPriority() && $this->_oModule->hasMedia($this->_iEvent))
  65. $aResult['class_link'] = 'bx-btn-disabled';
  66. break;
  67. }
  68. return $aResult;
  69. }
  70. }
  71. /** @} */