BxPhotosModule.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 Photos Photos
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Photos module
  13. */
  14. class BxPhotosModule extends BxBaseModTextModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. }
  20. public function actionViewEntryBrief()
  21. {
  22. echo BxDolPage::getObjectInstance($this->_oConfig->CNF['OBJECT_PAGE_VIEW_ENTRY_BRIEF'], $this->_oTemplate)->getCodeDynamic();
  23. }
  24. /**
  25. * Display entries of the author
  26. * @return HTML string
  27. */
  28. public function serviceBrowseAuthor ($iProfileId = 0, $aParams = array())
  29. {
  30. $mixedResult = parent::serviceBrowseAuthor ($iProfileId, $aParams);
  31. if(empty($mixedResult))
  32. return;
  33. $sJsCode = $this->_oTemplate->getJsCode('main');
  34. if(is_string($mixedResult))
  35. $mixedResult .= $sJsCode;
  36. else if(is_array($mixedResult) && isset($mixedResult['content']))
  37. $mixedResult['content'] .= $sJsCode;
  38. $this->_oTemplate->addJs(array('main.js'));
  39. return $mixedResult;
  40. }
  41. /**
  42. * @page service Service Calls
  43. * @section bx_photos Photos
  44. * @subsection bx_photos-page_blocks Page Blocks
  45. * @subsubsection bx_photos-entity_photo_block entity_photo_block
  46. *
  47. * @code bx_srv('bx_photos', 'entity_photo_block', [...]); @endcode
  48. *
  49. * Get page block with photo.
  50. *
  51. * @param $iContentId (optional) photo ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  52. * @return HTML string with block content to display on the site or false if there is no enough input data. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  53. *
  54. * @see BxPhotosModule::serviceEntityPhotoBlock
  55. */
  56. /**
  57. * @ref bx_photos-entity_photo_block "entity_photo_block"
  58. */
  59. public function serviceEntityPhotoBlock ($iContentId = 0)
  60. {
  61. $mixedContent = $this->_getContent($iContentId);
  62. if($mixedContent === false)
  63. return false;
  64. list($iContentId, $aContentInfo) = $mixedContent;
  65. return $this->_oTemplate->entryPhoto($aContentInfo);
  66. }
  67. /**
  68. * @page service Service Calls
  69. * @section bx_photos Photos
  70. * @subsection bx_photos-page_blocks Page Blocks
  71. * @subsubsection bx_photos-entity_photo_block entity_photo_block
  72. *
  73. * @code bx_srv('bx_photos', 'entity_photo_switcher_block', [...]); @endcode
  74. *
  75. * Get page block with photo and Prev/Next controls.
  76. *
  77. * @param $iContentId (optional) photo ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  78. * @return HTML string with block content to display on the site or false if there is no enough input data. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  79. *
  80. * @see BxPhotosModule::serviceEntityPhotoBlock
  81. */
  82. /**
  83. * @ref bx_photos-entity_photo_block "entity_photo_switcher_block"
  84. */
  85. public function serviceEntityPhotoSwitcherBlock ($iContentId = 0, $sMode = '')
  86. {
  87. $mixedContent = $this->_getContent($iContentId);
  88. if($mixedContent === false)
  89. return false;
  90. list($iContentId, $aContentInfo) = $mixedContent;
  91. if(!$sMode)
  92. $sMode = bx_process_input(bx_get('mode'));
  93. return $this->_oTemplate->entryPhotoSwitcher($aContentInfo, $sMode);
  94. }
  95. /**
  96. * @page service Service Calls
  97. * @section bx_photos Photos
  98. * @subsection bx_photos-page_blocks Page Blocks
  99. * @subsubsection bx_photos-entity_rating entity_rating
  100. *
  101. * @code bx_srv('bx_photos', 'entity_rating', [...]); @endcode
  102. *
  103. * Get page block with Stars based photo's rating.
  104. *
  105. * @param $iContentId (optional) photo ID. If empty value is provided, an attempt to get it from GET/POST arrays will be performed.
  106. * @return HTML string with block content to display on the site or false if there is no enough input data. All necessary CSS and JS files are automatically added to the HEAD section of the site HTML.
  107. *
  108. * @see BxPhotosModule::serviceEntityRating
  109. */
  110. /**
  111. * @ref bx_photos-entity_rating "entity_rating"
  112. */
  113. public function serviceEntityRating($iContentId = 0)
  114. {
  115. return $this->_serviceTemplateFunc ('entryRating', $iContentId);
  116. }
  117. public function checkAllowedSetThumb ($iContentId = 0)
  118. {
  119. return $iContentId > 0 ? CHECK_ACTION_RESULT_ALLOWED : CHECK_ACTION_RESULT_NOT_ALLOWED;
  120. }
  121. protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
  122. {
  123. $aImages = parent::_getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams);
  124. $bView = $this->checkAllowedView($aContentInfo) === CHECK_ACTION_RESULT_ALLOWED;
  125. foreach($aImages as $iKey => $aImage)
  126. if(!$bView)
  127. unset($aImages[$iKey]['src_orig']);
  128. return $aImages;
  129. }
  130. }
  131. /** @} */