1
0

BxBaseCmtsReviewsForm.php 2.5 KB

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