$this_defn_record ) { // --------------------------------------------------------------------- $defined_field_slugs[] = $this_defn_record['slug'] ; // --------------------------------------------------------------------- foreach ( $loaded_datasets[ $dataset_slug ]['records'] as $this_data_index => $this_data_record ) { // ----------------------------------------------------------------- if ( ! array_key_exists( $this_defn_record['slug'] , $this_data_record ) ) { // ------------------------------------------------------------- if ( array_key_exists( $this_defn_record['slug'] , $record_indices_by_field_slug_to_add ) ) { $record_indices_by_field_slug_to_add[ $this_defn_record['slug'] ][] = $this_data_index ; } else { $record_indices_by_field_slug_to_add[ $this_defn_record['slug'] ] = array( $this_data_index ) ; } // ------------------------------------------------------------- } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- // Here we should have (eg):- // // $record_indices_by_field_slug_to_add = Array( // // [show_ads_list_reload_buttons] => Array( // [0] => 0 // ) // // [question_manual_update_approval] => Array( // [0] => 0 // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $record_indices_by_field_slug_to_add , // '$record_indices_by_field_slug_to_add' // ) ; // ========================================================================= // Get the fields to REMOVE (if any)... // ========================================================================= $record_indices_by_field_slug_to_remove = array() ; // ------------------------------------------------------------------------- foreach ( $loaded_datasets[ $dataset_slug ]['records'] as $this_data_index => $this_data_record ) { // --------------------------------------------------------------------- foreach ( $this_data_record as $name => $value ) { // ----------------------------------------------------------------- if ( ! in_array( $name , $defined_field_slugs , TRUE ) ) { // ------------------------------------------------------------- if ( array_key_exists( $name , $record_indices_by_field_slug_to_remove ) ) { $record_indices_by_field_slug_to_remove[ $name ][] = $this_data_index ; } else { $record_indices_by_field_slug_to_remove[ $name ] = array( $this_data_index ) ; } // ------------------------------------------------------------- } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- // Here we should have (eg):- // // $record_indices_by_field_slug_to_remove = Array( // // [hide_ads_list_reload_buttons] => Array( // [0] => 0 // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $record_indices_by_field_slug_to_remove , // '$record_indices_by_field_slug_to_remove' // ) ; // ========================================================================= // Init. // ========================================================================= $nothing_to_do = array( '' , '' , '' ) ; // ========================================================================= // Anything to do ? // ========================================================================= if ( count( $record_indices_by_field_slug_to_add ) < 1 && count( $record_indices_by_field_slug_to_remove ) < 1 ) { // ===================================================================== // Updaction Finished ? // ===================================================================== if ( array_key_exists( 'updaction_finished' , $_GET ) && $_GET['updaction_finished'] === $dataset_slug ) { return NULL ; } // ===================================================================== // That's that! // ===================================================================== return $nothing_to_do ; // --------------------------------------------------------------------- } // ========================================================================= // Check that each field to ADD has a GET NEW FIELD VALUE function... // ========================================================================= if ( count( $record_indices_by_field_slug_to_add ) > 0 ) { // ---------------------------------------------------------------------- // Here we should have (eg):- // // $selected_datasets_dmdd = array( // // ... // // 'get_new_field_value_functions' => array( // 'show_ads_list_reload_buttons' => array( // 'name' => '\\' . __NAMESPACE__ . '\\get_new_field_value_4_show_ads_list_reload_buttons' , // 'args' => array() // ) , // 'question_manual_update_approval' => array( // 'name' => '\\' . __NAMESPACE__ . '\\get_new_field_value_4_question_manual_update_approval' , // 'args' => array() // ) // ) // // ... // // ) // // --------------------------------------------------------------------- if ( ! array_key_exists( 'get_new_field_value_functions' , $selected_datasets_dmdd ) || ! is_array( $selected_datasets_dmdd['get_new_field_value_functions'] ) || count( $selected_datasets_dmdd['get_new_field_value_functions'] ) < 1 ) { // ----------------------------------------------------------------- $ln = __LINE__ - 8 ; $count = count( $record_indices_by_field_slug_to_add ) ; $field_slugs_to_add = '' ; foreach ( $record_indices_by_field_slug_to_add as $this_field_slug => $these_record_indices ) { $safe_field_slug = htmlentities( $this_field_slug ) ; $field_slugs_to_add .= <<{$safe_field_slug} EOT; } // ----------------------------------------------------------------- $msg = <<

Database Update


PROBLEM:  There are {$count} fields to ADD - but NO "get_new_field_value" functions defined.

The fields - of dataset {$safe_dataset_slug} - that need "get_new_field_value" functions - are:-

    {$field_slugs_to_add}

Detected in:  \\{$ns}\\{$fn}() near line {$ln}

EOT; // ----------------------------------------------------------------- $msg = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_one_line( $msg ) ; // ----------------------------------------------------------------- return $get_new_field_function_error_token . $msg ; // ----------------------------------------------------------------- } // --------------------------------------------------------------------- $get_new_field_value_function_errors = '' ; // --------------------------------------------------------------------- $tdh_style = << $these_record_indices ) { // ----------------------------------------------------------------- if ( ! array_key_exists( $this_field_slug , $selected_datasets_dmdd['get_new_field_value_functions'] ) ) { // ------------------------------------------------------------- $get_new_field_value_function_errors .= << {$this_field_slug} NO "get_new_field_value" function defined EOT; // ------------------------------------------------------------- continue ; // ------------------------------------------------------------- } // ----------------------------------------------------------------- if ( ! is_array( $selected_datasets_dmdd['get_new_field_value_functions'][ $this_field_slug ] ) ) { // ------------------------------------------------------------- $get_new_field_value_function_errors .= << {$this_field_slug} Bad "get_new_field_value" function definition (array expected) EOT; // ------------------------------------------------------------- continue ; // ------------------------------------------------------------- } // ----------------------------------------------------------------- if ( ! array_key_exists( 'name' , $selected_datasets_dmdd['get_new_field_value_functions'][ $this_field_slug ] ) ) { // ------------------------------------------------------------- $get_new_field_value_function_errors .= << {$this_field_slug} Bad "get_new_field_value" function definition (no function "name") EOT; // ------------------------------------------------------------- continue ; // ------------------------------------------------------------- } // ----------------------------------------------------------------- $get_new_field_value_function_name = $selected_datasets_dmdd['get_new_field_value_functions'][ $this_field_slug ]['name'] ; // ------------------------------------------------------------- if ( ! is_string( $get_new_field_value_function_name ) || trim( $get_new_field_value_function_name ) === '' ) { // ------------------------------------------------------------- $get_new_field_value_function_errors .= << {$this_field_slug} Bad "get_new_field_value" function "name" (non-empty string expected) EOT; // ------------------------------------------------------------- continue ; // ------------------------------------------------------------- } // ----------------------------------------------------------------- if ( ! function_exists( $get_new_field_value_function_name ) ) { // ------------------------------------------------------------- $get_new_field_value_function_errors .= << {$this_field_slug} Bad "get_new_field_value" function (function not found) EOT; // ------------------------------------------------------------- continue ; // ------------------------------------------------------------- } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- if ( $get_new_field_value_function_errors !== '' ) { // ----------------------------------------------------------------- $ln = __LINE__ - 4 ; // ----------------------------------------------------------------- $msg = <<

Database Update


PROBLEM:  One or more of the fields to add - to the {$safe_dataset_slug} dataset - have NO or an invalid "get_new_field_value" function.  As follows:-

{$get_new_field_value_function_errors}
Field Problem/Error

Detected in:  \\{$ns}\\{$fn}() near line {$ln}

EOT; // ----------------------------------------------------------------- $msg = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_one_line( $msg ) ; // ----------------------------------------------------------------- return $get_new_field_function_error_token . $msg ; // ----------------------------------------------------------------- } // --------------------------------------------------------------------- } // ========================================================================= // Support Routines.. // ========================================================================= require_once( dirname( __FILE__ ) . '/update-xxx-stored-dataset-data-support.php' ) ; // ========================================================================= // Get the DISTINCT VALUES to ADD... // ========================================================================= // -------------------------------------------------------------------------- // Here we should/must have (eg):- // // $selected_datasets_dmdd = array( // // ... // // 'get_new_field_value_functions' => array( // 'show_ads_list_reload_buttons' => array( // 'name' => '\\' . __NAMESPACE__ . '\\get_new_field_value_4_show_ads_list_reload_buttons' , // 'args' => array() // ) , // 'question_manual_update_approval' => array( // 'name' => '\\' . __NAMESPACE__ . '\\get_new_field_value_4_question_manual_update_approval' , // 'args' => array() // ) // ) // // ... // // ) // // -------------------------------------------------------------------------- $distinct_values_and_their_record_indices__by_field_slug__to_add = array() ; // -------------------------------------------------------------------------- foreach ( $record_indices_by_field_slug_to_add as $this_slug => $record_indices_to_add_this_field_to ) { // --------------------------------------------------------------------- $get_new_field_value_function_name = $selected_datasets_dmdd['get_new_field_value_functions'][ $this_slug ]['name'] ; // --------------------------------------------------------------------- if ( array_key_exists( 'args' , $selected_datasets_dmdd['get_new_field_value_functions'][ $this_slug ] ) ) { $get_new_field_value_function_args = $selected_datasets_dmdd['get_new_field_value_functions'][ $this_slug ]['args'] ; } else { $get_new_field_value_function_args = NULL ; } // --------------------------------------------------------------------- $distinct_values_and_their_record_indices = array() ; // --------------------------------------------------------------------- foreach ( $record_indices_to_add_this_field_to as $this_record_index ) { // ----------------------------------------------------------------- $this_record = $loaded_datasets[ $dataset_slug ]['records'][ $this_record_index ] ; // ------------------------------------------------------------------------- // ( // $core_plugapp_dirs , // $loaded_datasets , // $dataset_slug , // $selected_datasets_dmdd , // $record_indices_by_field_slug_to_add , // $record_indices_by_field_slug_to_remove , // $this_record , // $field_slug_to_add , // $get_new_field_value_function_args // ) // - - - - - - - - - - - - - - - - - - - - - - - - - // Returns the value for the specified field to be added to the // specified record. // // RETURNS // On SUCCESS // array( // $ok = TRUE // $new_field_value (any PHP type) // ) // // On FAILURE // array( // $ok = FALSE // $error_message STRING // ) // ------------------------------------------------------------------------- $result = $get_new_field_value_function_name( $core_plugapp_dirs , $loaded_datasets , $dataset_slug , $selected_datasets_dmdd , $record_indices_by_field_slug_to_add , $record_indices_by_field_slug_to_remove , $this_record , $this_slug , $get_new_field_value_function_args ) ; // ----------------------------------------------------------------- list( $ok , $new_field_value ) = $result ; // ----------------------------------------------------------------- if ( $ok === FALSE ) { return $new_field_value ; } // ------------------------------------------------------------------------- // get_list_index_4_value( // $list , // $target_value // ) // - - - - - - - - - - - - // Searches a list of records like:- // array( // array( // 'value' => // 'record_indices' => array(...) // ) // ... // ) // // for the specified value. // // RETURNS // $list_index = NULL (if target value NOT found) // --OR-- // $list_index = INT 0+ (if target value found) // ------------------------------------------------------------------------- $list_index = get_list_index_4_value( $distinct_values_and_their_record_indices , $new_field_value ) ; // ----------------------------------------------------------------- if ( is_int( $list_index ) ) { $distinct_values_and_their_record_indices[ $list_index ]['record_indices'][] = $this_record_index ; } else { $distinct_values_and_their_record_indices[] = array( 'value' => $new_field_value , 'record_indices' => array( $this_record_index ) ) ; } // ----------------------------------------------------------------- } // ---------------------------------------------------------------------- $distinct_values_and_their_record_indices__by_field_slug__to_add[ $this_slug ] = $distinct_values_and_their_record_indices ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- // Here we should have (eg):- // // $distinct_values_and_their_record_indices__by_field_slug__to_add = Array( // // [show_ads_list_reload_buttons] => Array( // // [0] => Array( // [value] => // [record_indices] => Array( // [0] => 0 // ) // ) // // ... // // ) // // [question_manual_update_approval] => Array( // // [0] => Array( // [value] => // [record_indices] => Array( // [0] => 0 // ) // ) // // ... // // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $distinct_values_and_their_record_indices__by_field_slug__to_add , // '$distinct_values_and_their_record_indices__by_field_slug__to_add' // ) ; //foreach ( $distinct_values_and_their_record_indices__by_field_slug__to_add as $this_slug => $distinct_values_and_their_record_indices ) { // foreach ( $distinct_values_and_their_record_indices as $this_record ) { // echo '
' ; // var_dump( $this_record['value'] ) ; // } //} // ========================================================================= // Get the DISTINCT VALUES to REMOVE... // ========================================================================= $distinct_values_and_their_record_indices__by_field_slug__to_remove = array() ; // -------------------------------------------------------------------------- foreach ( $record_indices_by_field_slug_to_remove as $this_slug => $record_indices_to_remove_this_field_from ) { // --------------------------------------------------------------------- $distinct_values_and_their_record_indices = array() ; // --------------------------------------------------------------------- foreach ( $record_indices_to_remove_this_field_from as $this_record_index ) { // ----------------------------------------------------------------- $this_record = $loaded_datasets[ $dataset_slug ]['records'][ $this_record_index ] ; // ----------------------------------------------------------------- $target_value = $this_record[ $this_slug ] ; // ------------------------------------------------------------------------- // get_list_index_4_value( // $list , // $target_value // ) // - - - - - - - - - - - - // Searches a list of records like:- // array( // array( // 'value' => // 'record_indices' => array(...) // ) // ... // ) // // for the specified value. // // RETURNS // $list_index = NULL (if target value NOT found) // --OR-- // $list_index = INT 0+ (if target value found) // ------------------------------------------------------------------------- $list_index = get_list_index_4_value( $distinct_values_and_their_record_indices , $target_value ) ; // ----------------------------------------------------------------- if ( is_int( $list_index ) ) { $distinct_values_and_their_record_indices[ $list_index ]['record_indices'][] = $this_record_index ; } else { $distinct_values_and_their_record_indices[] = array( 'value' => $target_value , 'record_indices' => array( $this_record_index ) ) ; } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- $distinct_values_and_their_record_indices__by_field_slug__to_remove[ $this_slug ] = $distinct_values_and_their_record_indices ; // ===================================================================== // Repeat with the next field slug to add (if there is one)... // ===================================================================== } // ------------------------------------------------------------------------- // Here we should have (eg):- // // $distinct_values_and_their_record_indices__by_field_slug__to_remove = Array( // // [hide_ads_list_reload_buttons] => Array( // // [0] => Array( // [value] => 1 // [record_indices] => Array( // [0] => 0 // ) // ) // // ... // // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $distinct_values_and_their_record_indices__by_field_slug__to_remove , // '$distinct_values_and_their_record_indices__by_field_slug__to_remove' // ) ; //foreach ( $distinct_values_and_their_record_indices__by_field_slug__to_remove as $this_slug => $distinct_values_and_their_record_indices ) { // foreach ( $distinct_values_and_their_record_indices as $this_record ) { // echo '
' ; // var_dump( $this_record['value'] ) ; // } //} // ========================================================================= // Do the requested MANUAL UPDATING (for the currently selected dataset)... // ========================================================================= if ( $this_dataset_update_method === 'manual' && array_key_exists( 'updaction' , $_GET ) && trim( $_GET['updaction'] ) !== '' && ctype_xdigit( $_GET['updaction'] ) ) { // --------------------------------------------------------------------- require_once( dirname( __FILE__ ) . '/update-and-save-array-stored-dataset-data.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\ // do_updaction_4_dataset( // $core_plugapp_dirs , // &$loaded_datasets , // $dataset_slug , // $selected_datasets_dmdd , // $record_indices_by_field_slug_to_add , // $record_indices_by_field_slug_to_remove , // $distinct_values_and_their_record_indices__by_field_slug__to_add , // $distinct_values_and_their_record_indices__by_field_slug__to_remove // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Does the dataset updating requested by:- // $_GET['updaction'] // // Then saves the updated dataset back to array storage - and re-loads the // current page. // // RETURNS // On SUCCESS // FALSE Means NO "updaction" was requested for this dataset. // So we should continue with the "auto" or "manual" // updating. // NOTE! If "updaction" WAS requested for this dataset - and // was completed successfully - then this routine // DOESN'T return. // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $result = do_updaction_4_dataset( $core_plugapp_dirs , $loaded_datasets , $dataset_slug , $selected_datasets_dmdd , $record_indices_by_field_slug_to_add , $record_indices_by_field_slug_to_remove , $distinct_values_and_their_record_indices__by_field_slug__to_add , $distinct_values_and_their_record_indices__by_field_slug__to_remove ) ; // --------------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // --------------------------------------------------------------------- // Fall through to do this dataset's "auto" or "manual" updating... // --------------------------------------------------------------------- } // ========================================================================= // Display the "MANUAL APPROVAL" page ? // ========================================================================= if ( $this_dataset_update_method === 'manual' ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\ // get_manual_approval_page_html_4_dataset( // $core_plugapp_dirs , // &$loaded_datasets , // $dataset_slug , // $selected_datasets_dmdd , // $record_indices_by_field_slug_to_add , // $record_indices_by_field_slug_to_remove , // $distinct_values_and_their_record_indices__by_field_slug__to_add , // $distinct_values_and_their_record_indices__by_field_slug__to_remove // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // On SUCCESS // array( // $manual_approval_page_html__4_dataset STRING , // $distinct_value_summary_pages__4_dataset STRING , // $record_listing_pages__4_dataset STRING // ) // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- return get_manual_approval_page_html_4_dataset( $core_plugapp_dirs , $loaded_datasets , $dataset_slug , $selected_datasets_dmdd , $record_indices_by_field_slug_to_add , $record_indices_by_field_slug_to_remove , $distinct_values_and_their_record_indices__by_field_slug__to_add , $distinct_values_and_their_record_indices__by_field_slug__to_remove ) ; // --------------------------------------------------------------------- } // ========================================================================= // AUTO-UPDATE ? // ========================================================================= if ( $this_dataset_update_method === 'auto' ) { // --------------------------------------------------------------------- // Create the updated dataset... // --------------------------------------------------------------------- $new_dataset_records = $loaded_datasets[ $dataset_slug ]['records'] ; // --------------------------------------------------------------------- // ADD ALL // --------------------------------------------------------------------- foreach ( $distinct_values_and_their_record_indices__by_field_slug__to_add as $this_field_slug => $these_distinct_values_and_record_indices ) { // ----------------------------------------------------------------- foreach ( $these_distinct_values_and_record_indices as $this_distinct_value_and_its_record_indices ) { // ------------------------------------------------------------- $this_distinct_value = $this_distinct_value_and_its_record_indices['value'] ; // ------------------------------------------------------------- $these_record_indices = $this_distinct_value_and_its_record_indices['record_indices'] ; // ------------------------------------------------------------- foreach ( $these_record_indices as $this_target_index ) { // --------------------------------------------------------- $new_dataset_records[ $this_target_index ][ $this_field_slug ] = $this_distinct_value ; // --------------------------------------------------------- } // ------------------------------------------------------------- } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- // REMOVE ALL // --------------------------------------------------------------------- foreach ( $distinct_values_and_their_record_indices__by_field_slug__to_remove as $this_field_slug => $these_distinct_values_and_record_indices ) { // ----------------------------------------------------------------- foreach ( $these_distinct_values_and_record_indices as $this_distinct_value_and_its_record_indices ) { // ------------------------------------------------------------- foreach ( $this_distinct_value_and_its_record_indices['record_indices'] as $this_target_index ) { // --------------------------------------------------------- unset( $new_dataset_records[ $this_target_index ][ $this_field_slug ] ) ; // --------------------------------------------------------- } // ------------------------------------------------------------- } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- // Save the updated dataset... // --------------------------------------------------------------------- // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_arrayStorage\ // save_numerically_indexed( // $dataset_name , // $array_to_save , // $question_die_on_error = FALSE , // $array_storage_data = NULL // ) // - - - - - - - - - - - - - - - - - - - - - - - - - // Saves the specified numerically-indexed PHP array. // // NOTE! // ----- // Does:- // $array_to_save = array_values( $array_to_save ) ; // // to ensures it's indices are 0, 1, 2... (before saving it). // // --- // // $array_storage_data can be either:- // // o NULL (in which case:- // $GLOBALS['GREAT_KIWI']['ARRAY_STORAGE'] // is used), or; // // o array( // 'default_storage_method' => "json" | "basepress-dataset" // 'json_data_files_dir' => NULL | "xxx" // 'supported_datasets' => $supported_datasets // ) // Where $supported_datasets is:- // array( // '' => array( // 'storage_method' => NULL | "json" | "basepress-dataset" , // 'json_filespec' => NULL | "xxx" , // 'basepress_dataset_handle' => $some_basepress_dataset_handle // ) // ... // ) // Where $some_basepress_dataset_handle is (eg):- // array( // 'nice_name' => 'adSwapper_byFerntec_someDatasetName' , // 'unique_key' => $some_basepress_dataset_uid , // 'version' => '0.1' // ) // Where $some_basepress_dataset_uid is (eg):- // '2f35c079-ef2e-4dea-a0e2-f1f861375aef' . '-' . // 'afe2576d-76b2-4a5c-83a3-60b652467438' . '-' . // '995a2d40-63d3-11e3-949a-0800200c9a66' . '-' . // 'a6acf950-63d3-11e3-949a-0800200c9a66' // ; // // RETURNS // o On SUCCESS // - - - - - // TRUE // // o On FAILURE // - - - - - // $error message STRING // ------------------------------------------------------------------------- $result = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_arrayStorage\save_numerically_indexed( $dataset_slug , $new_dataset_records ) ; // --------------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // --------------------------------------------------------------------- return TRUE ; // Update required and successfully completed! // --------------------------------------------------------------------- } // ========================================================================= // SUCCESS // ========================================================================= return FALSE ; // Update required but NOT done! // ========================================================================= // That's that! // ========================================================================= } /* // ============================================================================= // get_list_index_4_value() // ============================================================================= function get_list_index_4_value( $list , $target_value ) { // ------------------------------------------------------------------------- // get_list_index_4_value( // $list , // $target_value // ) // - - - - - - - - - - - - // Searches a list of records like:- // array( // array( // 'value' => // 'record_indices' => array(...) // ) // ... // ) // // for the specified value. // // RETURNS // $list_index = NULL (if target value NOT found) // --OR-- // $list_index = INT 0+ (if target value found) // ------------------------------------------------------------------------- foreach ( $list as $list_index => $list_record ) { if ( $list_record['value'] === $target_value ) { return $list_index ; } } // ------------------------------------------------------------------------- return NULL ; // ------------------------------------------------------------------------- } */ // ============================================================================= // get_manual_approval_page_html_4_dataset() // ============================================================================= function get_manual_approval_page_html_4_dataset( $core_plugapp_dirs , &$loaded_datasets , $dataset_slug , $selected_datasets_dmdd , $record_indices_by_field_slug_to_add , $record_indices_by_field_slug_to_remove , $distinct_values_and_their_record_indices__by_field_slug__to_add , $distinct_values_and_their_record_indices__by_field_slug__to_remove ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\ // get_manual_approval_page_html_4_dataset( // $core_plugapp_dirs , // &$loaded_datasets , // $dataset_slug , // $selected_datasets_dmdd , // $record_indices_by_field_slug_to_add , // $record_indices_by_field_slug_to_remove , // $distinct_values_and_their_record_indices__by_field_slug__to_add , // $distinct_values_and_their_record_indices__by_field_slug__to_remove // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // On SUCCESS // array( // $manual_approval_page_html__4_dataset STRING , // $distinct_value_summary_pages__4_dataset STRING , // $record_listing_pages__4_dataset STRING // ) // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Here we should have (eg):- // // $record_indices_by_field_slug_to_add = Array( // // [show_ads_list_reload_buttons] => Array( // [0] => 0 // ) // // [question_manual_update_approval] => Array( // [0] => 0 // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $record_indices_by_field_slug_to_add , // '$record_indices_by_field_slug_to_add' // ) ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $record_indices_by_field_slug_to_remove = Array( // // [hide_ads_list_reload_buttons] => Array( // [0] => 0 // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $record_indices_by_field_slug_to_remove , // '$record_indices_by_field_slug_to_remove' // ) ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $distinct_values_and_their_record_indices__by_field_slug__to_add = Array( // // [show_ads_list_reload_buttons] => Array( // // [0] => Array( // [value] => // [record_indices] => Array( // [0] => 0 // ) // ) // // ... // // ) // // [question_manual_update_approval] => Array( // // [0] => Array( // [value] => // [record_indices] => Array( // [0] => 0 // ) // ) // // ... // // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $distinct_values_and_their_record_indices__by_field_slug__to_add , // '$distinct_values_and_their_record_indices__by_field_slug__to_add' // ) ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $distinct_values_and_their_record_indices__by_field_slug__to_remove = Array( // // [hide_ads_list_reload_buttons] => Array( // // [0] => Array( // [value] => 1 // [record_indices] => Array( // [0] => 0 // ) // ) // // ... // // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $distinct_values_and_their_record_indices__by_field_slug__to_remove , // '$distinct_values_and_their_record_indices__by_field_slug__to_remove' // ) ; // ========================================================================= // Init. // ========================================================================= $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ------------------------------------------------------------------------- $total_records = count( $loaded_datasets[ $dataset_slug ]['records'] ) ; // ------------------------------------------------------------------------- $intro_style = << $record_indices_to_add_this_field_to ) { // ===================================================================== // Get the "show_distinct_values" DIV ID... // ===================================================================== $id = <<show distinct values EOT; // ===================================================================== // Add the field slug row... // ===================================================================== // ------------------------------------------------------------------------- // get_updaction_url( // $core_plugapp_dirs , // $args // ) // - - - - - - - - - - - - - - - // Adds the "updaction" parameters specified in $args, to the current // page url. // // $args should be like (eg):- // // $args = array( // 'dataset' => $dataset_slug , // 'field' => $this_slug , // 'action' => 'add-this-field' // ) // // RETURNS // On SUCCESS // $url STRING // // On FAILURE // array( $error_message STRING ) // ------------------------------------------------------------------------- $url = get_updaction_url( $core_plugapp_dirs , array( 'dataset' => $dataset_slug , 'field' => $this_slug , 'action' => 'add-this-field' ) ) ; // --------------------------------------------------------------------- if ( is_array( $url ) ) { return $url[0] ; } // --------------------------------------------------------------------- $action = <<add this field EOT; // --------------------------------------------------------------------- $fields_to_add_html .= << {$this_slug} {$number_records_to_add_this_field_to__pretty} {$number_distinct_values__pretty} {$number_records_NOT_to_add_this_field_to__pretty} {$action} EOT; // ===================================================================== // Get the distinct values (for this field slug)... // ===================================================================== // ------------------------------------------------------------------------- // get_distinct_values_for_field__summary_and_record_listing_pages( // $core_plugapp_dirs , // $dataset_records , // $dataset_slug , // $field_slug , // $distinct_values_and_their_record_indices , // $question_add // ) // - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // array( // $distinct_values_summary_pages__4_field STRING // $record_listing_pages__4_field STRING // ) // ------------------------------------------------------------------------- list( $distinct_values_summary_pages__4_field , $record_listing_pages__4_field ) = get_distinct_values_for_field__summary_and_record_listing_pages( $core_plugapp_dirs , $loaded_datasets[ $dataset_slug ]['records'] , $dataset_slug , $this_slug , $distinct_values_and_their_record_indices__by_field_slug__to_add[ $this_slug ] , $question_add ) ; // --------------------------------------------------------------------- $distinct_value_summary_pages__4_dataset .= <<