( // "array_storage_record_structure" => array( // => array( // "array_storage_value_from" => array(...) // ) // ) // ) // // --- // // Where "array_storage_value_from" can have the following values (as of // 23 September 2014):- // // array( // 'method' => 'created-server-datetime-utc' // ) // // array( // 'method' => 'last-modified-server-datetime-utc' // ) // // array( // 'method' => 'created-server-micro-datetime-utc' // ) // // array( // 'method' => 'last-modified-server-micro-datetime-utc' // ) // // array( // 'method' => 'unique-key' // ) // // array( // 'method' => 'literal' , // 'instance' => // ) // // array( // 'method' => 'get' , // 'instance' => '' // ) // // array( // 'method' => 'post' , // 'instance' => '' // ) // // array( // 'method' => 'server' , // 'instance' => '' // ) // // array( // 'method' => 'cookie' , // 'instance' => '' // ) // // array( // 'method' => 'function' , // 'instance' => '' , // 'args' => // ) // // array( // 'method' => 'maintained-programatically' // ) // // --- // // RETURNS:- // // o On SUCCESS! // - - - - - - // array( // $ok = TRUE , // $field_value (any PHP type) , // $question_change // ) // NOTE! // ----- // If $question_change is anything but TRUE, then the array // storage field SHOULDN'T be updated with the returned // $field_value. For example, if you're editing a record // identified by some unique "key", then that "key" field // should never (usually) be updated. It's a unique // identifier for the record - assigned when the record is // first created - and remaining unchanged till the record // is destroyed. // // o On FAILURE! // - - - - - - // array( // $ok = FALSE , // $error_message STRING // ) // ------------------------------------------------------------------------- // ========================================================================= // Support Routines... // ========================================================================= require_once( dirname( __FILE__ ) . '/standard-field-values.php' ) ; // ========================================================================= // Init. the output variables... // ========================================================================= $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ------------------------------------------------------------------------- $success = TRUE ; $failure = FALSE ; // ------------------------------------------------------------------------- $question_change = TRUE ; // Override this for field methods that assume the field values // are assigned at "add" time only. // ------------------------------------------------------------------------- if ( $question_adding ) { // --------------------------------------------------------------------- if ( array_key_exists( 'add' , $array_storage_field_details['array_storage_value_from'] ) ) { $value_from_details = $array_storage_field_details['array_storage_value_from']['add'] ; } elseif ( array_key_exists( 'add-edit' , $array_storage_field_details['array_storage_value_from'] ) ) { $value_from_details = $array_storage_field_details['array_storage_value_from']['add-edit'] ; } else { $msg = << 'created-server-datetime-utc' // // "instance" and "args", if specified, are IGNORED // ) // ===================================================================== // $field_value = time() ; $field_value = get_server_datetime_UTC() ; // --------------------------------------------------------------------- if ( ! $question_adding ) { $question_change = FALSE ; } // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'last-modified-server-datetime-utc' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'last-modified-server-datetime-utc' // // "instance" and "args", if specified, are IGNORED // ) // ===================================================================== // $field_value = time() ; $field_value = get_server_datetime_UTC() ; // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'created-server-micro-datetime-utc' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'created-server-micro-datetime-utc' // // "instance" and "args", if specified, are IGNORED // ) // ===================================================================== // --------------------------------------------------------------------- // NOTE! // ----- // "Micro" dates/times are expressed as floats like (eg):- // // 12.34 = 12 seconds and 340 microseconds // // "micro" = 1 millionth // --------------------------------------------------------------------- // ------------------------------------------------------------------------- // mixed microtime ([ bool $get_as_float = false ] ) // - - - - - - - - - - - - - - - - - - - - - - - - - // microtime() returns the current Unix timestamp with microseconds. This // function is only available on operating systems that support the // gettimeofday() system call. // // get_as_float // If used and set to TRUE, microtime() will return a float instead // of a string, as described in the return values section below. // // By default, microtime() returns a string in the form "msec sec", where // sec is the number of seconds since the Unix epoch (0:00:00 January 1,1970 // GMT), and msec measures microseconds that have elapsed since sec and is // also expressed in seconds. // // If get_as_float is set to TRUE, then microtime() returns a float, which // represents the current time in seconds since the Unix epoch accurate to // the nearest microsecond. // // (PHP 4, PHP 5) // // CHANGELOG // Version Description // 5.0.0 The get_as_float parameter was added. // ------------------------------------------------------------------------- // if ( function_exists( 'microtime' ) ) { // list( $usec , $sec ) = explode( chr(32) , microtime() ) ; // $field_value = (float) $usec + (float) $sec ; // // Getting the microtime() as float this way works in both // // PHP 4 and 5. // // } else { // $field_value = (float) time() ; // // } // --------------------------------------------------------------------- $field_value = get_server_micro_datetime_UTC() ; // --------------------------------------------------------------------- if ( ! $question_adding ) { $question_change = FALSE ; } // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'last-modified-server-micro-datetime-utc' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'last-modified-server-micro-datetime-utc' // // "instance" and "args", if specified, are IGNORED // ) // ===================================================================== // --------------------------------------------------------------------- // NOTE! // ----- // "Micro" dates/times are expressed as floats like (eg):- // // 12.34 = 12 seconds and 340 microseconds // // "micro" = 1 millionth // --------------------------------------------------------------------- // if ( function_exists( 'microtime' ) ) { // list( $usec , $sec ) = explode( chr(32) , microtime() ) ; // $field_value = (float) $usec + (float) $sec ; // // Getting the microtime() as float this way works in both // // PHP 4 and 5. // // } else { // $field_value = (float) time() ; // // } // --------------------------------------------------------------------- $field_value = get_server_micro_datetime_UTC() ; // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'unique-key' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'unique-key' // // "instance" and "args", if specified, are IGNORED // ) // ===================================================================== // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_standardDatasetManager\ // get_unique_record_key_for_dataset( // $record_indices_by_key // ) // - - - - - - - - - - - - - - - - - // RETURNS // o On SUCCESS // $record_key STRING // // o On FAILURE // ARRAY( $error_message STRING ) // ------------------------------------------------------------------------- $field_value = get_unique_record_key_for_dataset( $record_indices_by_key ) ; // --------------------------------------------------------------------- if ( is_array( $field_value ) ) { return array( $failure , $field_value[0] ) ; } // --------------------------------------------------------------------- if ( ! $question_adding ) { $question_change = FALSE ; } // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'literal' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'literal' , // 'instance' => // // "args", if specified, is IGNORED // ) // ===================================================================== if ( ! isset( $value_from_details['instance'] ) ) { $msg = << 'get' , // 'instance' => '' // // If "instance" is unspecified - or is anything but a // // non-empty string, then '' defaults to // // the field's "slug" // // "args", if specified, is IGNORED // ) // ===================================================================== // --------------------------------------------------------------------- // NOTE! // ===== // CHECKBOX fields are a special case. They WON'T be submitted - and // placed into $_GET or $_POST (acc. to the form METHOD) - unless the // checkbox is CHECKED. // // Hence we must detect this - and default the field value to TRUE or // FALSE accordingly... // --------------------------------------------------------------------- if ( count( $zebra_form_field_indices_of_checkbox_type_zebra_form_fields ) > 0 ) { // ------------------------------------------------------------------------- // is_array_storage_field_a_checkbox_type_field( // $selected_datasets_dmdd , // $zebra_form_definition , // $dataset_slug , // $dataset_title , // $array_storage_field_details , // $zebra_form_field_indices_of_checkbox_type_zebra_form_fields , // $get_post , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // o On SUCCESS! // array( // $question_checkbox_type_field BOOL , // $expected_checkbox_value STRING or NULL // ) // // o On FAILURE! // $error_message STRING // ------------------------------------------------------------------------- $get_post = 'get' ; $result = is_array_storage_field_a_checkbox_type_field( $selected_datasets_dmdd , $zebra_form_definition , $dataset_slug , $dataset_title , $array_storage_field_details , $zebra_form_field_indices_of_checkbox_type_zebra_form_fields , $get_post , $value_from_details ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return array( $failure , $result ) ; } // ----------------------------------------------------------------- list( $question_checkbox_type_field , $expected_checkbox_value ) = $result ; // ----------------------------------------------------------------- } else { // ----------------------------------------------------------------- $question_checkbox_type_field = FALSE ; $expected_checkbox_value = NULL ; // ----------------------------------------------------------------- } // --------------------------------------------------------------------- // NOTE! // ===== // RADIO fields are a special case. They WON'T be submitted - and // placed into $_GET or $_POST (acc. to the form METHOD) - unless one // radio in the group (of radios with the name name) is CHECKED. // // Hence we must detect this - and default the field value to it's // default accordingly... // --------------------------------------------------------------------- if ( count( $zebra_form_field_indices_of_radios_type_zebra_form_fields ) > 0 ) { // ------------------------------------------------------------------------- // is_array_storage_field_a_radios_type_field( // $selected_datasets_dmdd , // $zebra_form_definition , // $dataset_slug , // $dataset_title , // $array_storage_field_details , // $zebra_form_field_indices_of_radios_type_zebra_form_fields , // $get_post , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // o On SUCCESS! // - - - - - - // TRUE or FALSE // // o On FAILURE! // $error_message STRING // ------------------------------------------------------------------------- $get_post = 'get' ; $question_radios_type_field = is_array_storage_field_a_radios_type_field( $selected_datasets_dmdd , $zebra_form_definition , $dataset_slug , $dataset_title , $array_storage_field_details , $zebra_form_field_indices_of_radios_type_zebra_form_fields , $get_post , $value_from_details ) ; // ----------------------------------------------------------------- if ( is_string( $question_radios_type_field ) ) { return array( $failure , $question_radios_type_field ) ; } // ----------------------------------------------------------------- } else { // ----------------------------------------------------------------- $question_radios_type_field = FALSE ; // ----------------------------------------------------------------- } // ------------------------------------------------------------------------- // get_slash_check_get_post_server_or_cookie_field_value( // $dataset_title , // $array_storage_field_details , // $_WHATEVER , // $whatever , // $adding_editing , // $question_checkbox_type_field , // $question_radios_type_field , // $expected_checkbox_value , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - // NOTE! // ===== // The returned CHECKBOX type field values are TRUE or FALSE. // All other returned field values are STRINGS. // // RETURNS // o On SUCCESS! // - - - - - - // $field_value (BOOL or STRING) // // o On FAILURE! // - - - - - - // array( $error_message STRING ) // ------------------------------------------------------------------------- $field_value = get_slash_check_get_post_server_or_cookie_field_value( $dataset_title , $array_storage_field_details , $_GET , 'get' , $adding_editing , $question_checkbox_type_field , $question_radios_type_field , $expected_checkbox_value , $value_from_details ) ; // --------------------------------------------------------------------- if ( is_array( $field_value ) ) { return array( $failure , $field_value[0] ) ; } // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'post' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'post' , // 'instance' => '' // // If "instance" is unspecified - or is anything but a // // non-empty string, then '' defaults to // // the field's "slug" // // "args", if specified, is IGNORED // ) // ===================================================================== // --------------------------------------------------------------------- // NOTE! // ===== // CHECKBOX fields are a special case. They WON'T be submitted - and // placed into $_GET or $_POST (acc. to the form METHOD) - unless the // checkbox is CHECKED. // // Hence we must detect this - and default the field value to TRUE or // FALSE accordingly... // --------------------------------------------------------------------- if ( count( $zebra_form_field_indices_of_checkbox_type_zebra_form_fields ) > 0 ) { // ------------------------------------------------------------------------- // is_array_storage_field_a_checkbox_type_field( // $selected_datasets_dmdd , // $zebra_form_definition , // $dataset_slug , // $dataset_title , // $array_storage_field_details , // $zebra_form_field_indices_of_checkbox_type_zebra_form_fields , // $get_post , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // o On SUCCESS! // array( // $question_checkbox_type_field BOOL , // $expected_checkbox_value STRING or NULL // ) // // o On FAILURE! // $error_message STRING // ------------------------------------------------------------------------- $get_post = 'post' ; $result = is_array_storage_field_a_checkbox_type_field( $selected_datasets_dmdd , $zebra_form_definition , $dataset_slug , $dataset_title , $array_storage_field_details , $zebra_form_field_indices_of_checkbox_type_zebra_form_fields , $get_post , $value_from_details ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return array( $failure , $result ) ; } // ----------------------------------------------------------------- list( $question_checkbox_type_field , $expected_checkbox_value ) = $result ; // ----------------------------------------------------------------- } else { // ----------------------------------------------------------------- $question_checkbox_type_field = FALSE ; $expected_checkbox_value = NULL ; // ----------------------------------------------------------------- } // --------------------------------------------------------------------- // NOTE! // ===== // RADIO fields are a special case. They WON'T be submitted - and // placed into $_GET or $_POST (acc. to the form METHOD) - unless one // radio in the group (of radios with the name name) is CHECKED. // // Hence we must detect this - and default the field value to it's // default accordingly... // --------------------------------------------------------------------- if ( count( $zebra_form_field_indices_of_radios_type_zebra_form_fields ) > 0 ) { // ------------------------------------------------------------------------- // is_array_storage_field_a_radios_type_field( // $selected_datasets_dmdd , // $zebra_form_definition , // $dataset_slug , // $dataset_title , // $array_storage_field_details , // $zebra_form_field_indices_of_radios_type_zebra_form_fields , // $get_post , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // o On SUCCESS! // - - - - - - // TRUE or FALSE // // o On FAILURE! // $error_message STRING // ------------------------------------------------------------------------- $get_post = 'post' ; $question_radios_type_field = is_array_storage_field_a_radios_type_field( $selected_datasets_dmdd , $zebra_form_definition , $dataset_slug , $dataset_title , $array_storage_field_details , $zebra_form_field_indices_of_radios_type_zebra_form_fields , $get_post , $value_from_details ) ; // ----------------------------------------------------------------- if ( is_string( $question_radios_type_field ) ) { return array( $failure , $question_radios_type_field ) ; } // ----------------------------------------------------------------- } else { // ----------------------------------------------------------------- $question_radios_type_field = FALSE ; // ----------------------------------------------------------------- } // ------------------------------------------------------------------------- // get_slash_check_get_post_server_or_cookie_field_value( // $dataset_title , // $array_storage_field_details , // $_WHATEVER , // $whatever , // $adding_editing , // $question_checkbox_type_field , // $question_radios_type_field , // $expected_checkbox_value , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - // NOTE! // ===== // The returned CHECKBOX type field values are TRUE or FALSE. // All other returned field values are STRINGS. // // RETURNS // o On SUCCESS! // - - - - - - // $field_value (BOOL or STRING) // // o On FAILURE! // - - - - - - // array( $error_message STRING ) // ------------------------------------------------------------------------- $field_value = get_slash_check_get_post_server_or_cookie_field_value( $dataset_title , $array_storage_field_details , $_POST , 'post' , $adding_editing , $question_checkbox_type_field , $question_radios_type_field , $expected_checkbox_value , $value_from_details ) ; // --------------------------------------------------------------------- if ( is_array( $field_value ) ) { return array( $failure , $field_value[0] ) ; } // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'server' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'server' , // 'instance' => '' // // If "instance" is unspecified - or is anything but a // // non-empty string, then '' defaults to // // the field's "slug" // // "args", if specified, is IGNORED // ) // ===================================================================== // ------------------------------------------------------------------------- // get_slash_check_get_post_server_or_cookie_field_value( // $dataset_title , // $array_storage_field_details , // $_WHATEVER , // $whatever , // $adding_editing , // $question_checkbox_type_field , // $question_radios_type_field , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - // NOTE! // ===== // The returned CHECKBOX type field values are TRUE or FALSE. // All other returned field values are STRINGS. // // RETURNS // o On SUCCESS! // - - - - - - // $field_value (BOOL or STRING) // // o On FAILURE! // - - - - - - // array( $error_message STRING ) // ------------------------------------------------------------------------- $question_checkbox_type_field = FALSE ; $question_radios_type_field = FALSE ; $expected_checkbox_value = NULL ; // --------------------------------------------------------------------- $field_value = get_slash_check_get_post_server_or_cookie_field_value( $dataset_title , $array_storage_field_details , $_SERVER , 'server' , $adding_editing , $question_checkbox_type_field , $question_radios_type_field , $expected_checkbox_value , $value_from_details ) ; // --------------------------------------------------------------------- if ( is_array( $field_value ) ) { return array( $failure , $field_value[0] ) ; } // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'cookie' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'cookie' , // 'instance' => '' // // If "instance" is unspecified - or is anything but a // // non-empty string, then '' defaults to // // the field's "slug" // // "args", if specified, is IGNORED // ) // ===================================================================== // ------------------------------------------------------------------------- // get_slash_check_get_post_server_or_cookie_field_value( // $dataset_title , // $array_storage_field_details , // $_WHATEVER , // $whatever , // $adding_editing , // $question_checkbox_type_field , // $question_radios_type_field , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - // NOTE! // ===== // The returned CHECKBOX type field values are TRUE or FALSE. // All other returned field values are STRINGS. // // RETURNS // o On SUCCESS! // - - - - - - // $field_value (BOOL or STRING) // // o On FAILURE! // - - - - - - // array( $error_message STRING ) // ------------------------------------------------------------------------- $question_checkbox_type_field = FALSE ; $question_radios_type_field = FALSE ; $expected_checkbox_value = NULL ; // --------------------------------------------------------------------- $field_value = get_slash_check_get_post_server_or_cookie_field_value( $dataset_title , $array_storage_field_details , $_COOKIE , 'cookie' , $adding_editing , $question_checkbox_type_field , $question_radios_type_field , $expected_checkbox_value , $value_from_details ) ; // --------------------------------------------------------------------- if ( is_array( $field_value ) ) { return array( $failure , $field_value[0] ) ; } // --------------------------------------------------------------------- } elseif ( $value_from_details['method'] === 'function' ) { // ===================================================================== // $value_from_details = array( // 'method' => 'function' , // 'instance' => '' , // 'args' => // ) // ===================================================================== if ( ! isset( $value_from_details['instance'] ) ) { $msg = << 255 ) { $msg = << 'from-default-record' , // 'instance' => '' // ) // ===================================================================== if ( ! $question_adding ) { $msg = << 'dont-change' // ) // ===================================================================== if ( $question_adding ) { $msg = << 'maintained-programatically' // ) // ===================================================================== $field_value = NULL ; // Ignored (because $question_change, see below, is FALSE) // --------------------------------------------------------------------- $question_change = FALSE ; // --------------------------------------------------------------------- } else { // ===================================================================== // ERROR! // ===================================================================== $field_type = htmlentities( $value_from_details['method'] ) ; $msg = << 64 ) { $msg = << array( // // array( // 'slug' => 'created_server_micro_datetime_UTC' , // 'array_storage_value_from' => array( // 'method' => 'created-server-micro-datetime-utc' // ) , // 'constraints' => array( // array( // 'method' => 'unix-timestamp-with-microseconds' // ) // ) // ) , // // ... // // array( // 'slug' => 'key' , // 'array_storage_value_from' => array( // 'method' => 'unique-key' // ) , // 'constraints' => array( // array( // 'method' => 'unique-key' // ) // ) // ) , // // array( // 'slug' => 'pathspec' , // 'array_storage_value_from' => array( // 'method' => 'post' , // 'instance' => 'pathspec' // ) , // 'constraints' => array() // ) , // // ... // // ) , // // ... // // ['zebra_form'] => array( // // 'form_specs' => array( // 'name' => 'add_edit_plugin_component' , // 'method' => 'POST' , // 'action' => '' , // 'attributes' => array() , // 'clientside_validation' => TRUE // ) , // // 'field_specs' => array( // // array( // 'form_field_name' => 'pathspec' , // 'zebra_control_type' => 'text' , // 'label' => 'Pathspec' , // 'attributes' => array() , // 'rules' => array( // 'required' => array( // 'error' , // variable to add the error message to // 'Field is required' // error message if value doesn't validate // ) // ) // ) , // // array( // 'form_field_name' => 'save_me' , // 'zebra_control_type' => 'submit' , // 'label' => NULL , // 'attributes' => array() , // 'rules' => array() , // 'type_specific_args' => array( // 'caption' => 'Submit' // ) // ) , // // ) , // // 'focus_field_slug' => 'pathspec' // // ) // // ... // // ) // // ------------------------------------------------------------------------- //pr( func_get_args() ) ; //pr( $selected_datasets_dmdd['array_storage_record_structure'] ) ; //pr( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_specs'] ) ; //pr( $array_storage_field_details ) ; //exit() ; // ------------------------------------------------------------------------- $target_form_field_name_from_instance = NULL ; if ( isset( $value_from_details ) && isset( $value_from_details['method'] ) && strtolower( $value_from_details['method'] ) === strtolower( $get_post ) && isset( $value_from_details['instance'] ) && is_string( $value_from_details['instance'] ) && trim( $value_from_details['instance'] ) !== '' && strlen( $value_from_details['instance'] ) <= 64 && \greatKiwi_byFernTec_adSwapper_local_v0x1x210_stringUtils\ctype_varname( $value_from_details['instance'] ) ) { $target_form_field_name_from_instance = $value_from_details['instance'] ; } // ------------------------------------------------------------------------- $target_form_field_name_from_slug = NULL ; if ( isset( $array_storage_field_details['slug'] ) && is_string( $array_storage_field_details['slug'] ) && trim( $array_storage_field_details['slug'] ) !== '' && strlen( $array_storage_field_details['slug'] ) <= 64 && \greatKiwi_byFernTec_adSwapper_local_v0x1x210_stringUtils\ctype_varname( $array_storage_field_details['slug'] ) ) { $target_form_field_name_from_slug = $array_storage_field_details['slug'] ; } // ------------------------------------------------------------------------- foreach ( $zebra_form_field_indices_of_checkbox_type_zebra_form_fields as $zebra_form_field_index ) { // --------------------------------------------------------------------- $zebra_form_field_details = $zebra_form_definition['field_specs'][ $zebra_form_field_index ] ; // --------------------------------------------------------------------- if ( isset( $zebra_form_field_details['form_field_name'] ) && is_string( $zebra_form_field_details['form_field_name'] ) ) { // ----------------------------------------------------------------- if ( $zebra_form_field_details['form_field_name'] === $target_form_field_name_from_instance || $zebra_form_field_details['form_field_name'] === $target_form_field_name_from_slug ) { return TRUE ; } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- return FALSE ; // ------------------------------------------------------------------------- } */ // ============================================================================= // is_array_storage_field_a_checkbox_type_field() // ============================================================================= function is_array_storage_field_a_checkbox_type_field( $selected_datasets_dmdd , $zebra_form_definition , $dataset_slug , $dataset_title , $array_storage_field_details , $zebra_form_field_indices_of_checkbox_type_zebra_form_fields , $get_post , $value_from_details ) { // ------------------------------------------------------------------------- // is_array_storage_field_a_checkbox_type_field( // $selected_datasets_dmdd , // $zebra_form_definition , // $dataset_slug , // $dataset_title , // $array_storage_field_details , // $zebra_form_field_indices_of_checkbox_type_zebra_form_fields , // $get_post , // $value_from_details // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // o On SUCCESS! // array( // $question_checkbox_type_field BOOL , // $expected_checkbox_value STRING or NULL // ) // // o On FAILURE! // $error_message STRING // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Here we should have (eg):- // // $selected_datasets_dmdd = array( // // ... // // ['array_storage_record_structure'] => array( // // array( // 'slug' => 'created_server_micro_datetime_UTC' , // 'array_storage_value_from' => array( // 'method' => 'created-server-micro-datetime-utc' // ) , // 'constraints' => array( // array( // 'method' => 'unix-timestamp-with-microseconds' // ) // ) // ) , // // ... // // array( // 'slug' => 'key' , // 'array_storage_value_from' => array( // 'method' => 'unique-key' // ) , // 'constraints' => array( // array( // 'method' => 'unique-key' // ) // ) // ) , // // array( // 'slug' => 'pathspec' , // 'array_storage_value_from' => array( // 'method' => 'post' , // 'instance' => 'pathspec' // ) , // 'constraints' => array() // ) , // // ... // // ) , // // ... // // ['zebra_form'] => array( // // 'form_specs' => array( // 'name' => 'add_edit_plugin_component' , // 'method' => 'POST' , // 'action' => '' , // 'attributes' => array() , // 'clientside_validation' => TRUE // ) , // // 'field_specs' => array( // // array( // 'form_field_name' => 'pathspec' , // 'zebra_control_type' => 'text' , // 'label' => 'Pathspec' , // 'attributes' => array() , // 'rules' => array( // 'required' => array( // 'error' , // variable to add the error message to // 'Field is required' // error message if value doesn't validate // ) // ) // ) , // // array( // 'form_field_name' => 'save_me' , // 'zebra_control_type' => 'submit' , // 'label' => NULL , // 'attributes' => array() , // 'rules' => array() , // 'type_specific_args' => array( // 'caption' => 'Submit' // ) // ) , // // ) , // // 'focus_field_slug' => 'pathspec' // // ) // // ... // // ) // // ------------------------------------------------------------------------- //pr( func_get_args() ) ; //pr( $selected_datasets_dmdd['array_storage_record_structure'] ) ; //pr( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_specs'] ) ; //pr( $array_storage_field_details ) ; //exit() ; // ------------------------------------------------------------------------- $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ------------------------------------------------------------------------- $target_form_field_name_from_instance = NULL ; // ------------------------------------------------------------------------- if ( isset( $value_from_details ) && isset( $value_from_details['method'] ) && strtolower( $value_from_details['method'] ) === strtolower( $get_post ) && isset( $value_from_details['instance'] ) && is_string( $value_from_details['instance'] ) && trim( $value_from_details['instance'] ) !== '' && strlen( $value_from_details['instance'] ) <= 64 && \greatKiwi_byFernTec_adSwapper_local_v0x1x210_stringUtils\ctype_varname( $value_from_details['instance'] ) ) { $target_form_field_name_from_instance = $value_from_details['instance'] ; } // ------------------------------------------------------------------------- $target_form_field_name_from_slug = NULL ; // ------------------------------------------------------------------------- if ( isset( $array_storage_field_details['slug'] ) && is_string( $array_storage_field_details['slug'] ) && trim( $array_storage_field_details['slug'] ) !== '' && strlen( $array_storage_field_details['slug'] ) <= 64 && \greatKiwi_byFernTec_adSwapper_local_v0x1x210_stringUtils\ctype_varname( $array_storage_field_details['slug'] ) ) { $target_form_field_name_from_slug = $array_storage_field_details['slug'] ; } // ------------------------------------------------------------------------- foreach ( $zebra_form_field_indices_of_checkbox_type_zebra_form_fields as $zebra_form_field_index ) { // --------------------------------------------------------------------- $zebra_form_field_details = $zebra_form_definition['field_specs'][ $zebra_form_field_index ] ; // --------------------------------------------------------------------- if ( isset( $zebra_form_field_details['form_field_name'] ) && is_string( $zebra_form_field_details['form_field_name'] ) ) { // ----------------------------------------------------------------- if ( $zebra_form_field_details['form_field_name'] === $target_form_field_name_from_instance || $zebra_form_field_details['form_field_name'] === $target_form_field_name_from_slug ) { // ------------------------------------------------------------- $expected_value = '1' ; // The default // ------------------------------------------------------------- if ( array_key_exists( 'type_specific_args' , $zebra_form_field_details ) && is_array( $zebra_form_field_details['type_specific_args'] ) && array_key_exists( 'value' , $zebra_form_field_details['type_specific_args'] ) ) { // --------------------------------------------------------- if ( ! is_string( $zebra_form_field_details['type_specific_args']['value'] ) ) { // ----------------------------------------------------- $safe_field_name = htmlentities( $zebra_form_field_details['form_field_name'] ) ; $zebra_form_field_number = $zebra_form_field_index + 1 ; return << array( // // array( // 'slug' => 'created_server_micro_datetime_UTC' , // 'array_storage_value_from' => array( // 'method' => 'created-server-micro-datetime-utc' // ) , // 'constraints' => array( // array( // 'method' => 'unix-timestamp-with-microseconds' // ) // ) // ) , // // ... // // array( // 'slug' => 'key' , // 'array_storage_value_from' => array( // 'method' => 'unique-key' // ) , // 'constraints' => array( // array( // 'method' => 'unique-key' // ) // ) // ) , // // array( // 'slug' => 'pathspec' , // 'array_storage_value_from' => array( // 'method' => 'post' , // 'instance' => 'pathspec' // ) , // 'constraints' => array() // ) , // // ... // // ) , // // ... // // ['zebra_form'] => array( // // 'form_specs' => array( // 'name' => 'add_edit_plugin_component' , // 'method' => 'POST' , // 'action' => '' , // 'attributes' => array() , // 'clientside_validation' => TRUE // ) , // // 'field_specs' => array( // // array( // 'form_field_name' => 'pathspec' , // 'zebra_control_type' => 'text' , // 'label' => 'Pathspec' , // 'attributes' => array() , // 'rules' => array( // 'required' => array( // 'error' , // variable to add the error message to // 'Field is required' // error message if value doesn't validate // ) // ) // ) , // // array( // 'form_field_name' => 'save_me' , // 'zebra_control_type' => 'submit' , // 'label' => NULL , // 'attributes' => array() , // 'rules' => array() , // 'type_specific_args' => array( // 'caption' => 'Submit' // ) // ) , // // ) , // // 'focus_field_slug' => 'pathspec' // // ) // // ... // // ) // // ------------------------------------------------------------------------- //pr( func_get_args() ) ; //pr( $selected_datasets_dmdd['array_storage_record_structure'] ) ; //pr( $selected_datasets_dmdd['zebra_form']['field_specs'] ) ; //pr( $array_storage_field_details ) ; //exit() ; // ------------------------------------------------------------------------- $target_form_field_name_from_instance = NULL ; if ( isset( $value_from_details ) && isset( $value_from_details['method'] ) && strtolower( $value_from_details['method'] ) === strtolower( $get_post ) && isset( $value_from_details['instance'] ) && is_string( $value_from_details['instance'] ) && trim( $value_from_details['instance'] ) !== '' && strlen( $value_from_details['instance'] ) <= 64 && \greatKiwi_byFernTec_adSwapper_local_v0x1x210_stringUtils\ctype_varname( $value_from_details['instance'] ) ) { $target_form_field_name_from_instance = $value_from_details['instance'] ; } // ------------------------------------------------------------------------- $target_form_field_name_from_slug = NULL ; if ( isset( $array_storage_field_details['slug'] ) && is_string( $array_storage_field_details['slug'] ) && trim( $array_storage_field_details['slug'] ) !== '' && strlen( $array_storage_field_details['slug'] ) <= 64 && \greatKiwi_byFernTec_adSwapper_local_v0x1x210_stringUtils\ctype_varname( $array_storage_field_details['slug'] ) ) { $target_form_field_name_from_slug = $array_storage_field_details['slug'] ; } // ------------------------------------------------------------------------- foreach ( $zebra_form_field_indices_of_radios_type_zebra_form_fields as $zebra_form_field_index ) { // --------------------------------------------------------------------- $zebra_form_field_details = $zebra_form_definition['field_specs'][ $zebra_form_field_index ] ; // --------------------------------------------------------------------- if ( isset( $zebra_form_field_details['form_field_name'] ) && is_string( $zebra_form_field_details['form_field_name'] ) ) { // ----------------------------------------------------------------- if ( $zebra_form_field_details['form_field_name'] === $target_form_field_name_from_instance || $zebra_form_field_details['form_field_name'] === $target_form_field_name_from_slug ) { return TRUE ; } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- return FALSE ; // ------------------------------------------------------------------------- } // ============================================================================= // That's that! // =============================================================================