diff --git a/main/inc/lib/formvalidator/FormValidator.class.php b/main/inc/lib/formvalidator/FormValidator.class.php index 7eb920cbca..11456e746c 100755 --- a/main/inc/lib/formvalidator/FormValidator.class.php +++ b/main/inc/lib/formvalidator/FormValidator.class.php @@ -207,16 +207,17 @@ EOT; * @param string $name * @param string $label * @param string $icon font-awesome + * @param string $style default|primary|success|info|warning|danger|link + * @param string $size large|default|small|extra-small * @param string $class Example plus is transformed to icon fa fa-plus * @param array $attributes * * @return HTML_QuickForm_button */ - public function addButton($name, $label, $icon = 'check', $class = 'btn btn-default', $attributes = array()) + public function addButton($name, $label, $icon = 'check', $style = 'default', $size = 'default', $class = 'btn', $attributes = array()) { - //$attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'btn btn-default'; $attributes['icon'] = $icon; - $attributes['class'] = $class; + $attributes['class'] = $class.' btn-'.$style.' btn-'.$size; return $this->addElement('button', $name, $label, $attributes); } diff --git a/main/inc/lib/pear/HTML/QuickForm/button.php b/main/inc/lib/pear/HTML/QuickForm/button.php index 7153218dbf..0b99712902 100755 --- a/main/inc/lib/pear/HTML/QuickForm/button.php +++ b/main/inc/lib/pear/HTML/QuickForm/button.php @@ -48,8 +48,17 @@ class HTML_QuickForm_button extends HTML_QuickForm_input public function HTML_QuickForm_button( $elementName = null, $value = null, - $attributes = null + $icon = 'check', + $style = 'default', + $size = 'default', + $class = 'btn', + $attributes = array() ) { + $attributes['icon'] = $icon; + $attributes['style'] = $style; + $attributes['size'] = $size; + $attributes['class'] = $class; + HTML_QuickForm_input::HTML_QuickForm_input( $elementName, null, @@ -70,8 +79,9 @@ class HTML_QuickForm_button extends HTML_QuickForm_input } else { $value = $this->_attributes['value']; unset($this->_attributes['value']); - //$class = isset($this->_attributes['class']) ? $this->_attributes['class'] : 'btn btn-large'; $icon = isset($this->_attributes['icon']) ? $this->_attributes['icon'] : 'check'; + + unset($this->_attributes['icon']); $icon = ' '; return diff --git a/main/inc/lib/pear/HTML/QuickForm/element.php b/main/inc/lib/pear/HTML/QuickForm/element.php index 39aca8af8e..5d65a879a6 100755 --- a/main/inc/lib/pear/HTML/QuickForm/element.php +++ b/main/inc/lib/pear/HTML/QuickForm/element.php @@ -394,7 +394,7 @@ class HTML_QuickForm_element extends HTML_Common * @access public * @return void */ - function onQuickFormEvent($event, $arg, &$caller) + public function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'createElement': @@ -409,6 +409,7 @@ class HTML_QuickForm_element extends HTML_Common case 'updateValue': // constant values override both default and submitted ones // default values are overriden by submitted + $value = $this->_findValue($caller->_constantValues); if (null === $value) { diff --git a/main/survey/ch_dropdown.php b/main/survey/ch_dropdown.php index 20dcd34cbf..8c4450954e 100644 --- a/main/survey/ch_dropdown.php +++ b/main/survey/ch_dropdown.php @@ -11,9 +11,9 @@ class ch_dropdown extends survey_question * @param $formData * @return FormValidator */ - public function create_form($survey_data, $formData) + public function createForm($survey_data, $formData) { - parent::create_form($survey_data, $formData); + parent::createForm($survey_data, $formData); // The answers /*$this->html .= '
'; @@ -51,7 +51,7 @@ class ch_dropdown extends survey_question } } - return parent :: add_remove_buttons($formData); + parent :: addRemoveButtons($formData); } /** diff --git a/main/survey/ch_multiplechoice.php b/main/survey/ch_multiplechoice.php index f7af16402f..ae1907e338 100644 --- a/main/survey/ch_multiplechoice.php +++ b/main/survey/ch_multiplechoice.php @@ -11,9 +11,9 @@ class ch_multiplechoice extends survey_question * @param array $formData * @return FormValidator */ - public function create_form($survey_data, $formData) + public function createForm($survey_data, $formData) { - parent::create_form($survey_data, $formData); + parent::createForm($survey_data, $formData); $options = array( 'horizontal' => get_lang('Horizontal'), @@ -22,12 +22,12 @@ class ch_multiplechoice extends survey_question $this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options); $formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal'; + $this->getForm()->setDefaults($formData); $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120'); $total = count($formData['answers']); if (is_array($formData['answers'])) { foreach ($formData['answers'] as $key => $value) { - $this->getForm()->addHtmlEditor('answers['.$key.']', null, false, false, $config); if ($key < $total-1) { @@ -39,13 +39,12 @@ class ch_multiplechoice extends survey_question } if ($total> 2) { - $this->getForm()->addButton("delete_answer[$key]", get_lang('Delete')); + $this->getForm()->addButton("delete_answer[$key]", get_lang('Delete'), 'trash', 'danger'); } } } - $this->getForm()->setDefaults($formData); - return parent :: add_remove_buttons($formData); + parent :: addRemoveButtons($formData); } /** diff --git a/main/survey/ch_multipleresponse.php b/main/survey/ch_multipleresponse.php index 9dbff1a82f..c554bd72d7 100644 --- a/main/survey/ch_multipleresponse.php +++ b/main/survey/ch_multipleresponse.php @@ -7,12 +7,12 @@ class ch_multipleresponse extends survey_question { /** - * @param array $survey_data + * @param array $surveyData * @param array $formData */ - public function create_form($survey_data, $formData) + public function createForm($surveyData, $formData) { - parent::create_form($survey_data, $formData); + parent::createForm($surveyData, $formData); $options = array( 'horizontal' => get_lang('Horizontal'), 'vertical' => get_lang('Vertical') @@ -20,6 +20,7 @@ class ch_multipleresponse extends survey_question $this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options); $formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal'; + $this->getForm()->setDefaults($formData); $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120'); if (is_array($formData['answers'])) { @@ -45,9 +46,7 @@ class ch_multipleresponse extends survey_question } } - $this->getForm()->setDefaults($formData); - - return parent :: add_remove_buttons($formData); + parent :: addRemoveButtons($formData); } /** diff --git a/main/survey/ch_personality.php b/main/survey/ch_personality.php index 2c96e2b149..d4c6a03c34 100644 --- a/main/survey/ch_personality.php +++ b/main/survey/ch_personality.php @@ -13,9 +13,9 @@ class ch_personality extends survey_question * @author Patrick Cool , Ghent University * @version January 2007 */ - public function create_form($survey_data, $form_content) + public function createForm($survey_data, $form_content) { - parent::create_form($survey_data, $form_content); + parent::createForm($survey_data, $form_content); $this->html .= ' '; $this->html .= ' '.get_lang('DisplayAnswersHorVert').''; $this->html .= ' '; diff --git a/main/survey/ch_score.php b/main/survey/ch_score.php index aea090b6a3..11580b1fe8 100644 --- a/main/survey/ch_score.php +++ b/main/survey/ch_score.php @@ -10,9 +10,9 @@ class ch_score extends survey_question * @param array $survey_data * @param $form_content */ - public function create_form($survey_data, $formData) + public function createForm($survey_data, $formData) { - parent::create_form($survey_data, $formData); + parent::createForm($survey_data, $formData); $this->getForm()->addText('maximum_score', get_lang('MaximumScore')); @@ -40,7 +40,7 @@ class ch_score extends survey_question } } - return parent :: add_remove_buttons($formData); + parent :: addRemoveButtons($formData); } /** diff --git a/main/survey/ch_yesno.php b/main/survey/ch_yesno.php index 0a5b1c8773..69d21d71ce 100644 --- a/main/survey/ch_yesno.php +++ b/main/survey/ch_yesno.php @@ -7,12 +7,12 @@ class ch_yesno extends survey_question { /** - * @param array $survey_data + * @param array $surveyData * @param array $formData */ - public function create_form($survey_data, $formData) + public function createForm($surveyData, $formData) { - parent::create_form($survey_data, $formData); + parent::createForm($surveyData, $formData); $options = array( 'horizontal' => get_lang('Horizontal'), @@ -21,6 +21,7 @@ class ch_yesno extends survey_question $this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options); $formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal'; + $this->getForm()->setDefaults($formData); /*// Horizontal or vertical $this->html .= '
'; @@ -46,8 +47,6 @@ class ch_yesno extends survey_question $this->getForm()->addHtmlEditor('answers[0]', get_lang('AnswerOptions'), true, false, $config); $this->getForm()->addHtmlEditor('answers[1]', null, true, false, $config); - $this->getForm()->setDefaults($formData); - /*$this->html .= '
'; $this->html .= '