BxAdsFormsEntryHelper.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 Ads Ads
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Entry forms helper functions
  13. */
  14. class BxAdsFormsEntryHelper extends BxBaseModTextFormsEntryHelper
  15. {
  16. public function __construct($oModule)
  17. {
  18. parent::__construct($oModule);
  19. }
  20. public function getObjectFormAdd($sDisplay = false)
  21. {
  22. if(($sCategoryDisplay = $this->_oModule->getCategoryDisplay('add')) !== false)
  23. $sDisplay = $sCategoryDisplay;
  24. return parent::getObjectFormAdd($sDisplay);
  25. }
  26. public function viewDataEntry ($iContentId)
  27. {
  28. $CNF = &$this->_oModule->_oConfig->CNF;
  29. $mixedResult = parent::viewDataEntry ($iContentId);
  30. if(!empty($mixedResult))
  31. return $mixedResult;
  32. $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
  33. $sDisplay = false;
  34. if(!empty($aContentInfo[$CNF['FIELD_CATEGORY']]) && ($sCategoryDisplay = $this->_oModule->getCategoryDisplay('view', $aContentInfo[$CNF['FIELD_CATEGORY']])) !== false)
  35. $sDisplay = $sCategoryDisplay;
  36. $oForm = $this->getObjectFormView($sDisplay);
  37. if(!$oForm)
  38. return '';
  39. $oForm->initChecker($aContentInfo);
  40. if(!empty($CNF['FIELD_TEXT']) && !$oForm->isInputVisible($CNF['FIELD_TEXT']))
  41. return '';
  42. return $this->_oModule->_oTemplate->entryText($aContentInfo);
  43. }
  44. public function onDataAddAfter($iAccountId, $iContentId)
  45. {
  46. $s = parent::onDataAddAfter($iAccountId, $iContentId);
  47. if(!empty($s))
  48. return $s;
  49. $this->_oModule->serviceUpdateCategoriesStats();
  50. return '';
  51. }
  52. public function onDataEditAfter($iContentId, $aContentInfo, $aTrackTextFieldsChanges, $oProfile, $oForm)
  53. {
  54. $s = parent::onDataEditAfter($iContentId, $aContentInfo, $aTrackTextFieldsChanges, $oProfile, $oForm);
  55. if(!empty($s))
  56. return $s;
  57. $this->_oModule->serviceUpdateCategoriesStats();
  58. return '';
  59. }
  60. public function onDataDeleteAfter ($iContentId, $aContentInfo, $oProfile)
  61. {
  62. $s = parent::onDataDeleteAfter ($iContentId, $aContentInfo, $oProfile);
  63. if(!empty($s))
  64. return $s;
  65. $this->_oModule->serviceUpdateCategoriesStats();
  66. return '';
  67. }
  68. }
  69. /** @} */