BxPollsMenuSnippetMeta.php 2.4 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 Polls Polls
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxPollsMenuSnippetMeta extends BxBaseModTextMenuSnippetMeta
  12. {
  13. public function __construct($aObject, $oTemplate = false)
  14. {
  15. $this->_sModule = 'bx_polls';
  16. parent::__construct($aObject, $oTemplate);
  17. }
  18. public function setContent($aContentInfo)
  19. {
  20. $CNF = &$this->_oModule->_oConfig->CNF;
  21. $this->_aContentInfo = !empty($this->_aContentInfo) && is_array($this->_aContentInfo) ? array_merge($this->_aContentInfo, $aContentInfo) : $aContentInfo;
  22. if($this->_aContentInfo) {
  23. $this->_iContentId = (int)$aContentInfo[$CNF['FIELD_ID']];
  24. $this->addMarkers(array('content_id' => $this->_iContentId));
  25. }
  26. }
  27. protected function _getMenuItemActions($aItem)
  28. {
  29. $CNF = &$this->_oModule->_oConfig->CNF;
  30. $iContentId = (int)$this->_aContentInfo[$CNF['FIELD_ID']];
  31. $bPerformed = $this->_oModule->isPerformed($iContentId);
  32. if((int)$this->_aContentInfo[$CNF['FIELD_HIDDEN_RESULTS']] != 0 && !$bPerformed)
  33. return false;
  34. $aTmplVars = array(
  35. 'js_object' => $this->_oModule->_oConfig->getJsObject('entry'),
  36. 'html_id_subentries' => '',
  37. 'html_id_results' => '',
  38. 'id' => $iContentId,
  39. 'bx_if:hide_subentries' => array(
  40. 'condition' => !$bPerformed,
  41. 'content' => array()
  42. ),
  43. 'bx_if:hide_results' => array(
  44. 'condition' => $bPerformed,
  45. 'content' => array()
  46. ),
  47. );
  48. if(!empty($this->_aContentInfo['salt'])) {
  49. $sSalt = $this->_aContentInfo['salt'];
  50. $aTmplVars = array_merge($aTmplVars, array(
  51. 'html_id_subentries' => $this->_oModule->_oConfig->getHtmlIds('snippet_link_subentries') . $sSalt,
  52. 'html_id_results' => $this->_oModule->_oConfig->getHtmlIds('snippet_link_results') . $sSalt,
  53. 'id' => bx_js_string(json_encode(array('content_id' => $iContentId, 'salt' => $sSalt)))
  54. ));
  55. }
  56. return $this->getUnitMetaItemCustom($this->_oTemplate->parseHtmlByName('unit_meta_actions.html', $aTmplVars));
  57. }
  58. }
  59. /** @} */