private function get_region_fields($context)
 {
     return awpcp_region_fields($context, $this->options['enabled_fields']);
 }
Beispiel #2
0
/**
 * Generates HTML for Region fields. Only those fields enabled
 * in the settings will be returned.
 *
 * @param $query array 			Default or selected values for form fields.
 * @param $translations array 	Allow developers to change the name
 * 								attribute of the form field associated
 *								to this Region Field.
 * @deprecated since 3.2.3
 */
function awpcp_region_form_fields($query, $translations = null, $context = 'details', $errors = array())
{
    if (is_null($translations)) {
        $translations = array('country', 'state', 'city', 'county');
        $translations = array_combine($translations, $translations);
    }
    $fields = array();
    foreach (awpcp_region_fields($translations) as $key => $field) {
        $field['value'] = awpcp_array_data($key, '', $query);
        if ($context === 'search' && get_awpcp_option('buildsearchdropdownlists')) {
            $field['entries'] = awpcp_get_region_field_entries($key);
            $field['options'] = awpcp_render_region_form_field_options($field['entries'], $field['value']);
        } else {
            $field['entries'] = array();
            $field['options'] = '';
        }
        $fields[$key] = $field;
    }
    // no field is required in Search Ads screen
    if ($context == 'search') {
        foreach ($fields as $key => $field) {
            $fields[$key]['required'] = false;
        }
    }
    $ordered = array('country', 'state', 'city', 'county');
    ob_start();
    include AWPCP_DIR . '/frontend/templates/region-control-form-fields.tpl.php';
    $html = ob_get_contents();
    ob_end_clean();
    return $html;
}