protected function _country_settings() { $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US'; $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO; //load field generator helper $this->_template_args['values'] = $this->_yes_no_values; $this->_template_args['countries'] = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => __('Select Country', 'event_espresso'), 'QST_system' => 'admin-country')), EE_Answer::new_instance(array('ANS_ID' => 0, 'ANS_value' => $CNT_ISO)), array('input_id' => 'country', 'input_name' => 'country', 'input_prefix' => '', 'append_qstn_id' => FALSE)); // EEH_Debug_Tools::printr( $this->_template_args['countries'], 'countries <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); $this->_template_args['country_details_settings'] = $this->display_country_settings(); $this->_template_args['country_states_settings'] = $this->display_country_states(); $this->_set_add_edit_form_tags('update_country_settings'); $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); $this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', $this->_template_args, TRUE); $this->display_admin_page_with_no_sidebar(); }
/** * Metabox for person details * @param WP_Post $post wp post object * @return string person address details (and form) */ public function person_address_details($post) { //get people object (should already have it) $this->_template_args['person'] = $this->_cpt_model_obj; $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => __('State/Province', 'event_espresso'), 'QST_system' => 'admin-state')), EE_Answer::new_instance(array('ANS_ID' => 0, 'ANS_value' => $this->_cpt_model_obj->state_ID())), array('input_id' => 'STA_ID', 'input_name' => 'STA_ID', 'input_prefix' => '', 'append_qstn_id' => FALSE))); $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => __('Country', 'event_espresso'), 'QST_system' => 'admin-country')), EE_Answer::new_instance(array('ANS_ID' => 0, 'ANS_value' => $this->_cpt_model_obj->country_ID())), array('input_id' => 'CNT_ISO', 'input_name' => 'CNT_ISO', 'input_prefix' => '', 'append_qstn_id' => FALSE))); $template = EEA_PEOPLE_ADDON_ADMIN_TEMPLATE_PATH . 'people_address_details_metabox_content.template.php'; EEH_Template::display_template($template, $this->_template_args); }
public function column_required(EE_Question $item) { return $item->required() ? 'Yes' : ''; }
/** * @param EE_Registration $registration * @param EE_Question $question * @param mixed EE_Answer|NULL $answer * @return EE_Form_Input_Base */ public function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) { // d( $registration ); // d( $question ); // d( $answer ); // array of params to pass to parent constructor. // possible values: // html_id; // html_class; // html_style; // name; // html_name; // html_label_id; // html_label_class; // html_label_style; // html_label_text; // html_label; // html_help_text; // html_help_class = 'description'; // html_help_style; // raw_value; $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); $input_constructor_args = array('html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, 'required' => $question->required() ? TRUE : FALSE, 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, 'html_label_class' => 'ee-reg-qstn', 'html_label_text' => $question->display_text(), 'required_validation_error_message' => $question->required_text()); // has this question been answered ? if ($answer instanceof EE_Answer) { if ($answer->ID()) { $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; $input_constructor_args['html_id'] .= '-' . $answer->ID(); $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); } $input_constructor_args['default'] = $answer->value(); } //add "-lbl" to the end of the label id $input_constructor_args['html_label_id'] .= '-lbl'; switch ($question->type()) { // Text case EEM_Question::QST_type_text: if ($identifier == 'email') { return new EE_Email_Input($input_constructor_args); } else { return new EE_Text_Input($input_constructor_args); } break; // Textarea // Textarea case EEM_Question::QST_type_textarea: return new EE_Text_Area_Input($input_constructor_args); break; // Radio Buttons // Radio Buttons case EEM_Question::QST_type_radio: return new EE_Radio_Button_Input($question->options(), $input_constructor_args); break; // Dropdown // Dropdown case EEM_Question::QST_type_dropdown: return new EE_Select_Input($question->options(), $input_constructor_args); break; // State Dropdown // State Dropdown case EEM_Question::QST_type_state: $state_options = array('' => array('' => '')); $states = $this->checkout->action == 'process_reg_step' ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_active_states(); if (!empty($states)) { foreach ($states as $state) { if ($state instanceof EE_State) { $state_options[$state->country()->name()][$state->ID()] = $state->name(); } } } $state_options = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', $state_options, $this, $registration, $question, $answer); return new EE_State_Select_Input($state_options, $input_constructor_args); break; // Country Dropdown // Country Dropdown case EEM_Question::QST_type_country: $country_options = array('' => ''); // get possibly cached list of countries $countries = $this->checkout->action == 'process_reg_step' ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); if (!empty($countries)) { foreach ($countries as $country) { if ($country instanceof EE_Country) { $country_options[$country->ID()] = $country->name(); } } } $country_options = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', $country_options, $this, $registration, $question, $answer); return new EE_Country_Select_Input($country_options, $input_constructor_args); break; // Checkboxes // Checkboxes case EEM_Question::QST_type_checkbox: return new EE_Checkbox_Multi_Input($question->options(), $input_constructor_args); break; // Date // Date case EEM_Question::QST_type_date: return new EE_Datepicker_Input($input_constructor_args); break; case EEM_Question::QST_type_html_textarea: $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); $input = new EE_Text_Area_Input($input_constructor_args); $input->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); return $input; // fallback // fallback default: $default_input = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', null, $question->type(), $question, $input_constructor_args); if (!$default_input) { $default_input = new EE_Text_Input($input_constructor_args); } return $default_input; } }
public function venue_address_metabox() { $template_args['_venue'] = $this->_cpt_model_obj; $template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input($QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => 'State', 'QST_system' => 'state')), EE_Answer::new_instance(array('ANS_value' => $this->_cpt_model_obj->state_ID())), array('input_name' => 'sta_id', 'input_id' => 'sta_id', 'input_class' => '', 'input_prefix' => '', 'append_qstn_id' => FALSE))); $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input($QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => 'Country', 'QST_system' => 'country')), EE_Answer::new_instance(array('ANS_value' => $this->_cpt_model_obj->country_ID())), array('input_name' => 'cnt_iso', 'input_id' => 'cnt_iso', 'input_class' => '', 'input_prefix' => '', 'append_qstn_id' => FALSE))); $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php'; EEH_Template::display_template($template, $template_args); }
/** * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. This will be used in our dummy data setup * @return array */ private function _get_some_q_and_as() { $quests_array = array(0 => array(555, __('What is your favorite planet?', 'event_espresso'), 0), 1 => array(556, __('What is your favorite food?', 'event_espresso'), 0), 2 => array(557, __('How many lightyears have you travelled', 'event_espresso'), 0)); $ans_array = array(0 => array(999, 555, 'Tattoine'), 1 => array(1000, 555, 'Alderaan'), 2 => array(1001, 555, 'Dantooine'), 3 => array(1002, 556, 'Fish Fingers'), 4 => array(1003, 556, 'Sushi'), 5 => array(1004, 556, 'Water'), 6 => array(1005, 557, 'A lot'), 7 => array(1006, 557, "That's none of your business."), 8 => array(1007, 557, "People less travel me then.")); $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); EE_Registry::instance()->load_class('Question', array(), FALSE, TRUE, TRUE); EE_Registry::instance()->load_class('Answer', array(), FALSE, TRUE, TRUE); //first the questions foreach ($quests_array as $qst) { $qstobj = array_combine($qst_columns, $qst); $qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj); } //now the answers (and we'll setup our arrays) $q_n_as = array(); foreach ($ans_array as $ans) { $ansobj = array_combine($ans_columns, $ans); $ansobj = EE_Answer::new_instance($ansobj); $q_n_as['answers'][$ansobj->ID()] = $ansobj; $q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')]; } return $q_n_as; }
/** * display_add_new_state_micro_form * * @access public * @return string */ public static function display_add_new_state_micro_form($input_html, $question, $answer, $name, $id, $class, $system_ID) { // load JS add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); $output = ''; // we're only doing this for state select inputs if ($system_ID == 'state') { // add hidden input to indicate that a new state is being added $output .= EEH_Form_Fields::hidden_input(str_replace('state', 'add_new_state', $name), 0, str_replace('state', 'add_new_state', $id)); $output .= '<a id="display-' . $id . '" class="ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js" rel="' . $id . '">' . __('click here to add a new state/province', 'event_espresso') . '</a>'; $output .= '<div id="' . $id . '-dv" class="ee-form-add-new-state-dv" style="display: none;">'; $output .= '<h6>' . __('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso') . '</h6>'; $output .= '<ul>'; $output .= sprintf(__('%1$sfirst select the Country that your State/Province belongs to%2$s%1$senter the name of your State/Province%2$s%1$senter a two to six letter abbreviation for the name of your State/Province%2$s%1$sclick the ADD button%2$s', 'event_espresso'), '<li>', '</li>'); $output .= '</ul>'; // NEW STATE COUNTRY $cntry_id = str_replace('state', 'new_state_country', $id); $cntry_input = str_replace('state', 'new_state_country', $name); $country = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => __('New State/Province Country', 'event_espresso'), 'QST_system' => 'admin-country', 'QST_type' => EEM_Question::QST_type_dropdown, 'QST_required' => FALSE)), EE_Answer::new_instance(array('ANS_value' => EE_Registry::instance()->REQ->is_set($cntry_input) ? EE_Registry::instance()->REQ->get($cntry_input) : '')), array('input_name' => $cntry_input, 'input_id' => $cntry_id, 'input_class' => $class, 'input_prefix' => '', 'append_qstn_id' => FALSE)); $output .= EEH_Form_Fields::generate_form_input($country); // NEW STATE NAME $state_id = str_replace('state', 'new_state_name', $id); $state_name = str_replace('state', 'new_state_name', $name); $new_state_name = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => __('New State/Province Name', 'event_espresso'), 'QST_system' => '', 'QST_type' => EEM_Question::QST_type_text, 'QST_required' => FALSE)), EE_Answer::new_instance(array('ANS_value' => EE_Registry::instance()->REQ->is_set($state_name) ? EE_Registry::instance()->REQ->get($state_name) : '')), array('input_name' => $state_name, 'input_id' => $state_id, 'input_class' => $class, 'input_prefix' => '', 'append_qstn_id' => FALSE)); $output .= EEH_Form_Fields::generate_form_input($new_state_name); // NEW STATE ABBREVIATION $abbrv_id = str_replace('state', 'new_state_abbrv', $id); $abbrv_name = str_replace('state', 'new_state_abbrv', $name); $new_state_abbrv = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => __('New State/Province Abbreviation', 'event_espresso'), 'QST_system' => '', 'QST_type' => EEM_Question::QST_type_text, 'QST_required' => FALSE)), EE_Answer::new_instance(array('ANS_value' => EE_Registry::instance()->REQ->is_set($abbrv_name) ? EE_Registry::instance()->REQ->get($abbrv_name) : '')), array('input_name' => $abbrv_name, 'input_id' => $abbrv_id, 'input_class' => $class, 'input_prefix' => '', 'append_qstn_id' => FALSE)); // add filters for reducing size of State Abbrv text input, and adding an "ADD" button, as well as a "cancel" button add_filter('FHEE__EEH_Form_Fields__additional_form_field_attributes', array('EED_Add_New_State', 'set_new_state_input_size')); add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Add_New_State', 'add_new_state_submit_button'), 1, 3); add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Add_New_State', 'cancel_new_state'), 2, 3); $output .= EEH_Form_Fields::generate_form_input($new_state_abbrv); // remove the filters from above so that they don't affect any other inputs remove_filter('FHEE__EEH_Form_Fields__additional_form_field_attributes', array('EED_Add_New_State', 'set_new_state_input_size')); remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Add_New_State', 'add_new_state_submit_button'), 1, 3); remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Add_New_State', 'cancel_new_state'), 2, 3); $output .= '</div>'; } return $input_html . $output; }
/** * @param string $action */ protected function _edit_question($action = 'add') { do_action('AHEE_log', __FILE__, __FUNCTION__, ''); $ID = isset($this->_req_data['QST_ID']) && !empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE; $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); // add PRC_ID to title if editing $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; if ($ID) { $question = $this->_question_model->get_one_by_ID($ID); $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); } else { $question = EE_Question::new_instance(); $question->set_order_to_latest(); $this->_set_add_edit_form_tags('insert_question'); } $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); $this->_template_args['QST_ID'] = $ID; $this->_template_args['question'] = $question; $this->_template_args['question_types'] = $question_types; $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID()); $this->_set_publish_post_box_vars('id', $ID); $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE); // the details template wrapper $this->display_admin_page_with_sidebar(); }
/** * generate_question_form_inputs_for_object * * @access protected * @param bool|object $object $object * @param array $input_types * @return array */ static function generate_question_form_inputs_for_object($object = FALSE, $input_types = array()) { if (!is_object($object)) { return FALSE; } $inputs = array(); $fields = $object->get_model()->field_settings(FALSE); // $pk = $object->ID(); <<< NO! // printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); // printr( $fields, '$fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); // printr( $input_types, '$input_types <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); foreach ($fields as $field_ID => $field) { if ($field instanceof EE_Model_Field_Base) { // echo '<h4>$field_ID : ' . $field_ID . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // printr( $field, '$field <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if (isset($input_types[$field_ID])) { // get saved value for field $value = $object->get($field_ID); // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // if no saved value, then use default $value = $value !== NULL ? $value : $field->get_default_value(); // if ( $field_ID == 'CNT_active' ) // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; // determine question type $type = isset($input_types[$field_ID]) ? $input_types[$field_ID]['type'] : 'TEXT'; // input name $input_name = isset($input_types[$field_ID]) && isset($input_types[$field_ID]['input_name']) ? $input_types[$field_ID]['input_name'] . '[' . $field_ID . ']' : $field_ID; // css class for input $class = isset($input_types[$field_ID]['class']) && !empty($input_types[$field_ID]['class']) ? ' ' . $input_types[$field_ID]['class'] : ''; // whether to apply htmlentities to answer $htmlentities = isset($input_types[$field_ID]['htmlentities']) ? $input_types[$field_ID]['htmlentities'] : TRUE; // whether to apply htmlentities to answer $label_b4 = isset($input_types[$field_ID]['label_b4']) ? $input_types[$field_ID]['label_b4'] : FALSE; // whether to apply htmlentities to answer $use_desc_4_label = isset($input_types[$field_ID]['use_desc_4_label']) ? $input_types[$field_ID]['use_desc_4_label'] : FALSE; // create EE_Question_Form_Input object $QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => $field->get_nicename(), 'QST_type' => $type)), EE_Answer::new_instance(array('ANS_ID' => 0, 'QST_ID' => 0, 'REG_ID' => 0, 'ANS_value' => $value)), array('input_id' => $field_ID . '-' . $object->ID(), 'input_name' => $input_name, 'input_class' => $field_ID . $class, 'input_prefix' => '', 'append_qstn_id' => FALSE, 'htmlentities' => $htmlentities, 'label_b4' => $label_b4, 'use_desc_4_label' => $use_desc_4_label)); // does question type have options ? if (in_array($type, array('DROPDOWN', 'SINGLE', 'MULTIPLE')) && isset($input_types[$field_ID]) && isset($input_types[$field_ID]['options'])) { foreach ($input_types[$field_ID]['options'] as $option) { $option = stripslashes_deep($option); $option_id = !empty($option['id']) ? $option['id'] : 0; $QSO = EE_Question_Option::new_instance(array('QSO_value' => (string) $option_id, 'QSO_desc' => $option['text'], 'QSO_deleted' => FALSE)); // all QST (and ANS) properties can be accessed indirectly thru QFI $QFI->add_temp_option($QSO); } } // we don't want ppl manually changing primary keys cuz that would just lead to total craziness man if ($field_ID == $object->get_model()->primary_key_name()) { $QFI->set('QST_disabled', TRUE); } //printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $inputs[$field_ID] = $QFI; // if ( $field_ID == 'CNT_active' ) { // printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); // } } } } return $inputs; }
/** * generate s HTML for the billing info form during registration * @access protected * @param array $billing_inputs - array of input field details * @param array $section - what part of the billing info form, "address", "credit_card", or "other" * @return string */ protected function _generate_billing_info_form_fields($billing_inputs = array(), $section = FALSE) { do_action('AHEE_log', __FILE__, __FUNCTION__, ''); if (empty($billing_inputs) || !$section) { return; } global $wp_filter, $css_class; // fill out section name $section = '_billing_info_' . $section . '_fields'; // if you don't behave - this is what you're gonna get !!! $output = ''; // cycle thru billing inputs foreach ($billing_inputs as $input_key => $billing_input) { // is the billing input in the requested section ? if (in_array($input_key, $this->{$section})) { // required fields get a * $required = $billing_input['required'] ? EEH_Form_Fields::prep_required(array('class' => 'required', 'label' => '<em>*</em>')) : ''; // answer $answer = EE_Registry::instance()->REQ->is_set($input_key) ? EE_Registry::instance()->REQ->get($input_key) : $billing_input['value']; if ($input_key == '_reg-page-billing-card-exp-date-mnth-' . $this->_gateway_name) { // Credit Card MONTH add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_month_input_wrap'), 10, 2); remove_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2); remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2); $output .= EEH_Form_Fields::select(__('Expiry Date', 'event_espresso'), $answer, EEH_Form_Fields::two_digit_months_dropdown_options(), $input_key, $input_key, $css_class . ' ee-credit-card-month display-inline small-txt', $required, '', '', '', FALSE, TRUE, FALSE); remove_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_month_input_wrap'), 10, 2); add_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2); add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2); $output .= "\n\t\t\t" . ' / '; } elseif ($input_key == '_reg-page-billing-card-exp-date-year-' . $this->_gateway_name) { // Credit Card YEAR // remove label add_filter('FHEE__EEH_Form_Fields__label_html', array('EEH_Form_Fields', 'remove_label_keep_required_msg'), 10, 2); add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_year_input_wrap'), 10, 2); remove_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2); remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2); $output .= EEH_Form_Fields::select(__('Year', 'event_espresso'), $answer, EEH_Form_Fields::next_decade_two_digit_year_dropdown_options(), $input_key, $input_key, $css_class . ' ee-credit-card-year display-inline small-txt', $required, '', '', '', FALSE, TRUE, FALSE); // remove filter that removes label, or else no other inputs will have labels remove_filter('FHEE__EEH_Form_Fields__label_html', array('EEH_Form_Fields', 'remove_label_keep_required_msg'), 10, 2); remove_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_year_input_wrap'), 10, 2); add_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2); add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2); $output .= "\n\t\t\t" . '<span class="small-text lt-grey-text">' . __('(mm/yy)', 'event_espresso') . '</span>'; } else { // create question form input $QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => $billing_input['label'], 'QST_system' => $billing_input['db-col'], 'QST_type' => $billing_input['input'], 'QST_required' => $billing_input['required'])), EE_Answer::new_instance(array('ANS_value' => $answer)), array('input_name' => $input_key, 'input_id' => $input_key, 'input_class' => $css_class, 'input_prefix' => '', 'append_qstn_id' => FALSE)); // add options if (isset($billing_input['options'])) { $options = is_array($billing_input['options']) ? $billing_input['options'] : explode(',', $billing_input['options']); foreach ($options as $option) { $QSO = EE_Question_Option::new_instance(array('QSO_value' => $option, 'QSO_desc' => $option)); $QFI->add_temp_option($QSO); } } $output .= EEH_Form_Fields::generate_form_input($QFI); } } // end if ( in_array( $input_key, $this->$section )) } // end foreach( $billing_inputs as $input_key => $billing_input ) return $output; }
public function column_display_text(EE_Question $item) { $system_question = $item->is_system_question(); $actions = array(); if (!defined('REG_ADMIN_URL')) { define('REG_ADMIN_URL', EVENTS_ADMIN_URL); } $edit_query_args = array('action' => 'edit_question', 'QST_ID' => $item->ID()); $trash_query_args = array('action' => 'trash_question', 'QST_ID' => $item->ID()); $restore_query_args = array('action' => 'restore_question', 'QST_ID' => $item->ID()); $delete_query_args = array('action' => 'delete_questions', 'QST_ID' => $item->ID()); $duplicate_query_args = array('action' => 'duplicate_question', 'QST_ID' => $item->ID()); $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL); $trash_link = EE_Admin_Page::add_query_args_and_nonce($trash_query_args, EE_FORMS_ADMIN_URL); $restore_link = EE_Admin_Page::add_query_args_and_nonce($restore_query_args, EE_FORMS_ADMIN_URL); $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EE_FORMS_ADMIN_URL); $duplicate_link = EE_Admin_Page::add_query_args_and_nonce($duplicate_query_args, EE_FORMS_ADMIN_URL); if (EE_Registry::instance()->CAP->current_user_can('ee_edit_question', 'espresso_registration_form_edit_question', $item->ID())) { $actions = array('edit' => '<a href="' . $edit_link . '" title="' . __('Edit Question', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'); } if (!$system_question && $this->_view != 'trash' && EE_Registry::instance()->CAP->current_user_can('ee_delete_question', 'espresso_registration_form_trash_question', $item->ID())) { $actions['delete'] = '<a href="' . $trash_link . '" title="' . __('Trash Question', 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; } if ($this->_view == 'trash') { if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question', 'espresso_registration_form_restore_question', $item->ID())) { $actions['restore'] = '<a href="' . $restore_link . '" title="' . __('Restore Question', 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; } if ($item->count_related('Answer') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_question', 'espresso_registration_form_delete_questions', $item->ID())) { $actions['delete'] = '<a href="' . $delete_link . '" title="' . __('Delete Question Permanently', 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>'; } } if (EE_Registry::instance()->CAP->current_user_can('ee_edit_questions', 'espresso_registration_form_edit_question')) { $actions['duplicate'] = '<a href="' . $duplicate_link . '" title="' . __('Duplicate Question', 'event_espresso') . '">' . __('Duplicate', 'event_espresso') . '</a>'; } $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_question', 'espresso_registration_form_edit_question', $item->ID()) ? '<strong><a class="row-title" href="' . $edit_link . '">' . $item->display_text() . '</a></strong>' : $item->display_text(); $content .= $this->row_actions($actions); return $content; }
/** * inject_new_reg_country_into_options * * @access public * @param \EE_Country[] $country_options * @param \EE_SPCO_Reg_Step_Attendee_Information $reg_step * @param \EE_Registration $registration * @param \EE_Question $question * @param $answer * @return bool */ public static function inject_new_reg_country_into_options($country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country) { $CNT_ISO = $answer->value(); if (!empty($CNT_ISO)) { $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); if ($country instanceof EE_Country) { if (!isset($country_options[$CNT_ISO])) { $country_options[$CNT_ISO] = $country->name(); } } } } return $country_options; }
/** * decaf venue metabox * @return string form for Event Venue */ public function venue_metabox() { //first let's see if we have a venue already $event_id = $this->_cpt_model_obj->ID(); $venue = !empty($event_id) ? $this->_cpt_model_obj->venues() : NULL; $venue = empty($venue) ? EE_Registry::instance()->load_model('Venue')->create_default_object() : array_shift($venue); $template_args['_venue'] = $venue; $template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input($QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => 'State', 'QST_system' => 'state')), EE_Answer::new_instance(array('ANS_value' => $venue->state_ID())), array('input_name' => 'state', 'input_id' => 'phys-state', 'input_class' => '', 'input_prefix' => '', 'append_qstn_id' => FALSE))); $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input($QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => 'Country', 'QST_system' => 'country')), EE_Answer::new_instance(array('ANS_value' => $venue->country_ID())), array('input_name' => 'countries', 'input_id' => 'phys-country', 'input_class' => '', 'input_prefix' => '', 'append_qstn_id' => FALSE))); $template_path = EVENTS_TEMPLATE_PATH . 'event_venues_metabox_content.template.php'; EEH_Template::display_template($template_path, $template_args); }
/** * Gets the list of states for the form input * * @param array|null $states_list * @param EE_Question $question * @param EE_Registration $registration * @return array 2d keys are state IDs, values are their names */ public function use_cached_states_for_form_input($states_list, $question, $registration, $answer) { $state_options = array('' => array('' => '')); $states = $this->checkout->action == 'process_reg_step' ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_active_states(); if (!empty($states)) { foreach ($states as $state) { if ($state instanceof EE_State) { $state_options[$state->country()->name()][$state->ID()] = $state->name(); } } } if ($question instanceof EE_Question && $registration instanceof EE_Registration) { $answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))); } else { $answer = EE_Answer::new_instance(); } $state_options = apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', $state_options, $this, $registration, $question, $answer); return $state_options; }