$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_v0x1x210_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_v0x1x210_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:-
Detected in: \\{$ns}\\{$fn}() near line {$ln}
EOT;
// -----------------------------------------------------------------
$msg = \greatKiwi_byFernTec_adSwapper_local_v0x1x210_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:-
| Field |
Problem/Error |
{$get_new_field_value_function_errors}
Detected in: \\{$ns}\\{$fn}() near line {$ln}
EOT;
// -----------------------------------------------------------------
$msg = \greatKiwi_byFernTec_adSwapper_local_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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_v0x1x210_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 .= <<{$distinct_values_summary_pages__4_field}
EOT;
// ---------------------------------------------------------------------
$record_listing_pages__4_dataset .=
$record_listing_pages__4_field
;
// =====================================================================
// Repeat with the next field slug (if there is one)...
// =====================================================================
}
// -------------------------------------------------------------------------
// Table Proper
// -------------------------------------------------------------------------
$add_table_style = << $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' => NULL ,
'action' => 'add-all-dataset-fields'
)
) ;
// -------------------------------------------------------------------------
if ( is_array( $url ) ) {
return $url[0] ;
}
// -------------------------------------------------------------------------
if ( $fields_to_add_html !== '' ) {
// ---------------------------------------------------------------------
$fields_to_add_html = <<{$number_fields_to_add} field{$fs} to
ADD - to {$total_records} record{$rs} - as follows:-
| Field Name |
#Records To Add This Field To |
#Distinct Values To Add |
#Records NOT To Add This Field To |
Action |
{$fields_to_add_html}
ADD ALL The Above Fields
EOT;
// ---------------------------------------------------------------------
}
// =========================================================================
// REMOVE
// =========================================================================
// -------------------------------------------------------------------------
// get_red_colours()
// - - - - - - - - -
// RETURNS
// list(
// $light_red_bg ,
// $dark_red_bg ,
// $red_text
// )
// -------------------------------------------------------------------------
list(
$light_red_bg ,
$dark_red_bg ,
$red_text
) = get_red_colours() ;
// -------------------------------------------------------------------------
$question_add = FALSE ;
// -------------------------------------------------------------------------
// Rows...
// -------------------------------------------------------------------------
$fields_to_remove_html = '' ;
// -------------------------------------------------------------------------
foreach ( $record_indices_by_field_slug_to_remove as $this_slug => $record_indices_to_remove_this_field_from ) {
// =====================================================================
// Get the "show_distinct_values" DIV ID...
// =====================================================================
$id = <<show distinct values
EOT;
// =====================================================================
// Action
// =====================================================================
if ( count( $record_indices_by_field_slug_to_add ) < 1 ) {
// -------------------------------------------------------------------------
// 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' => 'remove-this-field'
)
) ;
// -----------------------------------------------------------------
if ( is_array( $url ) ) {
return $url[0] ;
}
// -----------------------------------------------------------------
$action = <<remove this field
EOT;
// Can only remove fields if there are NO fields to ADD.
//
// This is because the "get New field value" routines may want
// to look at the value of fields being removed - as when
// renaming a field, for example).
// -----------------------------------------------------------------
} else {
// -----------------------------------------------------------------
$action = ' ' ;
// -----------------------------------------------------------------
}
// =====================================================================
// Field Slug Row...
// =====================================================================
$fields_to_remove_html .= <<
{$this_slug} |
{$number_records_to_remove_this_field_from__pretty} |
{$number_distinct_values__pretty} |
{$number_records_NOT_to_remove_this_field_from__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_remove[ $this_slug ] ,
$question_add
) ;
// ---------------------------------------------------------------------
$distinct_value_summary_pages__4_dataset .= <<{$distinct_values_summary_pages__4_field}
EOT;
// ---------------------------------------------------------------------
$record_listing_pages__4_dataset .=
$record_listing_pages__4_field
;
// =====================================================================
// Repeat with the next field slug (if there is one)...
// =====================================================================
}
// -------------------------------------------------------------------------
// Table Proper
// -------------------------------------------------------------------------
$remove_table_style = << $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' => NULL ,
'action' => 'remove-all-dataset-fields'
)
) ;
// ---------------------------------------------------------------------
if ( is_array( $url ) ) {
return $url[0] ;
}
// ---------------------------------------------------------------------
$remove_all = <<REMOVE ALL The Above Fields
EOT;
// ---------------------------------------------------------------------
} else {
// ---------------------------------------------------------------------
$remove_all = '' ;
// ---------------------------------------------------------------------
}
// -------------------------------------------------------------------------
if ( $fields_to_remove_html !== '' ) {
// ---------------------------------------------------------------------
$fields_to_remove_html = <<{$number_fields_to_remove} field{$fs} to
REMOVE - from {$total_records} record{$rs} - as follows:-
| Field Name |
#Records To Remove This Field From |
#Distinct Values To Remove |
#Records NOT To Remove This Field From |
Action |
{$fields_to_remove_html}
{$remove_all}
EOT;
// ---------------------------------------------------------------------
}
// =========================================================================
// EVERYTHING
// =========================================================================
$container_div_style = << $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' => NULL ,
'action' => 'add-all-then-remove-all'
)
) ;
// -------------------------------------------------------------------------
if ( is_array( $url ) ) {
return $url[0] ;
}
// -------------------------------------------------------------------------
$light_pink = '#FF1493' ;
$dark_pink = '#AD0E64' ;
// -------------------------------------------------------------------------
$manual_approval_page_html_4_dataset = <<
Array
Stored
Dataset: {$dataset_slug}
{$fields_to_add_html}
{$fields_to_remove_html}
UPDATE ENTIRE DATASET
(ADD ALL Fields To Be Added -
Then REMOVE ALL Fields To Be Removed)
EOT;
// =========================================================================
// SUCCESS
// =========================================================================
return array(
$manual_approval_page_html_4_dataset ,
$distinct_value_summary_pages__4_dataset ,
$record_listing_pages__4_dataset
) ;
// =========================================================================
// That's that!
// =========================================================================
}
/*
// =============================================================================
// get_green_colours()
// =============================================================================
function get_green_colours() {
// -------------------------------------------------------------------------
// get_green_colours()
// - - - - - - - - - -
// RETURNS
// list(
// $light_green_bg ,
// $dark_green_bg ,
// $green_text
// )
// -------------------------------------------------------------------------
return array(
'#F0FFF8' ,
'#CEFFE8' ,
'#007000'
) ;
// -------------------------------------------------------------------------
}
// =============================================================================
// get_red_colours()
// =============================================================================
function get_red_colours() {
// -------------------------------------------------------------------------
// get_red_colours()
// - - - - - - - - -
// RETURNS
// list(
// $light_red_bg ,
// $dark_red_bg ,
// $red_text
// )
// -------------------------------------------------------------------------
return array(
'#FFEEEE' ,
'#FFDDDD' ,
'#AA0000'
) ;
// -------------------------------------------------------------------------
}
// =============================================================================
// get_s()
// =============================================================================
function get_s(
$value
) {
if ( $value == 1 ) {
return '' ;
}
return 's' ;
}
// =============================================================================
// get_number_records__pretty()
// =============================================================================
function get_number_records__pretty(
$number_records ,
$total_records
) {
// -------------------------------------------------------------------------
$s = get_s( $number_records ) ;
// -------------------------------------------------------------------------
if ( $number_records === $total_records ) {
// ---------------------------------------------------------------------
return <<All ({$number_records} record{$s})
EOT;
// ---------------------------------------------------------------------
} elseif ( $number_records === 0 ) {
// ---------------------------------------------------------------------
return <<None
EOT;
// ---------------------------------------------------------------------
} else {
// ---------------------------------------------------------------------
$percent =
round(
( $number_records * 100 ) / $total_records
) ;
// ---------------------------------------------------------------------
return <<{$percent}% ({$number_records} record{$s})
EOT;
// ---------------------------------------------------------------------
}
// -------------------------------------------------------------------------
}
*/
// =============================================================================
// get_distinct_values_for_field__summary_and_record_listing_pages()
// =============================================================================
function 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
) {
// -------------------------------------------------------------------------
// 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 the records by distinct value...
// =========================================================================
// ob_start() ;
// \greatKiwi_byFernTec_adSwapper_local_v0x1x210_testDebug\pr(
// $distinct_values_and_their_record_indices ,
// '$distinct_values_and_their_record_indices'
// ) ;
// $distinct_values_for_field__summary_page = ob_get_clean() ;
// -------------------------------------------------------------------------
$tdh_style = <<{$records_for_distinct_value__listing_page}
EOT;
// ---------------------------------------------------------------------
$records_column_value = <<show/hide
EOT;
// -------------------------------------------------------------------------
// raw_2_displayable(
// $name ,
// $value
// )
// - - - - - - - - -
// RETURNS
// array(
// $displayable_value STRING ,
// $extra_info_slash_comment STRING
// )
// -------------------------------------------------------------------------
list(
$displayable_value ,
$extra_info_slash_comment
) = raw_2_displayable(
'' ,
$this_distinct_value
) ;
// ---------------------------------------------------------------------
if ( $extra_info_slash_comment !== '' ) {
$displayable_value .= <<({$extra_info_slash_comment})
EOT;
}
// ---------------------------------------------------------------------
$distinct_values_for_field__summary_page .= <<
#{$this_distinct_value_number} of {$total_distinct_values} |
{$displayable_value} |
{$this_type} |
{$records_column_value} |
EOT;
// ---------------------------------------------------------------------
$this_distinct_value_number++ ;
// ---------------------------------------------------------------------
}
// -------------------------------------------------------------------------
if ( $question_add ) {
$add_remove_1 = 'Add' ;
$add_remove_2 = 'Add To' ;
} else {
$add_remove_1 = 'Remove' ;
$add_remove_2 = 'Remove From' ;
}
// -------------------------------------------------------------------------
$distinct_values_for_field__summary_page = <<
| |
Distinct Value To {$add_remove_1} |
PHP Type |
Records To {$add_remove_2} |
{$distinct_values_for_field__summary_page}
EOT;
// =========================================================================
// Tie everything together...
// =========================================================================
$h1_style = <<
Distinct Values To {$add_remove}
back
For Dataset: {$dataset_slug}
And
Field: {$field_slug}
{$distinct_values_for_field__summary_page}
EOT;
// =========================================================================
// SUCCESS!
// =========================================================================
return array(
$distinct_values_for_field__summary_page ,
$records_for_distinct_value__listing_pages__4_all_distinct_values
) ;
// =========================================================================
// That's that!
// =========================================================================
}
/*
// =============================================================================
// raw_2_displayable()
// =============================================================================
function raw_2_displayable(
$name ,
$value
) {
// -------------------------------------------------------------------------
// raw_2_displayable(
// $name ,
// $value
// )
// - - - - - - - - -
// RETURNS
// array(
// $displayable_value STRING ,
// $extra_info_slash_comment STRING
// )
// -------------------------------------------------------------------------
$extra_info_slash_comment = '' ;
// -------------------------------------------------------------------------
if ( is_bool( $value ) ) {
// ---------------------------------------------------------------------
if ( $value ) {
$displayable_value = 'TRUE' ;
} else {
$displayable_value = 'FALSE' ;
}
// ---------------------------------------------------------------------
} elseif ( is_string( $value ) ) {
// ---------------------------------------------------------------------
$strlen = strlen( $value ) ;
// ---------------------------------------------------------------------
if ( $strlen === 0 ) {
$displayable_value = '""' ;
$extra_info_slash_comment = 'empty string' ;
} elseif ( $strlen > 255 ) {
$displayable_value = '"' . htmlentities( substr( $value , 0 , 255 ) ) . '..."';
$extra_info_slash_comment = $strlen . ' chars total; first 255 shown' ;
} else {
$displayable_value = '"' . htmlentities( $value ) . '"' ;
$extra_info_slash_comment = $strlen . ' chars' ;
}
// ---------------------------------------------------------------------
} elseif ( is_int( $value ) ) {
// ---------------------------------------------------------------------
$displayable_value = $value ;
// ---------------------------------------------------------------------
if ( contains_ignoring_case( $name , 'date' )
||
contains_ignoring_case( $name , 'time' )
) {
$extra_info_slash_comment =
gmdate( 'j M Y G:i:s' , $value )
;
// Returns a formatted date string. If a non-numeric value is
// used for timestamp, FALSE is returned and an E_WARNING level
// error is emitted.
$extra_info_slash_comment .= ' GMT' ;
}
// ---------------------------------------------------------------------
} elseif ( $value === NULL ) {
// ---------------------------------------------------------------------
$displayable_value = 'NULL' ;
// ---------------------------------------------------------------------
} else {
// ---------------------------------------------------------------------
$displayable_value = (string) $value ;
// ---------------------------------------------------------------------
}
// -------------------------------------------------------------------------
return array(
$displayable_value ,
$extra_info_slash_comment
) ;
// -------------------------------------------------------------------------
}
// =============================================================================
// contains_ignoring_case()
// =============================================================================
function contains_ignoring_case(
$haystack ,
$needle
) {
return stripos( $haystack , $needle ) !== FALSE ;
// Returns the position as an integer. If needle is
// not found, strpos() will return boolean FALSE.
}
*/
// =============================================================================
// get_records_for_distinct_value__listing_page()
// =============================================================================
function get_records_for_distinct_value__listing_page(
$core_plugapp_dirs ,
$dataset_records ,
$dataset_slug ,
$field_slug ,
$distinct_value ,
$these_record_indices ,
$question_add
) {
// -------------------------------------------------------------------------
// get_records_for_distinct_value__listing_page(
// $core_plugapp_dirs ,
// $dataset_records ,
// $dataset_slug ,
// $field_slug ,
// $distinct_value ,
// $these_record_indices ,
// $question_add
// )
// - - - - - - - - - - - - - - - - -
// RETURNS
// $records_for_distinct_value__listing_page STRING
// -------------------------------------------------------------------------
$tdh_style = << $this_record_index ) {
// ---------------------------------------------------------------------
$this_record = $dataset_records[ $this_record_index ] ;
// ---------------------------------------------------------------------
$this_records_html = '' ;
// ---------------------------------------------------------------------
foreach ( $this_record as $name => $value ) {
// -------------------------------------------------------------------------
// raw_2_displayable(
// $name ,
// $value
// )
// - - - - - - - - -
// RETURNS
// array(
// $displayable_value STRING ,
// $extra_info_slash_comment STRING
// )
// -------------------------------------------------------------------------
list(
$displayable_value ,
$extra_info_slash_comment
) = raw_2_displayable(
$name ,
$value
) ;
// -----------------------------------------------------------------
if ( $extra_info_slash_comment === '' ) {
$extra_info_slash_comment = ' ' ;
}
// -----------------------------------------------------------------
$type = gettype( $value ) ;
// -----------------------------------------------------------------
if ( $question_add === FALSE
&&
$name === $field_slug
) {
$highlight_style = <<
{$name} |
{$displayable_value} |
{$extra_info_slash_comment} |
{$type} |
EOT;
// -----------------------------------------------------------------
}
// ---------------------------------------------------------------------
if ( $question_add ) {
// -------------------------------------------------------------------------
// raw_2_displayable(
// $name ,
// $value
// )
// - - - - - - - - -
// RETURNS
// array(
// $displayable_value STRING ,
// $extra_info_slash_comment STRING
// )
// -------------------------------------------------------------------------
list(
$displayable_value ,
$extra_info_slash_comment
) = raw_2_displayable(
$field_slug ,
$distinct_value
) ;
// -----------------------------------------------------------------
if ( $extra_info_slash_comment === '' ) {
$extra_info_slash_comment = ' ' ;
}
// -----------------------------------------------------------------
$type = gettype( $distinct_value ) ;
// -----------------------------------------------------------------
$highlight_style = <<
{$field_slug} |
{$displayable_value} |
{$extra_info_slash_comment} |
{$type} |
EOT;
// -----------------------------------------------------------------
}
// ---------------------------------------------------------------------
$item_number = $this_item_index + 1 ;
// ---------------------------------------------------------------------
if ( $this_item_index > 0 ) {
$margin_top = <<
Record# {$item_number} of
{$item_count} to {$add_remove} — Out of {$total_count} dataset records
total — Record index {$this_record_index}
| Field Name |
Field Value |
Extra Info. / Comments |
PHP Type (of Field Value) |
{$this_records_html}
EOT;
// ---------------------------------------------------------------------
$all_records_html .= $this_records_html ;
// ---------------------------------------------------------------------
}
// =========================================================================
// Tie everything together...
// =========================================================================
$h1_style = <<
Records For Distinct Value To {$add_remove}
back
{$displayable_value}
For Dataset: {$dataset_slug}
And Field: {$field_slug}
{$all_records_html}
EOT;
// =========================================================================
// SUCCESS!
// =========================================================================
return $records_for_distinct_value__listing_page ;
// -------------------------------------------------------------------------
}
/*
// =============================================================================
// get_updaction_url()
// =============================================================================
function get_updaction_url(
$core_plugapp_dirs ,
$args
) {
// -------------------------------------------------------------------------
// 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 )
// -------------------------------------------------------------------------
//\greatKiwi_byFernTec_adSwapper_local_v0x1x210_testDebug\pr( $args , '$args' ) ;
// -------------------------------------------------------------------------
$args = serialize( $args ) ;
// Returns a string containing a byte-stream representation of
// value that can be stored anywhere.
//
// Note that this is a binary string which may include null
// bytes, and needs to be stored and handled as such. For
// example, serialize() output should generally be stored in a
// BLOB field in a database, rather than a CHAR or TEXT field.
// -------------------------------------------------------------------------
require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/string-utils.php' ) ;
// -------------------------------------------------------------------------
$args = \greatKiwi_byFernTec_adSwapper_local_v0x1x210_stringUtils\hex_encode( $args ) ;
// -------------------------------------------------------------------------
require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/url-utils.php' ) ;
// -------------------------------------------------------------------------
// \greatKiwi_byFernTec_adSwapper_local_v0x1x210_urlUtils\
// get_query_adjusted_current_page_url(
// $query_changes = array() ,
// $question_amp = FALSE ,
// $question_die_on_error = FALSE
// )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Attempts to retrieve the current page URL from $_SERVER.
//
// If successful, returns the URL with the query part adjusted as
// requested.
//
// ---
//
// $query_changes is like:-
//
// $query_changes = array(
// 'name1' => NULL
// 'name2' => 'xxx'
// )
//
// If the value is NULL, then the query parameter is removed (if it
// exists). Otherwise, the query parameter is set (silently overwriting
// any existing value).
//
// RETURNS
// o On SUCCESS!
// -----------
// $query_adjusted_current_page_url STRING
//
// o On FAILURE!
// -----------
// If $question_die_on_error = TRUE
// Doesn't return
// If $question_die_on_error = FALSE
// array( $error_message STRING )
// -------------------------------------------------------------------------
$query_changes = array(
'updaction' => $args
) ;
// -------------------------------------------------------------------------
$question_amp = FALSE ;
$question_die_on_error = FALSE ;
// -------------------------------------------------------------------------
return
\greatKiwi_byFernTec_adSwapper_local_v0x1x210_urlUtils\get_query_adjusted_current_page_url(
$query_changes ,
$question_amp ,
$question_die_on_error
) ;
// -------------------------------------------------------------------------
}
*/
// =============================================================================
// That's that!
// =============================================================================