BxFilesMenuView.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 Files Files
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * View entry menu
  13. */
  14. class BxFilesMenuView extends BxBaseModTextMenuView
  15. {
  16. public function __construct($aObject, $oTemplate = false)
  17. {
  18. $this->MODULE = 'bx_files';
  19. parent::__construct($aObject, $oTemplate);
  20. }
  21. public function setContentId($iContentId)
  22. {
  23. parent::setContentId($iContentId);
  24. $CNF = $this->_oModule->_oConfig->CNF;
  25. $aFile = $this->_oModule->getContentFile($this->_aContentInfo);
  26. if (!$aFile || !$aFile['private']) {
  27. $this->addMarkers(array(
  28. 'file_download_token' => '0',
  29. 'file_ext' => $aFile['ext'] ? $aFile['ext'] : '',
  30. ));
  31. return;
  32. }
  33. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  34. if (!$oStorage) {
  35. $this->addMarkers(array(
  36. 'file_download_token' => '0',
  37. 'file_ext' => $aFile['ext'],
  38. ));
  39. return;
  40. }
  41. $this->addMarkers(array(
  42. 'file_download_token' => $oStorage->genToken($aFile['id']),
  43. 'file_ext' => $aFile['ext'],
  44. ));
  45. }
  46. }
  47. /** @} */