'projects' ,
// 'dataset_name_singular' => 'project' ,
// 'dataset_name_plural' => 'projects' ,
// 'dataset_title_singular' => 'Project' ,
// 'dataset_title_plural' => 'Projects' ,
// 'basepress_dataset_handle' => array(...) ,
// 'dataset_records_table' => array(...) ,
// 'zebra_form' => array(...) ,
// 'array_storage_record_structure' => array(...) ,
// 'array_storage_key_field_slug' => 'key'
// )
//
// Where $selected_datasets_dmdd['dataset_records_table'] is like (eg):-
//
// $selected_datasets_dmdd['dataset_records_table'] = array(
//
// 'column_defs' => array(
//
// // array(
// // 'base_slug' => 'xxx'
// // 'label' => 'Xxx' OR ''/NULL (means use "to_title( )"
// // 'question_sortable' => TRUE OR FALSE/NULL
// // 'raw_value_from' => array(
// // 'method' => 'array-storage-field-slug' ,
// // 'instance' => "xxx"
// // ) ,
// // --OR--
// // array(
// // 'method' => 'special-type' ,
// // 'instance' => "action"
// // ) ,
// // --OR--
// // array(
// // 'method' => 'foreign-field' ,
// // 'instance' => ""
// // 'args' => array(
// // array(
// // 'pointer_field_array_storage_slug' => '' ,
// // 'foreign_dataset' => ''
// // ) ,
// // ...
// // )
// // ) ,
// //
// // 'width_in_percent' => 1 to 100 (All columns must add up 100%. Though
// // some columns may be left 0/NULL or unspecified -
// // in which case the leftover width will be evenly
// // distributed amongst these columns.
// // 'header_halign' => 'left' | 'center' | 'right'
// // 'header_valign' => 'top' | 'middle' | 'bottom'
// // 'data_halign' => 'left' | 'center' | 'right'
// // 'data_valign' => 'top' | 'middle' | 'bottom'
// //
// // 'data_field_slug_to_display' => "xxx" (generated automatically; DON'T specify)
// // 'data_field_slug_to_sort_by' => "xxx" (generated automatically; DON'T specify)
// // ) ,
//
// array(
// 'base_slug' => 'title' ,
// 'label' => 'Project Title' ,
// 'question_sortable' => TRUE ,
// 'raw_value_from' => array(
// 'method' => 'array-storage-field-slug' ,
// 'instance' => 'title'
// ) ,
// 'display_treatments' => NULL ,
// 'sort_treatments' => NULL
// ) ,
//
// array(
// 'base_slug' => 'action' ,
// 'label' => 'Action' ,
// 'question_sortable' => FALSE ,
// 'raw_value_from' => array(
// 'method' => 'special-type' ,
// 'instance' => 'action'
// ) ,
// 'display_treatments' => NULL ,
// 'sort_treatments' => NULL
// )
//
// ) ,
//
// [rows_per_page] => 10
// [default_data_field_slug_to_orderby] => title
// [default_order] => asc
// [actions] => Array(
// [edit] => edit
// [delete] => delete
// )
// [action_separator] =>
//
// )
//
// -------------------------------------------------------------------------
// =========================================================================
// Init.
// =========================================================================
$ns = __NAMESPACE__ ;
$fn = __FUNCTION__ ;
// =========================================================================
// Select the dataset records table to use...
// =========================================================================
// -------------------------------------------------------------------------
// NOTE!
// =====
// This is used when the dataset definition has a:-
// "dataset_records_tables_by_role"
//
// member. Eg:-
//
// $selected_datasets_dmdd = array(
// ...
// 'dataset_records_table' => NULL // OPTIONAL
// 'dataset_records_tables_by_role' => array(
// 'administrator' => $dataset_records_table_4_admins ,
// '' => $dataset_records_table_4_non_admins
// )
// ...
// )
//
// Where the "dataset_records_tables_by_role" key '' (the empty string,)
// indicates the dataset records table to use if the current user's role
// wasn't found in:-
// "dataset_records_tables_by_role"
// -------------------------------------------------------------------------
if ( array_key_exists( 'dataset_records_tables_by_role' , $selected_datasets_dmdd ) ) {
// ---------------------------------------------------------------------
if ( ! is_array( $selected_datasets_dmdd['dataset_records_tables_by_role'] ) ) {
return << Array(
// [0] => administrator
// )
// ...
// )
//
// ---------------------------------------------------------------------
//\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( (array) $current_user ) ;
// ---------------------------------------------------------------------
$dataset_records_table = NULL ;
// ---------------------------------------------------------------------
foreach ( $current_user->roles as $role_name ) {
// -----------------------------------------------------------------
if ( array_key_exists( $role_name , $selected_datasets_dmdd['dataset_records_tables_by_role'] ) ) {
$dataset_records_table =
$selected_datasets_dmdd['dataset_records_tables_by_role'][ $role_name ]
;
break ;
}
// -----------------------------------------------------------------
}
// ---------------------------------------------------------------------
if ( $dataset_records_table === NULL
&&
array_key_exists( '' , $selected_datasets_dmdd['dataset_records_tables_by_role'] )
) {
$dataset_records_table =
$selected_datasets_dmdd['dataset_records_tables_by_role'][ '' ]
;
}
// ---------------------------------------------------------------------
$selected_datasets_dmdd['dataset_records_table'] = $dataset_records_table ;
// ---------------------------------------------------------------------
}
// =========================================================================
// INIT the OUTPUT table...
// =========================================================================
if ( array_key_exists( 'dataset_records_table' , $selected_datasets_dmdd ) ) {
// ---------------------------------------------------------------------
// Is Array ?
// ---------------------------------------------------------------------
if ( ! is_array( $selected_datasets_dmdd['dataset_records_table'] ) ) {
return << 'xxx'
// // 'label' => 'Xxx' OR ''/NULL (means use "to_title( )"
// // 'question_sortable' => TRUE OR FALSE/NULL
// // 'raw_value_from' => array(
// // 'method' => 'array-storage-field-slug' ,
// // 'instance' => "xxx"
// // ) ,
// // --OR--
// // array(
// // 'method' => 'special-type' ,
// // 'instance' => "action"
// // ) ,
// // --OR--
// // array(
// // 'method' => 'foreign-field' ,
// // 'instance' => ""
// // 'args' => array(
// // array(
// // 'pointer_field_array_storage_slug' => '' ,
// // 'foreign_dataset' => ''
// // ) ,
// // ...
// // )
// // ) ,
// //
// // 'width_in_percent' => 1 to 100 (All columns must add up 100%. Though
// // some columns may be left 0/NULL or unspecified -
// // in which case the leftover width will be evenly
// // distributed amongst these columns.
// // 'header_halign' => 'left' | 'center' | 'right'
// // 'header_valign' => 'top' | 'middle' | 'bottom'
// // 'data_halign' => 'left' | 'center' | 'right'
// // 'data_valign' => 'top' | 'middle' | 'bottom'
// //
// // 'data_field_slug_to_display' => "xxx" (generated automatically; DON'T specify)
// // 'data_field_slug_to_sort_by' => "xxx" (generated automatically; DON'T specify)
// // ) ,
//
// array(
// 'base_slug' => 'title' ,
// 'label' => 'Project Title' ,
// 'question_sortable' => TRUE ,
// 'raw_value_from' => array(
// 'method' => 'array-storage-field-slug' ,
// 'instance' => 'title'
// ) ,
// 'display_treatments' => NULL ,
// 'sort_treatments' => NULL
// ) ,
//
// array(
// 'base_slug' => 'action' ,
// 'label' => 'Action' ,
// 'question_sortable' => FALSE ,
// 'raw_value_from' => array(
// 'method' => 'special-type' ,
// 'instance' => 'action'
// ) ,
// 'display_treatments' => NULL ,
// 'sort_treatments' => NULL
// )
//
// )
//
// -------------------------------------------------------------------------
//\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records_table ) ;
if ( array_key_exists( 'column_defs' , $dataset_records_table ) ) {
// ---------------------------------------------------------------------
if ( ! is_array( $dataset_records_table['column_defs'] ) ) {
return << 0
// Without the above:-
// && count( $dataset_records ) > 0
//
// we get a:-
// PROBLEM defaulting the "dataset_records_table" from the dataset's records (there are NO dataset records to default the table columns from)
// For dataset: Topics
// Detected in: \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\check_and_default_dataset_records_table()
//
// error.
) {
// -----------------------------------------------------------------
$dataset_records_table['column_defs'] = array() ;
// -----------------------------------------------------------------
}
//\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records_table ) ;
// =========================================================================
// AUTO-CREATE the COLUMN DEFS (from the ARRAY STORAGE records)?
// =========================================================================
if ( array_key_exists( 'auto_create_column_defs' , $dataset_records_table ) ) {
// ---------------------------------------------------------------------
if ( ! function_exists( '\greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\is_raw_mode_for_tables' )
||
\greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\is_raw_mode_for_tables() !== TRUE
) {
// -------------------------------------------------------------------------
// auto_create_column_defs(
// $selected_datasets_dmdd ,
// $dataset_records_table_definition ,
// $dataset_title
// )
// - - - - - - - - - - - - - - - - - - - - -
// Auto-creates the Dataset Records Table Columns from the Array Storage
// Record definition.
//
// RETURNS
// o On SUCCESS!
// $updated_column_defs ARRAY
//
// o On FAILURE!
// $error_message STRING
// -------------------------------------------------------------------------
$updated_column_defs = auto_create_column_defs(
$selected_datasets_dmdd ,
$dataset_records_table ,
$dataset_title
) ;
// -----------------------------------------------------------------
if ( is_string( $updated_column_defs ) ) {
return $updated_column_defs ;
}
// -----------------------------------------------------------------
$dataset_records_table['column_defs'] = $updated_column_defs ;
// -----------------------------------------------------------------
}
// ---------------------------------------------------------------------
}
//\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records_table ) ;
// =========================================================================
// AUTO-CREATE the COLUMN DEFS (from the DATASET records)?
// =========================================================================
if ( count( $dataset_records_table['column_defs'] ) < 1 ) {
// ---------------------------------------------------------------------
// DEFAULT the DATA FIELD DEFINITIONS from the DATASET RECORDS...
// ---------------------------------------------------------------------
if ( count( $dataset_records ) < 1 ) {
return << $value ) {
// -----------------------------------------------------------------
$dataset_records_table['column_defs'][] = array(
'base_slug' => $name ,
'label' => \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_title( $name ) ,
'question_sortable' => TRUE ,
'raw_value_from' => array(
'method' => 'array-storage-field-slug' ,
'instance' => $name
) ,
'display_treatments' => NULL ,
'sort_treatments' => NULL
) ;
// -----------------------------------------------------------------
}
// ---------------------------------------------------------------------
// Add the DEFAULT ACTIONS COLUMN...
// ---------------------------------------------------------------------
$dataset_records_table['column_defs'][] = array(
'base_slug' => 'action' ,
'label' => 'Action' ,
'question_sortable' => FALSE ,
'raw_value_from' => array(
'method' => 'special-type' ,
'instance' => 'record-action'
) ,
'display_treatments' => NULL ,
'sort_treatments' => NULL
) ;
// ---------------------------------------------------------------------
}
//pr( $dataset_records_table['column_defs'] ) ;
// =========================================================================
// Finish checking and defaulting the COLUMN DEFS...
// =========================================================================
// -------------------------------------------------------------------------
// Here we should have (eg):-
//
// $dataset_records_table['column_defs'] = array(
//
// // array(
// // 'base_slug' => 'xxx'
// // 'label' => 'Xxx' OR ''/NULL (means use "to_title( )"
// // 'question_sortable' => TRUE OR FALSE/NULL
// // 'raw_value_from' => array(
// // 'method' => 'array-storage-field-slug' ,
// // 'instance' => "xxx"
// // ) ,
// // --OR--
// // array(
// // 'method' => 'special-type' ,
// // 'instance' => "action"
// // ) ,
// // --OR--
// // array(
// // 'method' => 'foreign-field' ,
// // 'instance' => ""
// // 'args' => array(
// // array(
// // 'pointer_field_array_storage_slug' => '' ,
// // 'foreign_dataset' => ''
// // ) ,
// // ...
// // )
// // ) ,
// //
// // 'display_treatments' => NULL ,
// // 'sort_treatments' => NULL ,
// //
// // 'width_in_percent' => 1 to 100 (All columns must add up 100%. Though
// // some columns may be left 0/NULL or unspecified -
// // in which case the leftover width will be evenly
// // distributed amongst these columns.
// // 'header_halign' => 'left' | 'center' | 'right'
// // 'header_valign' => 'top' | 'middle' | 'bottom'
// // 'data_halign' => 'left' | 'center' | 'right'
// // 'data_valign' => 'top' | 'middle' | 'bottom'
// //
// // 'data_field_slug_to_display' => "xxx" (generated automatically; DON'T specify)
// // 'data_field_slug_to_sort_by' => "xxx" (generated automatically; DON'T specify)
// // ) ,
//
// array(
// 'base_slug' => 'title' ,
// 'label' => 'Project Title' ,
// 'question_sortable' => TRUE ,
// 'raw_value_from' => array(
// 'method' => 'array-storage-field-slug' ,
// 'instance' => 'title'
// ) ,
// 'display_treatments' => NULL ,
// 'sort_treatments' => NULL
// ) ,
//
// array(
// 'base_slug' => 'action' ,
// 'label' => 'Action' ,
// 'question_sortable' => FALSE ,
// 'raw_value_from' => array(
// 'method' => 'special-type' ,
// 'instance' => 'action'
// ) ,
// 'display_treatments' => NULL ,
// 'sort_treatments' => NULL
// )
//
// )
//
// -------------------------------------------------------------------------
$total_widths_in_percent_so_far = 0 ;
$number_columns_with_unspecified_width = 0 ;
// -------------------------------------------------------------------------
$allowed_haligns = array( 'left' , 'center' , 'right' ) ;
$allowed_valigns = array( 'top' , 'middle' , 'bottom' ) ;
// -------------------------------------------------------------------------
foreach ( $dataset_records_table['column_defs'] as $this_index => $this_column_def ) {
// ---------------------------------------------------------------------
$column_number = $this_index + 1 ;
// =====================================================================
// BASE_SLUG ?
// =====================================================================
// ---------------------------------------------------------------------
// If NOT specified, we try to default it from the "instance" in:-
//
// 'raw_value_from' => array(
// 'method' => 'array-storage-field-slug' ,
// 'instance' => "xxx"
// ) ,
// --OR--
// array(
// 'method' => 'special-type' ,
// 'instance' => "action"
// ) ,
// --OR--
// array(
// 'method' => 'foreign-field' ,
// 'instance' => ""
// )
//
// But if this ISN'T possible, it's a FATAL error.
// =====================================================================
if ( ! array_key_exists( 'base_slug' , $this_column_def )
||
$this_column_def['base_slug'] === NULL
) {
// -----------------------------------------------------------------
if ( array_key_exists( 'raw_value_from' , $this_column_def )
&&
is_array( $this_column_def['raw_value_from'] )
&&
array_key_exists( 'method' , $this_column_def['raw_value_from'] )
&&
in_array(
$this_column_def['raw_value_from']['method'] ,
array( 'array-storage-field-slug' ,
'special-type' ,
'foreign-field'
) ,
TRUE
)
&&
array_key_exists( 'instance' , $this_column_def['raw_value_from'] )
&&
is_string( $this_column_def['raw_value_from']['instance'] )
&&
trim( $this_column_def['raw_value_from']['instance'] ) !== ''
&&
\greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\ctype_varname( $this_column_def['raw_value_from']['instance'] )
&&
strlen( $this_column_def['raw_value_from']['instance'] ) <= 64
) {
$dataset_records_table['column_defs'][ $this_index ]['base_slug'] =
$this_column_def['raw_value_from']['instance']
;
} else {
return << 64
) {
return << 'array-storage-field-slug' ,
// 'instance' => "xxx"
// )
//
// --OR--
//
// $this_column_def['raw_value_from'] = array(
// 'method' => 'special-type' ,
// 'instance' => "action"
// )
//
// --OR--
//
// $this_column_def['raw_value_from'] = array(
// 'method' => 'foreign-field' ,
// 'instance' => ""
// 'args' => array(
// array(
// 'pointer_field_array_storage_slug' => '' ,
// 'foreign_dataset' => ''
// ) ,
// ...
// )
// )
//
// But if:-
// $this_column_def['raw_value_from']
//
// ISN'T specified, we'll try to default it from:-
// $this_column_def['base_slug']
//
// Though if this ISN'T possible, it's a FATAL error.
// ---------------------------------------------------------------------
if ( ! array_key_exists( 'raw_value_from' , $this_column_def )
||
$this_column_def['raw_value_from'] === NULL
) {
// -----------------------------------------------------------------
$dataset_records_table['column_defs'][ $this_index ]['raw_value_from'] = array(
'method' => 'array-storage-field-slug' ,
'instance' => $dataset_records_table['column_defs'][ $this_index ]['base_slug']
) ;
// -----------------------------------------------------------------
} else {
// -----------------------------------------------------------------
if ( ! is_array( $this_column_def['raw_value_from'] ) ) {
return << 64
) {
return << 0 ) {
$dataset_records_table['column_defs'][ $this_index ]['data_field_slug_to_display'] =
$dataset_records_table['column_defs'][ $this_index ]['base_slug'] . '_display'
;
} else {
$dataset_records_table['column_defs'][ $this_index ]['data_field_slug_to_display'] =
$dataset_records_table['column_defs'][ $this_index ]['base_slug']
;
}
// =====================================================================
// DATA_FIELD_SLUG_TO_SORT_BY ?
// =====================================================================
if ( $dataset_records_table['column_defs'][ $this_index ]['question_sortable']
&&
count( $dataset_records_table['column_defs'][ $this_index ]['sort_treatments'] ) > 0
) {
$dataset_records_table['column_defs'][ $this_index ]['data_field_slug_to_sort_by'] =
$dataset_records_table['column_defs'][ $this_index ]['base_slug'] . '_sort'
;
} else {
$dataset_records_table['column_defs'][ $this_index ]['data_field_slug_to_sort_by'] =
$dataset_records_table['column_defs'][ $this_index ]['base_slug']
;
}
// =====================================================================
// HEADER_HALIGN ?
// =====================================================================
if ( isset( $this_column_def['header_halign'] ) ) {
if ( ! in_array( $this_column_def['header_halign'] , $allowed_haligns , TRUE ) ) {
return << 100
) {
return << 100 ) {
return << 0 ) {
// ---------------------------------------------------------------------
// min column width is 1%...
// ---------------------------------------------------------------------
$leftover_width_required = $number_columns_with_unspecified_width ;
$leftover_width_available = 100 - $total_widths_in_percent_so_far ;
// ---------------------------------------------------------------------
if ( $leftover_width_required > $leftover_width_available ) {
$leftover_width_available = round( $leftover_width_available , 1 ) ;
return << $this_column_def ) {
if ( $this_column_def['width_in_percent'] == 0 ) {
$dataset_records_table['column_defs'][ $this_index ]['width_in_percent'] =
$leftover_width_per_column
;
$total_widths_in_percent_so_far += $leftover_width_per_column ;
}
}
// ---------------------------------------------------------------------
}
// -------------------------------------------------------------------------
if ( $total_widths_in_percent_so_far < 98
||
$total_widths_in_percent_so_far > 102
) {
return << 'xxx' || ''/NULL (means orderby FIRST available data field)
// ---------------------------------------------------------------------
foreach ( $dataset_records_table['column_defs'] as $this_index => $this_column_def ) {
if ( $this_column_def['question_sortable'] ) {
$dataset_records_table['default_data_field_slug_to_orderby'] =
$this_column_def['data_field_slug_to_sort_by']
;
break ;
}
}
// ---------------------------------------------------------------------
}
// =========================================================================
// DEFAULT_ORDER ?
// =========================================================================
if ( ! isset( $dataset_records_table['default_order'] ) ) {
// ---------------------------------------------------------------------
// default_order
// => 'asc' OR 'desc' OR ''/NULL (means default to "asc")
// ---------------------------------------------------------------------
$dataset_records_table['default_order'] = 'asc' ;
// ---------------------------------------------------------------------
}
// =========================================================================
// ACTIONS ?
// =========================================================================
if ( ! isset( $dataset_records_table['actions'] ) ) {
// ---------------------------------------------------------------------
// actions
// => array(
// 'edit' => 'edit' ,
// 'delete' => 'delete'
// )
// ---------------------------------------------------------------------
$dataset_records_table['actions'] = array(
'edit' => 'edit' ,
'delete' => 'delete'
) ;
// ---------------------------------------------------------------------
}
// =========================================================================
// ACTION_SEPARATOR ?
// =========================================================================
if ( ! isset( $dataset_records_table['action_separator'] ) ) {
// ---------------------------------------------------------------------
// action_separator
// => ' '
// ---------------------------------------------------------------------
$dataset_records_table['action_separator'] = ' ' ;
// ---------------------------------------------------------------------
}
// =========================================================================
// SUCCESS!
// =========================================================================
$dataset_records_table['checked_defaulted_ok'] = TRUE ;
// -------------------------------------------------------------------------
return $dataset_records_table ;
// =========================================================================
// That's that!
// =========================================================================
}
// =============================================================================
// auto_create_column_defs()
// =============================================================================
function auto_create_column_defs(
$selected_datasets_dmdd ,
$dataset_records_table ,
$dataset_title
) {
// -------------------------------------------------------------------------
// auto_create_column_defs(
// $selected_datasets_dmdd ,
// $dataset_records_table ,
// $dataset_title
// )
// - - - - - - - - - - - - - - - - -
// Auto-creates the Dataset Records Table Columns from the Array Storage
// Record definition.
//
// RETURNS
// o On SUCCESS!
// $updated_column_defs ARRAY
//
// o On FAILURE!
// $error_message STRING
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Here we should have (eg):-
//
// $dataset_records_table['auto_create_column_defs'] = array(
// 'include' => 'all'
// --OR--
// array(
// '' ,
// '' ,
// ...
// ''
// )
// 'exclude' => 'none'
// --OR--
// array(
// '' ,
// '' ,
// ...
// ''
// )
// ) ,
//
// -------------------------------------------------------------------------
// =========================================================================
// Init.
// =========================================================================
$ns = __NAMESPACE__ ;
$fn = __FUNCTION__ ;
// =========================================================================
// Get the ARRAY STORAGE FIELD SLUGS...
// =========================================================================
// Very simple version...
$array_storage_field_slugs = array() ;
foreach ( $selected_datasets_dmdd['array_storage_record_structure'] as $this_field ) {
// TODO Error Checking ???
$array_storage_field_slugs[] = $this_field['slug'] ;
}
// =========================================================================
// include ?
// =========================================================================
if ( ! array_key_exists( 'include' , $dataset_records_table['auto_create_column_defs'] ) ) {
// ---------------------------------------------------------------------
$include = $array_storage_field_slugs ;
// ---------------------------------------------------------------------
} elseif ( $dataset_records_table['auto_create_column_defs']['include'] === 'all' ) {
// ---------------------------------------------------------------------
$include = $array_storage_field_slugs ;
// ---------------------------------------------------------------------
} elseif ( ! is_array( $dataset_records_table['auto_create_column_defs']['include'] )
||
count( $dataset_records_table['auto_create_column_defs']['include'] ) < 1
) {
// ---------------------------------------------------------------------
return << $this_candidate_array_storage_field_slug ) {
if ( ! in_array( $this_candidate_array_storage_field_slug , $array_storage_field_slugs , TRUE ) ) {
$entry_number = $this_index + 1 ;
return << $this_candidate_array_storage_field_slug ) {
if ( ! in_array( $this_candidate_array_storage_field_slug , $array_storage_field_slugs , TRUE ) ) {
$entry_number = $this_index + 1 ;
return <<['column_defs'] = array(
//
// array(
// 'base_slug' => 'title' ,
// 'label' => 'Title' ,
// 'question_sortable' => TRUE ,
// 'raw_value_from' => array(
// 'method' => 'array-storage-field-slug' ,
// 'instance' => 'title'
// ) ,
// 'display_treatments' => array(
// array(
// 'method' => 'bold'
// )
// )
// )
//
// ...
//
// )
//
// -------------------------------------------------------------------------
$pre_defined_column_indices_by_base_slug = array() ;
// -------------------------------------------------------------------------
foreach ( $dataset_records_table['column_defs'] as $this_index => $this_column_def ) {
// ---------------------------------------------------------------------
$column_number = $this_index + 1 ;
// ---------------------------------------------------------------------
if ( ! is_array( $this_column_def ) ) {
return <<['column_defs'] = array(
//
// array(
// 'base_slug' => 'title' ,
// 'label' => 'Title' ,
// 'question_sortable' => TRUE ,
// 'raw_value_from' => array(
// 'method' => 'array-storage-field-slug' ,
// 'instance' => 'title'
// ) ,
// 'display_treatments' => array(
// array(
// 'method' => 'bold'
// )
// )
// )
//
// ...
//
// )
//
// -------------------------------------------------------------------------
$updated_column_defs = array() ;
// -------------------------------------------------------------------------
// FIRST: Add any pre-defined columns that aren't in the array storage
// record structure...
// -------------------------------------------------------------------------
foreach ( $pre_defined_column_indices_by_base_slug as $this_base_slug => $this_index ) {
// ---------------------------------------------------------------------
if ( ! in_array( $this_base_slug , $array_storage_field_slugs , TRUE ) ) {
$updated_column_defs[] =
$dataset_records_table['column_defs'][
$pre_defined_column_indices_by_base_slug[ $this_base_slug ]
] ;
}
// ---------------------------------------------------------------------
}
// -------------------------------------------------------------------------
// THEN: Add in the included but NOT excluded array storage record
// fields...
// -------------------------------------------------------------------------
foreach ( $array_storage_field_slugs as $this_array_storage_field_slug ) {
// ---------------------------------------------------------------------
if ( ! in_array( $this_array_storage_field_slug , $include , TRUE ) ) {
continue ;
}
// ---------------------------------------------------------------------
if ( in_array( $this_array_storage_field_slug , $exclude , TRUE ) ) {
continue ;
}
// ---------------------------------------------------------------------
if ( array_key_exists( $this_array_storage_field_slug , $pre_defined_column_indices_by_base_slug ) ) {
// -----------------------------------------------------------------
$updated_column_defs[] =
$dataset_records_table['column_defs'][
$pre_defined_column_indices_by_base_slug[ $this_array_storage_field_slug ]
] ;
// -----------------------------------------------------------------
} else {
// -----------------------------------------------------------------
$label =
\greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_title(
$this_array_storage_field_slug
) ;
// -----------------------------------------------------------------
$updated_column_defs[] = array(
'base_slug' => $this_array_storage_field_slug ,
'label' => $label ,
'question_sortable' => TRUE ,
'raw_value_from' => array(
'method' => 'array-storage-field-slug' ,
'instance' => $this_array_storage_field_slug
)
) ;
// -----------------------------------------------------------------
}
// ---------------------------------------------------------------------
}
// =========================================================================
// Add the "ACTION" column - but only if any "record actions" are
// specified...
// =========================================================================
// -------------------------------------------------------------------------
// Here we should have (eg):-
//
// $dataset_records_table = array(
//
// ...
//
// 'record_actions' => array(
//
// array(
// 'type' => 'standard' ,
// 'slug' => 'edit' ,
// 'link_title' => 'edit'
// ) ,
//
// array(
// 'type' => 'standard' ,
// 'slug' => 'delete' ,
// 'link_title' => 'delete'
// ) ,
//
// // array(
// // 'type' => 'custom' ,
// // 'slug' => 'select-export-dirs-files' ,
// // 'link_title' => 'select/export dirs/files'
// // )
//
// ) ,
//
// ...
//
// )
//
// -------------------------------------------------------------------------
if ( array_key_exists( 'record_actions' , $dataset_records_table )
&&
is_array( $dataset_records_table['record_actions'] )
&&
count( $dataset_records_table['record_actions'] ) > 0
) {
// ---------------------------------------------------------------------
$updated_column_defs[] = array(
'base_slug' => 'action' ,
'label' => 'Action' ,
'question_sortable' => FALSE ,
'raw_value_from' => array(
'method' => 'special-type' ,
'instance' => 'record-action'
) ,
'display_treatments' => NULL
) ;
// ---------------------------------------------------------------------
}
// =========================================================================
// SUCCESS!
// =========================================================================
//\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $updated_column_defs ) ;
return $updated_column_defs ;
// =========================================================================
// That's that!
// =========================================================================
}
// =============================================================================
// That's that!
// =============================================================================