BxBaseServiceContent.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. * Services for content objects
  11. */
  12. class BxBaseServiceContent extends BxDol
  13. {
  14. /**
  15. * @page service Service Calls
  16. * @section bx_system_general System Services
  17. * @subsection bx_system_general-content-objects Content Objects
  18. * @subsubsection bx_system_general-get_info Get content info
  19. *
  20. * @code bx_srv('system', 'get_info', [$sContentObject, $iContentId], 'TemplServiceContent'); @endcode
  21. * @code {{~system:get:TemplServiceContent["bx_posts", 123]~}} @endcode
  22. *
  23. * Content
  24. * @param $sContentObject content object name
  25. * @param $iContentId content id
  26. * @param $bRawInfo if true - raw info return data directly from DB, if false - returns strutured array
  27. * @return content info array on success or false of error
  28. *
  29. * @see BxBaseServiceContent::serviceGetInfo
  30. */
  31. /**
  32. * @ref bx_system_general-get_info "Get content"
  33. */
  34. public function serviceGetInfo ($sContentObject, $iContentId, $bRawInfo = false)
  35. {
  36. $o = BxDolContentInfo::getObjectInstance($sContentObject);
  37. if (!$o)
  38. return false;
  39. if ($bRawInfo)
  40. return $o->getContentInfo($iContentId, false);
  41. else
  42. return $o->getContentInfoAPI($iContentId, false);
  43. }
  44. /**
  45. * @page service Service Calls
  46. * @section bx_system_general System Services
  47. * @subsection bx_system_general-content-objects Content Objects
  48. * @subsubsection bx_system_general-delete Delete content
  49. *
  50. * @code bx_srv('system', 'delete', [$sContentObject, $iContentId], 'TemplServiceContent'); @endcode
  51. * @code {{~system:get:TemplServiceContent["bx_posts", 123]~}} @endcode
  52. *
  53. * Content
  54. * @param $sContentObject content object name
  55. * @param $iContentId content id
  56. * @return empty string on success or error message on error
  57. *
  58. * @see BxBaseServiceContent::serviceDelete
  59. */
  60. /**
  61. * @ref bx_system_general-delete "Delete content"
  62. */
  63. public function serviceDelete ($sContentObject, $iContentId)
  64. {
  65. $o = BxDolContentInfo::getObjectInstance($sContentObject);
  66. if (!$o)
  67. return false;
  68. return $o->deleteContent($iContentId);
  69. }
  70. /**
  71. * @page service Service Calls
  72. * @section bx_system_general System Services
  73. * @subsection bx_system_general-content-objects Content Objects
  74. * @subsubsection bx_system_general-update Update content
  75. *
  76. * @code bx_srv('system', 'update', [$sContentObject, $iContentId, $aValues], 'TemplServiceContent'); @endcode
  77. * @code {{~system:get:TemplServiceContent["bx_posts", 123, ["title" => "new title"]]~}} @endcode
  78. *
  79. * Content
  80. * @param $sContentObject content object name
  81. * @param $iContentId content id
  82. * @param $aValues key value pairs to update
  83. * @return empty string on success or error message on error
  84. *
  85. * @see BxBaseServiceContent::serviceUpdate
  86. */
  87. /**
  88. * @ref bx_system_general-update "Update content"
  89. */
  90. public function serviceUpdate ($sContentObject, $iContentId, $aValues)
  91. {
  92. $o = BxDolContentInfo::getObjectInstance($sContentObject);
  93. if (!$o)
  94. return false;
  95. return $o->updateContent($iContentId, $aValues);
  96. }
  97. }
  98. /** @} */