1
0

BxStrmFormEntry.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 Stream Stream
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Create/Edit entry form
  13. */
  14. class BxStrmFormEntry extends BxBaseModTextFormEntry
  15. {
  16. protected $_sGhostTemplateCover = 'form_ghost_template_cover.html';
  17. public function __construct($aInfo, $oTemplate = false)
  18. {
  19. $this->MODULE = 'bx_stream';
  20. parent::__construct($aInfo, $oTemplate);
  21. $CNF = &$this->_oModule->_oConfig->CNF;
  22. if(isset($CNF['FIELD_COVER']) && isset($this->aInputs[$CNF['FIELD_COVER']])) {
  23. if($this->_oModule->checkAllowedSetThumb() === CHECK_ACTION_RESULT_ALLOWED) {
  24. $this->aInputs[$CNF['FIELD_COVER']]['storage_object'] = $CNF['OBJECT_STORAGE'];
  25. $this->aInputs[$CNF['FIELD_COVER']]['uploaders'] = !empty($this->aInputs[$CNF['FIELD_COVER']]['value']) ? unserialize($this->aInputs[$CNF['FIELD_COVER']]['value']) : $CNF['OBJECT_UPLOADERS'];
  26. $this->aInputs[$CNF['FIELD_COVER']]['upload_buttons_titles'] = array(
  27. 'Simple' => _t('_bx_stream_form_entry_input_covers_uploader_simple_title'),
  28. 'HTML5' => _t('_bx_stream_form_entry_input_covers_uploader_html5_title')
  29. );
  30. $this->aInputs[$CNF['FIELD_COVER']]['images_transcoder'] = $CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'];
  31. $this->aInputs[$CNF['FIELD_COVER']]['storage_private'] = 0;
  32. $this->aInputs[$CNF['FIELD_COVER']]['multiple'] = false;
  33. $this->aInputs[$CNF['FIELD_COVER']]['content_id'] = 0;
  34. $this->aInputs[$CNF['FIELD_COVER']]['ghost_template'] = '';
  35. }
  36. else
  37. unset($this->aInputs[$CNF['FIELD_COVER']]);
  38. }
  39. }
  40. public function insert ($aValsToAdd = [], $isIgnore = false)
  41. {
  42. $CNF = &$this->_oModule->_oConfig->CNF;
  43. return parent::insert(array_merge($aValsToAdd, [
  44. $CNF['FIELD_STATUS'] => 'awaiting', // streams are always in 'awaiting' status inless stream is live
  45. $CNF['FIELD_KEY'] => genRndPwd(12, false)
  46. ]), $isIgnore);
  47. }
  48. }
  49. /** @} */