BxAdsPageEntry.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 create/edit pages
  13. */
  14. class BxAdsPageEntry extends BxBaseModTextPageEntry
  15. {
  16. public function __construct($aObject, $oTemplate = false)
  17. {
  18. $this->MODULE = 'bx_ads';
  19. parent::__construct($aObject, $oTemplate);
  20. $CNF = &$this->_oModule->_oConfig->CNF;
  21. if(($oInformer = BxDolInformer::getInstance($this->_oTemplate)) !== false) {
  22. $aInformers = [];
  23. $sStatus = isset($CNF['FIELD_STATUS']) && isset($this->_aContentInfo[$CNF['FIELD_STATUS']]) ? $this->_aContentInfo[$CNF['FIELD_STATUS']] : '';
  24. $sStatusAdmin = isset($CNF['FIELD_STATUS_ADMIN']) && isset($this->_aContentInfo[$CNF['FIELD_STATUS_ADMIN']]) ? $this->_aContentInfo[$CNF['FIELD_STATUS_ADMIN']] : '';
  25. //--- Display 'auction' informer.
  26. if(!empty($CNF['INFORMERS']['auction']) && isset($CNF['INFORMERS']['auction']['map'][$sStatus])) {
  27. $aInformer = $CNF['INFORMERS']['auction'];
  28. $aInformers[] = ['name' => $aInformer['name'], 'msg' => _t($aInformer['map'][$sStatus]['msg']), 'type' => $aInformer['map'][$sStatus]['type']];
  29. }
  30. if(($this->_bLoggedOwner || $this->_bLoggedModerator || $this->_bLoggedContextModerator)) {
  31. //--- Display 'promotion' informer.
  32. if(!empty($CNF['INFORMERS']['promotion']) && isset($CNF['INFORMERS']['promotion']['map'][$sStatusAdmin])) {
  33. $aInformer = $CNF['INFORMERS']['promotion'];
  34. $aInformers[] = ['name' => $aInformer['name'], 'msg' => _t($aInformer['map'][$sStatusAdmin]['msg']), 'type' => $aInformer['map'][$sStatusAdmin]['type']];
  35. }
  36. }
  37. //--- Add informers
  38. if($aInformers)
  39. foreach($aInformers as $aInformer)
  40. $oInformer->add($aInformer['name'], $this->_replaceMarkers($aInformer['msg']), $aInformer['type']);
  41. }
  42. }
  43. public function getCode ()
  44. {
  45. $sResult = parent::getCode();
  46. if(!empty($sResult))
  47. $sResult .= $this->_oModule->_oTemplate->getJsCode('entry');
  48. $this->_oModule->_oTemplate->addCss(array('entry.css'));
  49. $this->_oModule->_oTemplate->addJs(array('entry.js'));
  50. return $sResult;
  51. }
  52. protected function _setSubmenu($aParams)
  53. {
  54. parent::_setSubmenu(array_merge($aParams, array(
  55. 'title' => '',
  56. 'icon' => ''
  57. )));
  58. }
  59. }
  60. /** @} */