/**
  *
  * @throws EE_Error
  * @return string of html to display the field
  */
 public function display()
 {
     $input = $this->get_input();
     $input->set_label_sizes();
     $label_size_class = $input->get_label_size_class();
     $html = '';
     foreach ($input->options() as $value => $display_text) {
         $value = $input->get_normalization_strategy()->unnormalize($value);
         $html_id = $this->get_sub_input_id($value);
         $html .= EEH_HTML::nl(0, 'radio');
         $html .= '<label for="' . $html_id . '"';
         $html .= ' id="' . $html_id . '-lbl"';
         $html .= ' class="ee-radio-label-after' . $label_size_class . '">';
         $html .= EEH_HTML::nl(1, 'radio');
         $html .= '<input id="' . $html_id . '"';
         $html .= ' name="' . $input->html_name() . '"';
         $html .= ' class="' . $input->html_class() . '"';
         $html .= ' style="' . $input->html_style() . '"';
         $html .= ' type="radio"';
         $html .= ' value="' . esc_attr($value) . '"';
         $html .= $input->raw_value() === $value ? ' checked="checked"' : '';
         $html .= ' ' . $this->_input->other_html_attributes();
         $html .= '>&nbsp;';
         $html .= $display_text;
         $html .= EEH_HTML::nl(-1, 'radio') . '</label>';
     }
     $html .= EEH_HTML::div('', '', 'clear-float');
     $html .= EEH_HTML::divx();
     return $html;
 }
 /**
  *
  * @throws EE_Error
  * @return string of html to display the field
  */
 public function display()
 {
     $input = $this->get_input();
     //d( $input );
     $multi = count($input->options()) > 1 ? TRUE : FALSE;
     $input->set_label_sizes();
     $label_size_class = $input->get_label_size_class();
     $html = '';
     if (!is_array($input->raw_value()) && $input->raw_value() !== NULL) {
         EE_Error::doing_it_wrong('EE_Checkbox_Display_Strategy::display()', sprintf(__('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'), $input->html_id(), var_export($input->raw_value(), true), $input->html_name() . '[]'), '4.8.1');
     }
     $input_raw_value = (array) $input->raw_value();
     foreach ($input->options() as $value => $display_text) {
         $value = $input->get_normalization_strategy()->unnormalize_one($value);
         $html_id = $multi ? $this->get_sub_input_id($value) : $input->html_id();
         $html .= EEH_HTML::nl(0, 'checkbox');
         $html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">';
         $html .= EEH_HTML::nl(1, 'checkbox');
         $html .= '<input type="checkbox"';
         $html .= ' name="' . $input->html_name() . '[]"';
         $html .= ' id="' . $html_id . '"';
         $html .= ' class="' . $input->html_class() . '"';
         $html .= ' style="' . $input->html_style() . '"';
         $html .= ' value="' . esc_attr($value) . '"';
         $html .= !empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : '';
         $html .= ' ' . $this->_input->other_html_attributes();
         $html .= '>&nbsp;';
         $html .= $display_text;
         $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
     }
     return $html;
 }
 /**
  *
  * @throws EE_Error
  * @return string of html to display the field
  */
 public function display()
 {
     if (!$this->_input instanceof EE_Form_Input_With_Options_Base) {
         throw new EE_Error(sprintf(__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso")));
     }
     $html = EEH_HTML::nl(0, 'select');
     $html .= '<select multiple';
     $html .= ' id="' . $this->_input->html_id() . '"';
     $html .= ' name="' . $this->_input->html_name() . '[]"';
     $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
     $html .= ' class="' . $class . '"';
     // add html5 required
     $html .= $this->_input->required() ? ' required' : '';
     $html .= ' style="' . $this->_input->html_style() . '"';
     $html .= '>';
     EE_Registry::instance()->load_helper('Array');
     EEH_HTML::indent(1, 'select');
     if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
         throw new EE_Error(sprintf(__("Select multiple display strategy does not allow for nested arrays of options.", "event_espresso")));
     } else {
         $html .= $this->_display_options($this->_input->options());
     }
     $html .= EEH_HTML::nl(-1, 'select') . "</select>";
     return $html;
 }
 /**
  *
  * @throws EE_Error
  * @return string of html to display the field
  */
 function display()
 {
     if (!$this->_input instanceof EE_Form_Input_With_Options_Base) {
         throw new EE_Error(sprintf(__('Can not use Radio Button Display Strategy with an input that doesn\'t have options', 'event_espresso')));
     }
     $this->_input->set_label_sizes();
     $label_size_class = $this->_input->get_label_size_class();
     $html = '';
     foreach ($this->_input->options() as $value => $display_text) {
         $value = $this->_input->get_normalization_strategy()->unnormalize($value);
         $html_id = $this->_append_chars($this->_input->html_id(), '-') . sanitize_key($value);
         $html .= EEH_HTML::nl(0, 'radio');
         $html .= '<label for="' . $html_id . '"';
         $html .= ' id="' . $html_id . '-lbl"';
         $html .= ' class="ee-radio-label-after' . $label_size_class . '">';
         $html .= EEH_HTML::nl(1, 'radio');
         $html .= '<input id="' . $html_id . '"';
         $html .= ' name="' . $this->_input->html_name() . '"';
         $html .= ' class="' . $this->_input->html_class() . '"';
         $html .= ' style="' . $this->_input->html_style() . '"';
         $html .= ' type="radio"';
         $html .= ' value="' . esc_attr($value) . '"';
         $html .= $this->_input->raw_value() === $value ? ' checked="checked"' : '';
         $html .= '>&nbsp;';
         $html .= $display_text;
         $html .= EEH_HTML::nl(-1, 'radio') . '</label>';
     }
     $html .= EEH_HTML::div('', '', 'clear-float');
     $html .= EEH_HTML::divx();
     return $html;
 }
 /**
  * Lays out the row for the input, including label and errors
  * @param EE_Form_Input_Base $input
  * @return string
  */
 public function layout_input($input)
 {
     $html = '';
     if ($input instanceof EE_Hidden_Input) {
         $html .= EEH_HTML::nl() . $input->get_html_for_input();
     } else {
         if ($input instanceof EE_Submit_Input) {
             $html .= EEH_HTML::br();
             $html .= $input->get_html_for_input();
         } else {
             if ($input instanceof EE_Select_Input) {
                 $html .= EEH_HTML::br();
                 $html .= EEH_HTML::nl(1) . $input->get_html_for_label();
                 $html .= EEH_HTML::nl() . $input->get_html_for_errors();
                 $html .= EEH_HTML::nl() . $input->get_html_for_input();
                 $html .= EEH_HTML::nl() . $input->get_html_for_help();
                 $html .= EEH_HTML::br();
             } else {
                 if ($input instanceof EE_Form_Input_With_Options_Base) {
                     $html .= EEH_HTML::br();
                     $html .= EEH_HTML::nl() . $input->get_html_for_errors();
                     $html .= EEH_HTML::nl() . $input->get_html_for_input();
                     $html .= EEH_HTML::nl() . $input->get_html_for_help();
                 } else {
                     $html .= EEH_HTML::br();
                     $html .= EEH_HTML::nl(1) . $input->get_html_for_label();
                     $html .= EEH_HTML::nl() . $input->get_html_for_errors();
                     $html .= EEH_HTML::nl() . $input->get_html_for_input();
                     $html .= EEH_HTML::nl() . $input->get_html_for_help();
                 }
             }
         }
     }
     return $html;
 }
 /**
  *
  * @throws EE_Error
  * @return string of html to display the field
  */
 function display()
 {
     if (!$this->_input instanceof EE_Form_Input_With_Options_Base) {
         throw new EE_Error(sprintf(__("Cannot use Checkbox Display Strategy with an input that doesn't have options", "event_espresso")));
     }
     //d( $this->_input );
     $multi = count($this->_input->options()) > 1 ? TRUE : FALSE;
     $this->_input->set_label_sizes();
     $label_size_class = $this->_input->get_label_size_class();
     $html = '';
     if (!is_array($this->_input->raw_value()) && $this->_input->raw_value() !== NULL) {
         EE_Error::doing_it_wrong('EE_Checkbox_Display_Strategy::display()', sprintf(__('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'), $this->_input->html_id(), var_export($this->_input->raw_value(), true), $this->_input->html_name() . '[]'), '4.8.1');
     }
     $input_raw_value = (array) $this->_input->raw_value();
     foreach ($this->_input->options() as $value => $display_text) {
         $option_value_as_string = $this->_input->get_normalization_strategy()->unnormalize_one($value);
         $html_id = $multi ? $this->_input->html_id() . '-' . sanitize_key($option_value_as_string) : $this->_input->html_id();
         $html .= EEH_HTML::nl(0, 'checkbox');
         $html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">';
         $html .= EEH_HTML::nl(1, 'checkbox');
         $html .= '<input type="checkbox"';
         $html .= ' name="' . $this->_input->html_name() . '[]"';
         $html .= ' id="' . $html_id . '"';
         $html .= ' class="' . $this->_input->html_class() . '"';
         $html .= ' style="' . $this->_input->html_style() . '"';
         $html .= ' value="' . esc_attr($value) . '"';
         $html .= !empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : '';
         $html .= '>&nbsp;';
         $html .= $display_text;
         $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
     }
     return $html;
 }
 /**
  *
  * @throws EE_Error
  * @return string of html to display the field
  */
 function display()
 {
     if (!$this->_input instanceof EE_Form_Input_With_Options_Base) {
         throw new EE_Error(sprintf(__("Cannot use Checkbox Display Strategy with an input that doesn't have options", "event_espresso")));
     }
     //d( $this->_input );
     $multi = count($this->_input->options()) > 1 ? TRUE : FALSE;
     $this->_input->set_label_sizes();
     $label_size_class = $this->_input->get_label_size_class();
     $html = '';
     foreach ($this->_input->options() as $value => $display_text) {
         $option_value_as_string = $this->_input->get_normalization_strategy()->unnormalize_one($value);
         $html_id = $multi ? $this->_input->html_id() . '-' . sanitize_key($option_value_as_string) : $this->_input->html_id();
         $html .= EEH_HTML::nl(0, 'checkbox');
         $html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">';
         $html .= EEH_HTML::nl(1, 'checkbox');
         $html .= '<input type="checkbox"';
         $html .= ' name="' . $this->_input->html_name() . '[]"';
         $html .= ' id="' . $html_id . '"';
         $html .= ' class="' . $this->_input->html_class() . '"';
         $html .= ' style="' . $this->_input->html_style() . '"';
         $html .= ' value="' . esc_attr($value) . '"';
         $html .= $this->_input->raw_value() && in_array($value, $this->_input->raw_value()) ? ' checked="checked"' : '';
         $html .= '>&nbsp;';
         $html .= $display_text;
         $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
     }
     return $html;
 }
 /**
  * Displays a flat list of options as option tags
  * @param array $options
  * @return string
  */
 protected function _display_options($options)
 {
     $html = '';
     EEH_HTML::indent(1, 'option');
     foreach ($options as $value => $display_text) {
         $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
         $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : '';
         $html .= EEH_HTML::nl(0, 'option') . '<option value="' . esc_attr($unnormalized_value) . '"' . $selected . '>' . $display_text . '</option>';
     }
     EEH_HTML::indent(-1, 'option');
     return $html;
 }
 /**
  * Lays out the row for the input, including label and errors
  * @param EE_Form_Input_Base $input
  * @return string
  */
 public function layout_input($input)
 {
     $html = '';
     if ($input instanceof EE_Hidden_Input) {
         $html .= $input->get_html_for_input();
     } else {
         $html_for_input = $input->get_html_for_input();
         $html_for_input .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : '';
         $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : '';
         $html .= EEH_HTML::tr(EEH_HTML::th($input->get_html_for_label()) . EEH_HTML::td($html_for_input));
     }
     return $html;
 }
 /**
  * Lays out the row for the input, including label and errors
  * @param EE_Form_Input_Base $input
  * @return string
  */
 public function layout_input($input)
 {
     if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy) {
         $input->set_html_class($input->html_class() . ' large-text');
     }
     if ($input instanceof EE_Text_Area_Input) {
         $input->set_rows(4);
         $input->set_cols(60);
     }
     $input_html = $input->get_html_for_input();
     // maybe add errors and help text ?
     $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : '';
     $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : '';
     //overriding parent to add wp admin specific things.
     $html = '';
     if ($input instanceof EE_Hidden_Input) {
         $html .= EEH_HTML::no_row($input->get_html_for_input(), 2);
     } else {
         $html .= EEH_HTML::tr(EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"') . EEH_HTML::td($input_html));
     }
     return $html;
 }
 /**
  * Converts a 1d array of key-value pairs into html hidden inputs
  * and returns the string of html
  *
  * @param array $args key-value pairs
  * @return string
  */
 protected function _args_as_inputs($args)
 {
     $html = '';
     if ($args !== null && is_array($args)) {
         foreach ($args as $name => $value) {
             $html .= EEH_HTML::nl(0) . '<input type="hidden" name="' . $name . '" value="' . esc_attr($value) . '"/>';
         }
     }
     return $html;
 }
 /**
  * Lays out a row for the subsection
  * @param EE_Form_Section_Proper $form_section
  * @return string
  */
 public function layout_subsection($form_section)
 {
     //		d( $form_section );
     return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
 }
 /**
  * returns HTML for generating the closing form HTML tag (</form>)
  * @return string
  */
 public function form_close()
 {
     return EEH_HTML::nl(-1, 'form') . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl();
 }
 /**
  * closing div tag for a form
  * @return string
  */
 public function layout_form_end()
 {
     return EEH_HTML::nl(-1);
 }
 /**
  * Converts a 1d array of key-value pairs into html hidden inputs
  * and returns the string of html
  * @param array $args key-value pairs
  * @return string
  */
 protected function _args_as_inputs($args)
 {
     $html = '';
     if ($args !== NULL && is_array($args)) {
         EE_Registry::instance()->load_helper('HTML');
         foreach ($args as $name => $value) {
             $html .= EEH_HTML::nl(0) . '<input type="hidden" name="' . $name . '" value="' . esc_attr($value) . '"/>';
         }
     }
     return $html;
 }
 /**
  * closing div tag for a form
  * @return string
  */
 public function layout_form_end()
 {
     return EEH_HTML::nl(-1) . '</fieldset>';
 }
예제 #17
0
 /**
  * Generates an html <--  comment --> tag
  * 	usage: echo comment( 'this is a comment' );
  *
  * @param string $comment
  * @return string
  */
 public static function comment($comment = '')
 {
     return !empty($comment) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : '';
 }
 /**
  * Does an action and hook onto the end of teh form
  * @param string $html
  * @return string
  */
 public function add_form_section_hooks_and_filters($html)
 {
     // replace dashes and spaces with underscores
     $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
     do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
     $html = apply_filters('AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section);
     $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
     $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
     return $html;
 }