BxBaseCmtsReviewsForm.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. if(bx_is_api()) {
  22. return $aInput;
  23. }
  24. $oSystem = $this->_getSystemObject();
  25. $sStylePrefix = $oSystem->getStylePrefix();
  26. $sJsObject = $oSystem->getJsObjectName();
  27. $iMoodMinValue = $oSystem->getMoodMinValue();
  28. $iMoodMaxValue = $oSystem->getMoodMaxValue();
  29. $aTmplVarsStars = $aTmplVarsSlider = $aTmplVarsButtons = array();
  30. for($i = $iMoodMinValue; $i <= $iMoodMaxValue; $i++) {
  31. $aTmplVarsStars[] = array(
  32. 'style_prefix' => $sStylePrefix,
  33. 'value' => $i
  34. );
  35. $aTmplVarsSlider[] = array(
  36. 'style_prefix' => $sStylePrefix
  37. );
  38. $aTmplVarsButtons[] = array(
  39. 'style_prefix' => $sStylePrefix,
  40. 'js_object' => $sJsObject,
  41. 'value' => $i
  42. );
  43. }
  44. return $this->oTemplate->parseHtmlByName('review_mood_form_field.html', array(
  45. 'style_prefix' => $sStylePrefix,
  46. 'name' => $aInput['name'],
  47. 'value' => !empty($aInput['value']) ? $aInput['value'] : 0,
  48. 'bx_repeat:stars' => $aTmplVarsStars,
  49. 'bx_repeat:slider' => $aTmplVarsSlider,
  50. 'bx_repeat:buttons' => $aTmplVarsButtons,
  51. 'bx_if:show_init' => array(
  52. 'condition' => $this->_bDynamicMode,
  53. 'content' => array(
  54. 'style_prefix' => $sStylePrefix,
  55. 'js_object' => $sJsObject,
  56. 'form_id' => $this->getId(),
  57. )
  58. )
  59. ));
  60. }
  61. protected function _getSystemObject()
  62. {
  63. if(empty($this->_sSystem))
  64. $this->_sSystem = $this->aInputs['sys']['value'];
  65. if(empty($this->_iId))
  66. $this->_iId = (int)$this->aInputs['id']['value'];
  67. return BxDolCmts::getObjectInstance($this->_sSystem, $this->_iId);
  68. }
  69. }
  70. /** @} */