1
0

BxFilesMenuView.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. $sFileExt = $aFile && !empty($aFile['ext']) ? $aFile['ext'] : '';
  27. if (!$aFile || !$aFile['private']) {
  28. $this->addMarkers(array(
  29. 'file_download_token' => '0',
  30. 'file_ext' => $sFileExt,
  31. ));
  32. return;
  33. }
  34. $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
  35. if (!$oStorage) {
  36. $this->addMarkers(array(
  37. 'file_download_token' => '0',
  38. 'file_ext' => $sFileExt,
  39. ));
  40. return;
  41. }
  42. $this->addMarkers(array(
  43. 'file_download_token' => $oStorage->genToken($aFile['id']),
  44. 'file_ext' => $sFileExt,
  45. ));
  46. }
  47. }
  48. /** @} */