BxTimelineFormPost.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. /**
  12. * Create/Edit entry form
  13. */
  14. class BxTimelineFormPost extends BxBaseModGeneralFormEntry
  15. {
  16. protected $_bPublicMode;
  17. public function __construct($aInfo, $oTemplate = false)
  18. {
  19. $this->MODULE = 'bx_timeline';
  20. parent::__construct($aInfo, $oTemplate);
  21. $iUserId = $this->_oModule->getUserId();
  22. $iOwnerId = $this->_oModule->getOwnerId();
  23. $this->_bPublicMode = isset($this->aParams['display']) && $this->aParams['display'] == $this->_oModule->_oConfig->getObject('form_display_post_add_public');
  24. $this->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'post/';
  25. $this->aInputs['owner_id']['value'] = $iOwnerId;
  26. if(isset($this->aInputs['object_privacy_view'])) {
  27. $this->aInputs['object_privacy_view'] = array_merge($this->aInputs['object_privacy_view'], BxDolPrivacy::getGroupChooser($this->_oModule->_oConfig->getObject('privacy_view'), 0, array(
  28. 'title' => _t('_bx_timeline_form_post_input_object_privacy_view')
  29. )));
  30. if($this->_bPublicMode)
  31. foreach($this->aInputs['object_privacy_view']['values'] as $iKey => $aValue)
  32. if($aValue['key'] !== BX_DOL_PG_ALL)
  33. unset($this->aInputs['object_privacy_view']['values'][$iKey]);
  34. }
  35. if(isset($this->aInputs['link']))
  36. $this->aInputs['link']['content'] = $this->_oModule->_oTemplate->getAttachLinkField($iUserId);
  37. if(isset($this->aInputs['photo'])) {
  38. $aFormNested = array(
  39. 'params' =>array(
  40. 'nested_form_template' => 'uploader_nfw.html'
  41. ),
  42. 'inputs' => array(),
  43. );
  44. $oFormNested = new BxDolFormNested('photo', $aFormNested, 'do_submit', $this->_oModule->_oTemplate);
  45. $this->aInputs['photo']['storage_object'] = $this->_oModule->_oConfig->getObject('storage_photos');
  46. $this->aInputs['photo']['images_transcoder'] = $this->_oModule->_oConfig->getObject('transcoder_photos_preview');
  47. $this->aInputs['photo']['uploaders'] = !empty($this->aInputs['photo']['value']) ? unserialize($this->aInputs['photo']['value']) : $this->_oModule->_oConfig->getUploaders('photo');
  48. $this->aInputs['photo']['upload_buttons_titles'] = array('Simple' => 'camera');
  49. $this->aInputs['photo']['multiple'] = true;
  50. $this->aInputs['photo']['ghost_template'] = $oFormNested;
  51. }
  52. if(isset($this->aInputs['video'])) {
  53. $aFormNested = array(
  54. 'params' =>array(
  55. 'nested_form_template' => 'uploader_nfw.html'
  56. ),
  57. 'inputs' => array(),
  58. );
  59. $oFormNested = new BxDolFormNested('video', $aFormNested, 'do_submit', $this->_oModule->_oTemplate);
  60. $this->aInputs['video']['storage_object'] = $this->_oModule->_oConfig->getObject('storage_videos');
  61. $this->aInputs['video']['images_transcoder'] = $this->_oModule->_oConfig->getObject('transcoder_videos_poster');
  62. $this->aInputs['video']['uploaders'] = !empty($this->aInputs['video']['value']) ? unserialize($this->aInputs['video']['value']) : $this->_oModule->_oConfig->getUploaders('video');
  63. $this->aInputs['video']['upload_buttons_titles'] = array('Simple' => 'video-camera');
  64. $this->aInputs['video']['multiple'] = true;
  65. $this->aInputs['video']['ghost_template'] = $oFormNested;
  66. }
  67. if(isset($this->aInputs['attachments']))
  68. $this->aInputs['attachments']['content'] = '__attachments_menu__';
  69. if (isset($this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']) && isset($this->aInputs[$this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']]))
  70. $this->aInputs[$this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']]['manual_input'] = false;
  71. }
  72. public function getCode($bDynamicMode = false)
  73. {
  74. $sResult = parent::getCode($bDynamicMode);
  75. return $this->_oModule->_oTemplate->parseHtmlByContent($sResult, array(
  76. 'attachments_menu' => $this->_oModule->getAttachmentsMenuObject()->getCode()
  77. ));
  78. }
  79. }
  80. /** @} */