BxTimelineFormPost.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. public function __construct($aInfo, $oTemplate = false)
  17. {
  18. $this->MODULE = 'bx_timeline';
  19. parent::__construct($aInfo, $oTemplate);
  20. $iUserId = $this->_oModule->getUserId();
  21. $iOwnerId = $this->_oModule->getOwnerId();
  22. $this->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'post/';
  23. $this->aInputs['owner_id']['value'] = $iOwnerId;
  24. if(isset($this->aInputs['link']))
  25. $this->aInputs['link']['content'] = $this->_oModule->_oTemplate->getAttachLinkField($iUserId);
  26. if(isset($this->aInputs['photo'])) {
  27. $aFormNested = array(
  28. 'params' =>array(
  29. 'nested_form_template' => 'uploader_nfw.html'
  30. ),
  31. 'inputs' => array(),
  32. );
  33. $oFormNested = new BxDolFormNested('photo', $aFormNested, 'do_submit', $this->_oModule->_oTemplate);
  34. $this->aInputs['photo']['storage_object'] = $this->_oModule->_oConfig->getObject('storage_photos');
  35. $this->aInputs['photo']['images_transcoder'] = $this->_oModule->_oConfig->getObject('transcoder_photos_preview');
  36. $this->aInputs['photo']['uploaders'] = !empty($this->aInputs['photo']['value']) ? unserialize($this->aInputs['photo']['value']) : $this->_oModule->_oConfig->getUploaders('photo');
  37. $this->aInputs['photo']['upload_buttons_titles'] = array('Simple' => 'camera');
  38. $this->aInputs['photo']['multiple'] = true;
  39. $this->aInputs['photo']['ghost_template'] = $oFormNested;
  40. }
  41. if(isset($this->aInputs['video'])) {
  42. $aFormNested = array(
  43. 'params' =>array(
  44. 'nested_form_template' => 'uploader_nfw.html'
  45. ),
  46. 'inputs' => array(),
  47. );
  48. $oFormNested = new BxDolFormNested('video', $aFormNested, 'do_submit', $this->_oModule->_oTemplate);
  49. $this->aInputs['video']['storage_object'] = $this->_oModule->_oConfig->getObject('storage_videos');
  50. $this->aInputs['video']['images_transcoder'] = $this->_oModule->_oConfig->getObject('transcoder_videos_poster');
  51. $this->aInputs['video']['uploaders'] = !empty($this->aInputs['video']['value']) ? unserialize($this->aInputs['video']['value']) : $this->_oModule->_oConfig->getUploaders('video');
  52. $this->aInputs['video']['upload_buttons_titles'] = array('Simple' => 'video-camera');
  53. $this->aInputs['video']['multiple'] = true;
  54. $this->aInputs['video']['ghost_template'] = $oFormNested;
  55. }
  56. if(isset($this->aInputs['attachments']))
  57. $this->aInputs['attachments']['content'] = '__attachments_menu__';
  58. if (isset($this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']) && isset($this->aInputs[$this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']]))
  59. $this->aInputs[$this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']]['manual_input'] = false;
  60. }
  61. public function getCode($bDynamicMode = false)
  62. {
  63. $sResult = parent::getCode($bDynamicMode);
  64. return $this->_oModule->_oTemplate->parseHtmlByContent($sResult, array(
  65. 'attachments_menu' => $this->_oModule->getAttachmentsMenuObject()->getCode()
  66. ));
  67. }
  68. }
  69. /** @} */