BxBaseCmtsReviewsForm.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. class BxBaseCmtsReviewsForm extends BxTemplCmtsForm
  10. {
  11. protected $_sSystem; ///< current review system name
  12. protected $_iId; ///< obect id to be reviewed
  13. public function __construct($aInfo, $oTemplate)
  14. {
  15. parent::__construct($aInfo, $oTemplate);
  16. $this->_sSystem = '';
  17. $this->_iId = 0;
  18. }
  19. protected function genCustomInputCmtMood ($aInput)
  20. {
  21. $oSystem = $this->_getSystemObject();
  22. $sStylePrefix = $oSystem->getStylePrefix();
  23. $sJsObject = $oSystem->getJsObjectName();
  24. $iMoodMinValue = $oSystem->getMoodMinValue();
  25. $iMoodMaxValue = $oSystem->getMoodMaxValue();
  26. $aTmplVarsStars = $aTmplVarsSlider = $aTmplVarsButtons = array();
  27. for($i = $iMoodMinValue; $i <= $iMoodMaxValue; $i++) {
  28. $aTmplVarsStars[] = array(
  29. 'style_prefix' => $sStylePrefix,
  30. 'value' => $i
  31. );
  32. $aTmplVarsSlider[] = array(
  33. 'style_prefix' => $sStylePrefix
  34. );
  35. $aTmplVarsButtons[] = array(
  36. 'style_prefix' => $sStylePrefix,
  37. 'js_object' => $sJsObject,
  38. 'value' => $i
  39. );
  40. }
  41. return $this->oTemplate->parseHtmlByName('review_mood_form_field.html', array(
  42. 'style_prefix' => $sStylePrefix,
  43. 'name' => $aInput['name'],
  44. 'value' => !empty($aInput['value']) ? $aInput['value'] : 0,
  45. 'bx_repeat:stars' => $aTmplVarsStars,
  46. 'bx_repeat:slider' => $aTmplVarsSlider,
  47. 'bx_repeat:buttons' => $aTmplVarsButtons,
  48. 'bx_if:show_init' => array(
  49. 'condition' => $this->_bDynamicMode,
  50. 'content' => array(
  51. 'style_prefix' => $sStylePrefix,
  52. 'js_object' => $sJsObject,
  53. 'form_id' => $this->getId(),
  54. )
  55. )
  56. ));
  57. }
  58. protected function _getSystemObject()
  59. {
  60. if(empty($this->_sSystem))
  61. $this->_sSystem = $this->aInputs['sys']['value'];
  62. if(empty($this->_iId))
  63. $this->_iId = (int)$this->aInputs['id']['value'];
  64. return BxDolCmts::getObjectInstance($this->_sSystem, $this->_iId);
  65. }
  66. }
  67. /** @} */