BxBaseUploaderServices.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * System services related to Comments.
  11. */
  12. class BxBaseUploaderServices extends BxDol
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. /**
  19. * @page service Service Calls
  20. * @section bx_system_cmts System Services
  21. * @subsection bx_system_cmts-general General
  22. * @subsubsection bx_system_cmts-get_data_api get_data_api
  23. *
  24. * @code bx_srv('system', 'get_data_api', [], 'TemplCmtsServices'); @endcode
  25. *
  26. * Get comments data
  27. * @param $aParams array with paramenters :
  28. * "module":"bx_posts","object_id":3,"start_from":5,"order_way":"desc","is_form":false
  29. *
  30. * @see TemplCmtsServices::serviceGetDataApi
  31. */
  32. /**
  33. * @ref bx_system_cmts-get_data_api "get_data_api"
  34. * @api @ref bx_system_cmts-get_data_api "get_data_api"
  35. */
  36. public function serviceGetDataApi($aParams)
  37. {
  38. $sUploaderObject = bx_process_input(bx_get('uo'));
  39. $sStorageObject = bx_process_input(bx_get('so'));
  40. $sUniqId = preg_match("/^[\d\w]+$/", bx_get('uid')) ? bx_get('uid') : '';
  41. $isMultiple = bx_get('m') ? true : false;
  42. $sFormat = bx_process_input(bx_get('f'));
  43. if ($sFormat != 'html' && $sFormat != 'json')
  44. $sFormat = 'html';
  45. $iContentId = bx_get('c');
  46. if (false === $iContentId || '' === $iContentId)
  47. $iContentId = false;
  48. else
  49. $iContentId = bx_process_input($iContentId, BX_DATA_INT);
  50. if (!$sUploaderObject || !$sStorageObject || !$sUniqId)
  51. exit;
  52. $isPrivate = (int)bx_get('p') ? 1 : 0;
  53. $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $sStorageObject, $sUniqId);
  54. $sAction = bx_process_input(bx_get('a'));
  55. switch ($sAction) {
  56. case 'restore_ghosts':
  57. $sImagesTranscoder = bx_process_input(bx_get('img_trans'));
  58. $oData = $oUploader->getGhostsWithOrder((int)bx_get_logged_profile_id(), $sFormat, $sImagesTranscoder, $iContentId);
  59. $aRv = isset($oData['g']) ? [$oData['g'], $oData['o']] : [];
  60. return $aRv;
  61. break;
  62. case 'delete':
  63. header('Content-type: text/html; charset=utf-8');
  64. $iFileId = bx_process_input(bx_get('id'), BX_DATA_INT);
  65. return $oUploader->deleteGhost($iFileId, bx_get_logged_profile_id());
  66. break;
  67. case 'upload':
  68. return $oUploader->handleUploads(bx_get_logged_profile_id(), isset($_FILES['f']) ? $_FILES['f'] : null, $isMultiple, $iContentId, $isPrivate);
  69. break;
  70. }
  71. }
  72. }
  73. /** @} */