ch_yesno.php 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class ch_yesno
  5. */
  6. class ch_yesno extends survey_question
  7. {
  8. /**
  9. * @param array $surveyData
  10. * @param array $formData
  11. */
  12. public function createForm($surveyData, $formData)
  13. {
  14. parent::createForm($surveyData, $formData);
  15. $options = array(
  16. 'horizontal' => get_lang('Horizontal'),
  17. 'vertical' => get_lang('Vertical')
  18. );
  19. $this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options);
  20. $formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal';
  21. $this->getForm()->setDefaults($formData);
  22. /*// Horizontal or vertical
  23. $this->html .= ' <div class="control-group">';
  24. $this->html .= ' <label class="control-label">';
  25. $this->html .= get_lang('DisplayAnswersHorVert');
  26. $this->html .= ' </label>';
  27. $this->html .= ' <div class="controls">';
  28. $this->html .= ' <input name="horizontalvertical" type="radio" value="horizontal" ';
  29. if (empty($form_content['horizontalvertical']) or $form_content['horizontalvertical'] == 'horizontal') {
  30. $this->html .= 'checked="checked"';
  31. }
  32. $this->html .= '/>'.get_lang('Horizontal').'<br />';
  33. $this->html .= ' <input name="horizontalvertical" type="radio" value="vertical" ';
  34. if (isset($form_content['horizontalvertical']) && $form_content['horizontalvertical'] == 'vertical') {
  35. $this->html .= 'checked="checked"';
  36. }
  37. $this->html .= ' />'.get_lang('Vertical').'';
  38. $this->html .= ' </div>';
  39. $this->html .= ' </div>';*/
  40. // The options
  41. $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120');
  42. $this->getForm()->addHtmlEditor('answers[0]', get_lang('AnswerOptions'), true, false, $config);
  43. $this->getForm()->addHtmlEditor('answers[1]', null, true, false, $config);
  44. /*$this->html .= ' <div class="row">';
  45. $this->html .= ' <label class="control-label">';
  46. $this->html .= get_lang('AnswerOptions');
  47. $this->html .= ' </label>';
  48. $this->html .= ' <div class="formw">';
  49. $this->html .= ' <table>';
  50. $this->html .= ' <tr>';
  51. $this->html .= ' <td align="right"><label for="answers[0]">1</label></td>';
  52. $this->html .= ' <td width="550">'.api_return_html_area('answers[0]', stripslashes($form_content['answers'][0]), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
  53. $this->html .= ' <td><input style="width:22px" src="../img/icons/22/down.png" type="image" class="down" value="move_down[0]" name="move_down[0]"/></td>';
  54. $this->html .= ' </tr>';
  55. $this->html .= ' <tr>';
  56. $this->html .= ' <td align="right"><label for="answers[1]">2</label></td>';
  57. //$this->html .= ' <td><input type="text" name="answers[1]" id="answers[1]" value="'.$form_content['answers'][1].'" /></td>';
  58. $this->html .= ' <td width="550">'.api_return_html_area('answers[1]', stripslashes($form_content['answers'][1]), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
  59. $this->html .= ' <td><input style="width:22px" type="image" src="../img/icons/22/up.png" value="move_up[1]" name="move_up[1]" /></td>';
  60. $this->html .= ' </tr>';
  61. $this->html .= ' </table>';
  62. $this->html .= ' </div>';
  63. $this->html .= ' </div>';*/
  64. }
  65. /**
  66. * @param FormValidator $form
  67. * @param array $questionData
  68. * @param array $answers
  69. */
  70. public function render(FormValidator $form, $questionData = array(), $answers = array())
  71. {
  72. if (is_array($questionData['options'])) {
  73. if ($questionData['display'] == 'vertical') {
  74. $class = '';
  75. } else {
  76. $class = 'inline';
  77. }
  78. $form->addRadio(
  79. 'question' . $questionData['question_id'],
  80. null,
  81. $questionData['options'],
  82. array('label-class' => $class)
  83. );
  84. }
  85. }
  86. }