/**
  * buildRawFieldToEdit function
  *
  * @param array $field
  * @param array $settings
  * @return array
  * @author Riccardo Strobbia
  **/
 private function buildRawFieldToEdit($field, $settings = array())
 {
     $opts = $settings ? $settings : get_post_meta($this->view_id, '_wpv_settings', true);
     $ret = array();
     $index = self::get_param_index_cmp($settings, $field);
     //print "index first method " . $index ."\n";
     //FIXME: fall back for retrocompatibility
     if ($index === -1) {
         //	$index = self::get_param_index($settings, $field);
     }
     $index = self::get_param_index($settings, $field);
     if ($index > -1) {
         $field['url_param'] = self::$tmp_settings['filter_controls_param'][$index];
         $field['can_force_zero'] = false;
         self::$tmp_settings = null;
         if (isset($field['taxonomy'])) {
             $name = $settings['filter_controls_field_name'][$index];
             $id = $name;
             $id = $settings['filter_controls_label'][$index];
             $ret['is_types'] = false;
             $ret['group'] = 'taxonomy';
             ///do processing for taxes and return
         } else {
             if (isset($field['field'])) {
                 $g = '';
                 $name = $field['field'];
                 $nice_name = explode('wpcf-', $name);
                 $id = isset($nice_name[1]) ? $nice_name[1] : $name;
                 $field_options = array();
                 if (function_exists('wpcf_admin_fields_get_groups_by_field')) {
                     $field_options = wpcf_admin_fields_get_field($id);
                     foreach (wpcf_admin_fields_get_groups_by_field($id) as $gs) {
                         $g = $gs['name'];
                     }
                 }
                 $ret['group'] = $g ? $g : "Custom fields";
                 $name = $g ? $name : $field['field'];
                 $ret['is_types'] = $g ? true : false;
                 if (!empty($field_options) && isset($field_options['meta_key'])) {
                     $name = $field_options['meta_key'];
                 }
                 if (!empty($field_options) && $field_options['type'] == 'checkbox' && $field_options['data']['save_empty'] == 'yes') {
                     $ret['can_force_zero'] = true;
                 }
                 $id = $g ? $id : $field['field'];
             } else {
                 if (isset($field['relationship'])) {
                     $name = 'relationship';
                     $id = __('Post relationship', 'wpv-views');
                     // TODO what are we doing here??
                     $id = $settings['filter_controls_label'][$index];
                     $ret['is_types'] = false;
                     $ret['group'] = 'basic_filters';
                     $ret['kind'] = 'relationship';
                     $ret['basic_filter_type'] = 'relationship';
                 } else {
                     $name = $settings['filter_controls_field_name'][$index];
                     $id = $name;
                     $ret['is_types'] = false;
                     $ret['group'] = 'Custom fields';
                 }
             }
         }
         //	print "\n'custom-field-'.$name.'_value'\n";
         //	print_r( $settings['custom-field-'.$name.'_value'] );
         $ret['field'] = $name;
         $ret['id'] = $id;
         if (isset($field['taxonomy'])) {
             $ret['kind'] = 'taxonomy';
             $ret['group'] = $ret['kind'];
             $ret['compare'] = isset($settings['taxonomy-' . $name . '-attribute-operator']) ? $settings['taxonomy-' . $name . '-attribute-operator'] : 'IN';
             //	$ret['hide_empty'] = isset( $field['hide_empty'] ) ? $field['hide_empty'] : 'false';
         } else {
             if (isset($field['relationship'])) {
                 $ret['group'] = 'basic_filters';
             } else {
                 $ret['compare'] = isset($settings['custom-field-' . $name . '_compare']) ? $settings['custom-field-' . $name . '_compare'] : '=';
                 $ret['data_type'] = isset($settings['custom-field-' . $name . '_type']) ? $settings['custom-field-' . $name . '_type'] : 'CHAR';
                 $ret['relation'] = isset($settings['custom-field-' . $name . '_relationship']) ? $settings['custom-field-' . $name . '_relationship'] : 'AND';
                 $ret['kind'] = 'field';
             }
         }
         $ret['name'] = $ret['is_types'] ? $settings['filter_controls_label'][$index] : $id;
         $ret['type'] = $settings['filter_controls_type'][$index];
         $ret['values'] = $settings['filter_controls_values'][$index];
         $ret['enabled'] = $settings['filter_controls_enable'][$index];
         $ret['index'] = $index;
         /*	$ret_aux = $settings['filter_controls_values'][$index];
         			$ret['taxonomy_order'] = isset( $ret_aux['taxonomy_order'] ) ? $ret_aux['taxonomy_order'] : 'ASC';
         			$ret['taxonomy_orderby'] = isset( $ret_aux['taxonomy_orderby'] ) ? $ret_aux['taxonomy_orderby'] : 'name';
         			$ret['hide_empty'] = isset( $ret_aux['hide_empty'] ) ? $ret_aux['hide_empty'] : 'false';*/
         //implement for tax
         return array_merge($field, $ret);
     } else {
         return array('error', __(sprintf('There is something wrong url parameter is missing %s', __METHOD__), 'wpv-views'));
     }
 }