BxFdbTemplate.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 Feedback Feedback
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxFdbTemplate extends BxBaseModGeneralTemplate
  12. {
  13. function __construct(&$oConfig, &$oDb)
  14. {
  15. $this->MODULE = 'bx_feedback';
  16. parent::__construct($oConfig, $oDb);
  17. }
  18. public function getJsCode($sType, $aParams = array(), $bWrap = true)
  19. {
  20. $aParams = array_merge(array(
  21. 'aHtmlIds' => $this->_oConfig->getHtmlIds()
  22. ), $aParams);
  23. return parent::getJsCode($sType, $aParams, $bWrap);
  24. }
  25. public function getBlockQuestion($aQuestion, $aAnswers)
  26. {
  27. $sJsObject = $this->_oConfig->getJsObject('question');
  28. $iQuestion = (int)$aQuestion['id'];
  29. $aTmplVarsAnswers = array();
  30. foreach($aAnswers as $aAnswer)
  31. $aTmplVarsAnswers[] = array(
  32. 'js_object' => $sJsObject,
  33. 'id' => $aAnswer['id'],
  34. 'question_id' => $iQuestion,
  35. 'title' => bx_process_output(_t($aAnswer['title'])),
  36. 'bx_if:show_checked' => array(
  37. 'condition' => (int)$aAnswer['checked'] > 0,
  38. 'content' => array()
  39. )
  40. );
  41. $this->addCss(array('question.css'));
  42. $this->addJs(array('question.js'));
  43. $this->addJsTranslation(array('_bx_feedback_txt_enter_text'));
  44. return $this->getJsCode('question') . $this->parseHtmlByName('question.html', array(
  45. 'html_id' => $this->_oConfig->getHtmlIds('question') . $iQuestion,
  46. 'text' => bx_process_output(_t($aQuestion['text'])),
  47. 'bx_repeat:answers' => $aTmplVarsAnswers,
  48. ));
  49. }
  50. }
  51. /** @} */