/**
		 * 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' ) );
			}
		}
 /**
  * parametric_enqueue_scripts function.
  *
  * @access public
  * @return void
  */
 private function parametric_enqueue_scripts()
 {
     wp_register_script('knockout', WPV_URL . '/res/js/redesign/lib/knockout-2.2.1.debug.js', array(), '2.2.1');
     /**
      * Knockout binding handler for interop with jQuery.Sortable.
      *
      * See link below for more information.
      *
      * @since 1.7
      *
      * @link https://github.com/rniemeyer/knockout-sortable
      */
     wp_register_script('knockout-sortable', WPV_URL . '/res/js/lib/knockout-sortable.min.js', array('jquery', 'knockout'), '0.9.2');
     if (!wp_script_is('toolset-utils', 'registered')) {
         wp_register_script('toolset-utils', WPV_URL_EMBEDDED . "/common/utility/js/utils.js", array('jquery', 'underscore', 'backbone'), '1.0', true);
     }
     wp_register_script('wpv-parametric-admin-script', WPV_URL . '/res/js/redesign/views_parametric.js', array('jquery', 'toolset-utils', 'icl_editor-script', 'views-codemirror-script', 'knockout-sortable'), WPV_VERSION);
     wp_enqueue_script('knockout');
     wp_enqueue_script('wpv-parametric-admin-script');
     if (self::$is_localized) {
         wp_localize_script('wpv-parametric-admin-script', 'WPV_Parametric', array('WPV_URL' => WPV_URL, 'wpv_parametric_create_nonce' => wp_create_nonce('wpv_parametric_create_nonce'), 'wpv_parametric_submit_create_nonce' => wp_create_nonce('wpv_parametric_submit_create_nonce'), 'wpv_parametric_create_dialog_nonce' => wp_create_nonce('wpv_parametric_create_dialog_nonce'), 'wpv_view_filter_search_nonce' => wp_create_nonce('wpv_view_filter_post_search_nonce'), 'wpv_view_filter_search_delete_nonce' => wp_create_nonce("wpv_view_filter_post_search_delete_nonce"), 'wpv_view_filters_add_filter_nonce' => wp_create_nonce('wpv_view_filters_add_filter_nonce'), 'wpv_parametric_validate_post_relationship_tree' => wp_create_nonce('wpv_parametric_validate_post_relationship_tree'), 'view_id' => $this->view_id, 'is_wpml_active' => self::is_wpml_active(), 'view_purpose' => $this->get_view_type(), 'debug' => true, 'make_valid_selection' => __('Please make a valid selection.', 'wpv-views'), 'something_bad' => __("Something bad happened with shortcode building, check the console", 'wpv-views'), 'field_mandatory' => __('The value for "Refer to this field as" is mandatory, please provide one.', 'wpv-views'), 'relationship_tree_mandatory' => __('Please make a valid tree selection.'), 'basic_field_mandatory' => __('This field can not be left empty', 'wpv-views'), 'reserved_word' => __('" is a reserved word for ', 'wpv-views'), 'avoid_conflicts' => __('Change this value to avoid conflicts', 'wpv-views'), 'ajax_error' => __("Error: AJAX returned ", 'wpv-views'), 'error_generic' => __("Error: ", 'wpv-views'), 'db_insert_problem' => __("There are problems inserting your data. Check the console. ", 'wpv-views'), 'select_post_types' => __('Please select at least one post type to fiter by.', 'wpv-views'), 'data_loading_problem' => __('Something went wrong loading data ', 'wpv-views'), 'model_build_problem' => __('Something went wrong while building model.', 'wpv-views'), 'select_taxonomy_alert' => __('Select posts with taxonomy:', 'wpv-views'), 'select_taxonomy_alert_2' => __('the same as set by the URL parameter', 'wpv-views'), 'error_building_filter' => __("Something went wrong in building the filter ", 'wpv-views'), 'editing_manual_filter' => __('This filter appears to have been entered manually, so you cannot modify it with this editor. You can continue editing the shortcode manually or re-insert it using the Filters button.', 'wpv-views'), 'taxonomy' => __('Taxonomy', 'wpv-views'), 'basic_filters' => __('Basic filters', 'wpv-views'), 'relationship_select_tree' => __('Select one tree', 'wpv-views'), 'add_submit_shortcode_button' => __('Submit button', 'wpv-views'), 'add_submit_shortcode_button_label' => __('Submit', 'wpv-views'), 'add_toolbar_submit_button_title' => __('Use the submit button to get results based on the form values', 'wpv-views'), 'add_toolbar_submit_button_title_complete' => __('This form has a submit button already', 'wpv-views'), 'add_toolbar_submit_button_title_incomplete' => __('You need to add a submit button', 'wpv-views'), 'add_toolbar_submit_button_title_irrelevant' => __('You do not need a submit button in this form', 'wpv-views'), 'add_toolbar_submit_button_title_irrelevant_added' => __('You do not need a submit button in this form, although you already have one', 'wpv-views'), 'add_reset_shortcode_button' => __('Clear form', 'wpv-views'), 'add_reset_shortcode_button_label' => __('Clear', 'wpv-views'), 'add_toolbar_reset_button_title' => __('You can use a reset button that will take the search form to its original state', 'wpv-views'), 'add_toolbar_reset_button_title_complete' => __('This form has a reset button already', 'wpv-views'), 'add_toolbar_reset_button_title_incomplete' => __('You can add a reset button to this form', 'wpv-views'), 'add_spinner_shortcode_button' => __('Spinner graphics', 'wpv-views'), 'add_toolbar_spinner_button_title' => __('You can use a spinner container that will be shown when performing any automatic update', 'wpv-views'), 'add_toolbar_spinner_button_title_complete' => __('This form has a spinner container already', 'wpv-views'), 'add_toolbar_spinner_button_title_useless' => __('No spinner container will be shown as this parametric search is not performing any automatic update', 'wpv-views'), 'add_search_shortcode_button' => __('Content search', 'wpv-views'), 'add_toolbar_search_button_title' => __('You can add a search box to this form', 'wpv-views'), 'add_toolbar_search_button_title_complete' => __('This form contains a search box already', 'wpv-views'), 'add_toolbar_search_button_title_missing' => __('You have a search box in this form, click here to create the search filter that is missing', 'wpv-views'), 'add_toolbar_search_button_title_wrong' => __('You have a search box in this form, but it is linked to a broken search filter', 'wpv-views'), 'add_submit_button_to_shortcode_input_default' => __('Search', 'wpv-views'), 'pointer_button_close' => __('Close', 'wpv-views'), 'pointer_button_dismiss' => __('Don\'t show again', 'wpv-views'), 'consider_adding_label_to_button_shortcode' => __('Consider adding a label before inserting the button.', 'wpv-views'), 'place_cursor_inside_wpv_controls' => __('Place cursor within the [wpv-filter-controls][/wpv-filter-controls] tags.', 'wpv-views'), 'place_cursor_inside_wpv_filter' => __('Place cursor within the [wpv-filter-start][wpv-filter-end] tags.', 'wpv-views'), 'place_cursor_inside_wpv_control' => __('Place your cursor inside [wpv-control] tags.', 'wpv-views'), 'place_in_wpv_control_not_wrong' => __("You should select a [wpv-control] short tag instead of ", 'wpv-views'), 'place_cursor_inside_valid_control_shortcodes' => __('Place your cursor over a [wpv-control] or a [wpv-control-set] tag to edit it.', 'wpv-views'), 'place_cursor_inside_wpv_control_set' => __('To edit this filter, place your cursor over the [wpv-control-set] tag.', 'wpv-views'), 'cursorInside' => __('Warning: the cursor is inside another short code, this may cause problems.', 'wpv-views'), 'cancel' => __('Cancel', 'wpv-views'), 'edit_filter_field' => __('Edit filter field', 'wpv-views'), 'update_input' => __('Update input', 'wpv-views'), 'problems_inserting_new_shortcode' => __('There are problems inserting the shortcode.', 'wpv-views'), 'add_submit_input_label' => __('Button label:', 'wpv-views'), 'add_submit_classname_input_label' => __('Button classname:', 'wpv-views'), 'expand_button_expand' => __('Expand', 'wpv-views'), 'expand_button_hide' => __('Hide', 'wpv-views'), 'check_values_and_values_labels' => __('Please ensure that values don\'t repeat themselves, they don\'t contain only whitespaces (however blank value is allowed) and display values aren\'t empty.', 'wpv-views'), 'ajax_callback_undefined' => __('You should define a callback for your ajax call to async load data', 'wpv-views')));
     }
     self::$is_localized = true;
     if (!wp_style_is('toolset-notifications-css')) {
         wp_register_style('toolset-notifications-css', WPV_URL_EMBEDDED . '/common/utility/css/notifications.css', array(), WPV_VERSION);
         wp_enqueue_style('toolset-notifications-css');
     }
 }
 /**
  * parametric_enqueue_scripts function.
  *
  * @access public
  * @return void
  */
 private function parametric_enqueue_scripts()
 {
     wp_register_script('knockout', WPV_URL . '/res/js/redesign/lib/knockout-2.2.1.debug.js', array(), '2.2.1');
     wp_register_script('wpv-parametric-admin-script', WPV_URL . '/res/js/redesign/views_parametric.js', array('jquery', 'icl_editor-script', 'views-codemirror-script'), WPV_VERSION);
     wp_enqueue_script('knockout');
     wp_enqueue_script('wpv-parametric-admin-script');
     if (self::$is_localized) {
         wp_localize_script('wpv-parametric-admin-script', 'WPV_Parametric', array('WPV_URL' => WPV_URL, 'wpv_parametric_create_nonce' => wp_create_nonce('wpv_parametric_create_nonce'), 'wpv_parametric_submit_create_nonce' => wp_create_nonce('wpv_parametric_submit_create_nonce'), 'wpv_parametric_create_dialog_nonce' => wp_create_nonce('wpv_parametric_create_dialog_nonce'), 'wpv_view_filter_search_nonce' => wp_create_nonce('wpv_view_filter_search_nonce'), 'wpv_view_filter_search_delete_nonce' => wp_create_nonce("wpv_view_filter_search_delete_nonce"), 'wpv_view_filters_add_filter_nonce' => wp_create_nonce('wpv_view_filters_add_filter_nonce'), 'view_id' => $this->view_id, 'is_wpml_active' => self::is_wpml_active(), 'view_purpose' => $this->get_view_type(), 'debug' => true, 'make_valid_selection' => __('Please make a valid selection.', 'wpv-views'), 'something_bad' => __("Something bad happend with shortcode building, check the console", 'wpv-views'), 'field_mandatory' => __('The value for "Refer to this field as" is mandatory, please provide one.', 'wpv-vies'), 'reserved_word' => __('" is a reserved word for ', 'wpv-views'), 'avoid_conflicts' => __('Change this value to avoid conflicts', 'wpv-views'), 'ajax_error' => __("Error: AJAX returned ", 'wpv-views'), 'error_generic' => __("Error: ", 'wpv-views'), 'db_insert_problem' => __("There are problems inserting your data. Check the console. ", 'wpv-views'), 'select_post_types' => __('Please select at least one post type to fiter by.', 'wpv-views'), 'data_loading_problem' => __('Something went wrong loading data ', 'wpv-views'), 'model_build_problem' => __('Something went wrong while bulding model.', 'wpv-views'), 'select_taxonomy_alert' => __('Select posts with taxonomy:', 'wpv-views'), 'select_taxonomy_alert_2' => __('the same as set by the URL parameter', 'wpv-views'), 'error_building_filter' => __("Something went wrong in building the filter ", 'wpv-views'), 'add_submit_shortcode_button' => __('Submit button', 'wpv-views'), 'add_submit_button_to_shortcode_label' => __('Insert input', 'wpv-views'), 'add_submit_button_to_shortcode_input_default' => __('Search', 'wpv-views'), 'consider_adding_label_to_submit_shortcode' => __('Consider adding a label before inserting submit button.', 'wpv-views'), 'add_submit_button_to_shortcode_header' => __('Create submit button for form.', 'wpv-views'), 'place_cursor_inside_wpv_controls' => __('Place cursor within [wpv-filter-controls][/wpv-filter-controls] tags.', 'wpv-views'), 'place_cursor_inside_wpv_control' => __('Place cursor inside [wpv-control] tags.', 'wpv-views'), 'place_in_wpv_control_not_wrong' => __("You should select a [wpv-control] short tag instead of ", 'wpv-views'), 'add_search_shortcode_button' => __('Search', 'wpv-views'), 'no_submit_button' => __('There is no submit button in the form just created. Use "Submit button" button to create one.', 'wpv-views'), 'cursorInside' => __('Warning: the cursor is inside another short code, this may cause problems.', 'wpv-views'), 'cancel' => __('Cancel', 'wpv-views'), 'edit_filter_field' => __('Edit filter field', 'wpv-views'), 'update_input' => __('Update input', 'wpv-views'), 'problems_inserting_new_shortcode' => __('There are problems inserting the shortcode.', 'wpv-views'), 'add_submit_input_label' => __('Button label:', 'wpv-views'), 'add_submit_classname_input_label' => __('Button classname:', 'wpv-views'), 'expand_button_expand' => __('Expand', 'wpv-views'), 'expand_button_hide' => __('Hide', 'wpv-views'), 'check_values_and_values_labels' => __("Please provide at least one non-empty value, you are free to live some of them empty.", 'wpv-views'), 'ajax_callback_undefined' => __('You should define a callback for your ajax call to async load data', 'wpv-views'), 'view_has_already_a_search' => __("This View already has a content search filter. If you insert a search control to the HTML, the existing search filter will be removed.", 'wpv-views')));
     }
     self::$is_localized = true;
 }