Array( // <== "dataset_slug" // [dataset_slug] => projects // [dataset_name_singular] => project // [dataset_name_plural] => projects // [dataset_title_singular] => Project // [dataset_title_plural] => Projects // [basepress_dataset_handle] => array(...) // ) // // ... // // ) // // RETURNS:- // Nothing // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Here we should have (eg):- // t // $_GET = array( // [page] => protoPress // [action] => add-record // [dataset_slug] => projects // ) // // --OR-- // // $_GET = array( // [page] => protoPress // [action] => edit-record // [dataset_slug] => projects // [record_key] => "xxx" // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $_GET , '$_GET' ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $_POST , '$_POST' ) ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $display_options = Array( // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $display_options ) ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $all_application_dataset_definitions = Array( // // [projects] => Array( // // [dataset_slug] => projects // [dataset_name_singular] => project // [dataset_name_plural] => projects // [dataset_title_singular] => Project // [dataset_title_plural] => Projects // [basepress_dataset_handle] => Array( // [nice_name] => protoPress_byFernTec_projects // [unique_key] => d2562b23-3c20-4368-92c4-2b6cd3fa722b-4d1e2f6c-bfd7-4d6d-a151-7710ac09802d-55672840-63d3-11e3-949a-0800200c9a66-627c9d30-63d3-11e3-949a-0800200c9a66 // [version] => 0.1 // ) // // [zebra_form] => Array( // // [form_specs] => Array( // [name] => add_edit_project // [method] => POST // [action] => // [attributes] => Array() // [clientside_validation] => 1 // ) // // [field_specs] => Array( // // [title] => Array( // [type] => text // [label] => Project Title // [type_specific_args] => Array( // [id] => // [default] => // [attributes] => Array() // ) // ) // // [notes_slash_comments] => Array( // [type] => textarea // [label] => Project Notes/Comments // [type_specific_args] => Array( // [id] => // [default] => // [attributes] => Array() // ) // ) // // [save_me] => Array( // [type] => submit // [label] => Submit // [type_specific_args] => Array( // [id] => // [default] => // [attributes] => Array() // ) // ) // // ) // // // 'focus_field_slug' => 'title' // // ) // // ) // // ------------------------------------------------------------------------- //pr( $all_application_dataset_definitions ) ; // ========================================================================= // Init. // ========================================================================= $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ========================================================================= // ADD or EDIT ? // ========================================================================= if ( $_GET['action'] === 'add-record' ) { $question_adding = TRUE ; $adding_editing = 'Adding' ; } else { $question_adding = FALSE ; $adding_editing = 'Editing' ; } // ========================================================================= // Get the specified dataset's DATASET MANAGER DATASET DEFINITION... // ========================================================================= $selected_datasets_dmdd = $all_application_dataset_definitions[ $dataset_slug ] ; // dmdd = Dataset Manager Dataset Definition // ========================================================================= // Get the ERROR PAGE TITLE and DATASET TITLE (for use in error messages)... // ========================================================================= if ( $question_adding ) { $error_page_title = 'Add Record' ; } else { $error_page_title = 'Edit Record' ; } // ------------------------------------------------------------------------- $dataset_manager_home_page_title = $error_page_title ; // ------------------------------------------------------------------------- if ( isset( $selected_datasets_dmdd['dataset_title_plural'] ) && is_string( $selected_datasets_dmdd['dataset_title_plural'] ) && trim( $selected_datasets_dmdd['dataset_title_plural'] ) !== '' ) { $dataset_title = $selected_datasets_dmdd['dataset_title_plural'] ; } else { $dataset_title = to_title( $dataset_slug ) ; } // ========================================================================= // Get the CORE PLUGAPP DIRS... // ========================================================================= // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_appsAPI\ // get_core_plugapp_dirs( // $path_in_plugin , // $app_handle = NULL // ) // - - - - - - - - - - - - - - - // Returns the dirspecs of the main dirs used in a given app. Ie:- // // array( // 'plugin_root_dir' => "xxx" , // 'plugins_includes_dir' => "xxx" , // 'plugins_app_defs_dir' => "xxx" , // 'dataset_manager_includes_dir' => "xxx" , // (1) // 'apps_dot_app_dir' => "xxx" , // (2) // 'apps_plugin_stuff_dir' => "xxx" // (3) // 'custom_pages_dir' => "xxx" // (4) // ) // // (1) This is where most of the "Dataset Manager" includes files // are stored. // // (2) If $app_handle === NULL, the returned 'apps_dot_app_dir' // is NULL too. // // (3) If $app_handle === NULL, the returned 'apps_plugin_stuff_dir' // is NULL too. // // (4) If $app_handle === NULL, the returned 'custom_pages_dir' // is NULL too. // // --- // // $path_in_plugin should be a file, directory or link path in the // plugin (or "app") from which this function is called. Typically, // one uses __FILE__ for this purpose. Eg:- // // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_appsAPI\get_single_app_defs_root_dir( __FILE__ ) ; // // --- // // $app_handle should be either:- // // o A single "app slug" - eg; "research-assistant" - as a // STRING. For which the returned dirspec might be (eg):- // // /home/joe/.../plugins/some-plugin/app-defs/research-assistant.app // // Or:- // // o An array of (nested) app slugs. Eg:- // // array( // 'some-app' , // 'child-app' , // 'grandchild-app' // [...] // ) // // For which the returned dirspec might be (eg):- // // /home/joe/.../plugins/some-plugin/app-defs/some-app.app/child-app.app/grandchild-app.app // // Exits with an error message if the directory can't be returned (eg; // doesn't exist). // // NOTE! // ----- // These "apps" and "datasets" (etc) are typically defined in a directory // tree structure like (eg):- // // /plugins/this-plugin/ // +-- app-defs/ // | +-- some-app.app/ // | | +-- child-app.app/ // | | +-- grandchild-app.app // | | +-- etc... // | +-- another-app.app/ // | +-- ... // +-- includes/ // +-- js/ // +-- admin/ // +-- remote/ // +-- ...etc... // +-- this-plugin.php // +-- ...etc... // // ------------------------------------------------------------------------- $path_in_plugin = __FILE__ ; // ------------------------------------------------------------------------- if ( array_key_exists( 'application' , $_GET ) && trim( $_GET['application'] ) !== '' ) { $app_handle = $_GET['application'] ; } else { $msg = <<['mysql_overrides']['load_all_records_function'] // // was specified, will call that to do the loading (which allows you to load // whatever records you want - those for the currently logged-in (WordPress) // user, for example). // // RETURNS // On SUCCESS // ARRAY $table_records // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $dataset_records = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_mysqlSupport\load_table_records( $core_plugapp_dirs , $all_application_dataset_definitions , $dataset_slug , $question_front_end ) ; // --------------------------------------------------------------------- if ( is_string( $dataset_records ) ) { return standard_dataset_manager_error( $dataset_manager_home_page_title , $dataset_records , $caller_apps_includes_dir , $question_front_end ) ; } // --------------------------------------------------------------------- } else { // ===================================================================== // FROM ARRAY STORAGE... // ===================================================================== require_once( $caller_apps_includes_dir . '/array-storage.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_arrayStorage\load_numerically_indexed( // $dataset_name , // $question_die_on_error = FALSE // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Loads and returns the specified PHP numerically indexed array. // // RETURNS // o On SUCCESS // - - - - - // ARRAY $array // A possibly empty PHP numerically indexed ARRAY. // // o On FAILURE // - - - - - // $error_message STRING // ------------------------------------------------------------------------- $question_die_on_error = TRUE ; $dataset_records = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_arrayStorage\load_numerically_indexed( $dataset_slug , $question_die_on_error ) ; // --------------------------------------------------------------------- if ( is_string( $dataset_records ) ) { return standard_dataset_manager_error( $dataset_manager_home_page_title , $dataset_records , $caller_apps_includes_dir , $question_front_end ) ; } // --------------------------------------------------------------------- } //pr( $dataset_records ) ; // ========================================================================= // GET/CHECK the dataset records KEY FIELD SLUG... // ========================================================================= // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\get_dataset_key_field_slug( // $all_application_dataset_definitions , // $dataset_slug // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Returns the dataset's (array storage) key field slug. // // RETURNS // o $array_storage_key_field_slug STRING on SUCCESS // o array( $error_message STRING ) on FAILURE // ------------------------------------------------------------------------- $key_field_slug = get_dataset_key_field_slug( $all_application_dataset_definitions , $dataset_slug ) ; // ------------------------------------------------------------------------- if ( is_array( $key_field_slug ) ) { return standard_dataset_manager_error( $error_page_title , $key_field_slug[0] , $caller_apps_includes_dir , $question_front_end ) ; } // ========================================================================= // GET the DATASET's RECORD INDICES BY KEY (if needed)... // ========================================================================= if ( $storage_mode === 'mysql' ) { // --------------------------------------------------------------------- $record_indices_by_key = array() ; // --------------------------------------------------------------------- } else { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\get_dataset_record_indices_by_key( // $dataset_title , // $dataset_records , // $key_field_slug // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS:- // o (array) $record_indices_by_key on SUCCESS // o (string) $error_message on FAILURE // ------------------------------------------------------------------------- $record_indices_by_key = get_dataset_record_indices_by_key( $dataset_title , $dataset_records , $key_field_slug ) ; // --------------------------------------------------------------------- if ( is_string( $record_indices_by_key ) ) { return standard_dataset_manager_error( $error_page_title , $record_indices_by_key , $caller_apps_includes_dir , $question_front_end ) ; } // --------------------------------------------------------------------- } // ========================================================================= // Get the "form_slug_underscored" of the form to use,,, // ========================================================================= require_once( dirname( __FILE__ ) . '/get-check-form-slug-underscored.php' ) ; // ------------------------------------------------------------------------- // get_check_form_slug_underscored( // $caller_app_slash_plugins_global_namespace , // $home_page_title , // $caller_apps_includes_dir , // $all_application_dataset_definitions , // $dataset_slug , // $question_front_end , // $display_options , // $submission_options , // $selected_datasets_dmdd , // $dataset_title // ) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // o On SUCCESS // $form_slug_underscored STRING // // o On FAILURE // ARRAY $error_message STRING ) // ------------------------------------------------------------------------- $form_slug_underscored = get_check_form_slug_underscored( $caller_app_slash_plugins_global_namespace , $home_page_title , $caller_apps_includes_dir , $all_application_dataset_definitions , $dataset_slug , $question_front_end , $display_options , $submission_options , $selected_datasets_dmdd , $dataset_title ) ; // ------------------------------------------------------------------------- if ( is_array( $form_slug_underscored ) ) { return standard_dataset_manager_error( $error_page_title , $form_slug_underscored[0] , $caller_apps_includes_dir , $question_front_end ) ; } // ========================================================================= // Check/Default the Zebra Form Definition... // ========================================================================= require_once( dirname( __FILE__ ) . '/check-and-default-zebra-form-definition.php' ) ; // ------------------------------------------------------------------------- // check_and_default_zebra_form_definition( // $caller_app_slash_plugins_global_namespace , // $home_page_title , // $caller_apps_includes_dir , // &$all_application_dataset_definitions , // $dataset_slug , // &$selected_datasets_dmdd , // $dataset_title , // $dataset_records , // $record_indices_by_key , // $question_adding , // $form_slug_underscored // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - // Checks:- // $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] // // defaulting it and it's members as necessary. // // RETURNS:- // On SUCCESS! // - - - - - - // TRUE // And the caller's:- // $all_application_dataset_definitions, and; // $selected_datasets_dmdd // have been updated as follows:- // o ...['zebra_forms'][ $form_slug_underscored ]['checked_defaulted_ok'] = TRUE // o With the remaining "zebra_form" elements defaulted as // required // // On FAILURE! // - - - - - - // $error_message STRING // ------------------------------------------------------------------------- $result = check_and_default_zebra_form_definition( $caller_app_slash_plugins_global_namespace , $home_page_title , $caller_apps_includes_dir , $all_application_dataset_definitions , $dataset_slug , $selected_datasets_dmdd , $dataset_title , $dataset_records , $record_indices_by_key , $question_adding , $form_slug_underscored ) ; // ------------------------------------------------------------------------- if ( is_string( $result ) ) { return standard_dataset_manager_error( $error_page_title , $result , $caller_apps_includes_dir , $question_front_end ) ; } // ========================================================================= // BASE64 ENCODING ? // ========================================================================= // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\ // get_pre_check_base64_encoded_array_storage_field_indices_by_slug( // $selected_datasets_dmdd // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // On SUCCESS! // ARRAY $pre_check_base64_encoded_array_storage_field_indices_by_slug // // On FAILURE // $error_message string // ------------------------------------------------------------------------- $pre_check_base64_encoded_array_storage_field_indices_by_slug = get_pre_check_base64_encoded_array_storage_field_indices_by_slug( $selected_datasets_dmdd ) ; // ------------------------------------------------------------------------- if ( is_string( $pre_check_base64_encoded_array_storage_field_indices_by_slug ) ) { return standard_dataset_manager_error( $error_page_title , $pre_check_base64_encoded_array_storage_field_indices_by_slug , $caller_apps_includes_dir , $question_front_end ) ; } // ========================================================================= // LOAD ZEBRA FORMs... // ========================================================================= require_once( $caller_apps_includes_dir . '/Zebra_Form-master/Zebra_Form.php' ) ; // ========================================================================= // CREATE the ZEBRA FORM object instance... // ========================================================================= require_once( dirname( __FILE__ ) . '/add-edit-record_create-zebra-form.php' ) ; // ------------------------------------------------------------------------- // create_zebra_form_object_instance( // $home_page_title , // $caller_apps_includes_dir , // $all_application_dataset_definitions , // $dataset_slug , // $question_front_end , // $display_options = array() , // $submission_options = array() , // $selected_datasets_dmdd , // $dataset_title , // $dataset_records , // $record_indices_by_key , // $question_adding , // $adding_editing , // $form_slug_underscored , // $key_field_slug , // $pre_check_base64_encoded_array_storage_field_indices_by_slug // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // o On SUCCESS! // array( // $zebra_form_obj (= reference to Zebra Form object instance) // $selected_datasets_dmdd_updated // ) // // o On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $result = create_zebra_form_object_instance( $home_page_title , $caller_apps_includes_dir , $all_application_dataset_definitions , $dataset_slug , $question_front_end , $display_options , $submission_options , $selected_datasets_dmdd , $dataset_title , $dataset_records , $record_indices_by_key , $question_adding , $adding_editing , $form_slug_underscored , $key_field_slug , $pre_check_base64_encoded_array_storage_field_indices_by_slug ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $result ) ; // ------------------------------------------------------------------------- if ( is_string( $result ) ) { return standard_dataset_manager_error( $error_page_title , $result , $caller_apps_includes_dir , $question_front_end ) ; } // ------------------------------------------------------------------------- list( $zebra_form_obj , $selected_datasets_dmdd ) = $result ; // ========================================================================= // WordPress Magic Quotes... // ========================================================================= require_once( $caller_apps_includes_dir . '/wordpress-magic-quotes.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_wordpressMagicQuotes\ // question_magic_quotes_gpc() // - - - - - - - - - - - - - - // RETURNS // o TRUE if $_GET, $_POST and $_COOKIE values have had // "addslashes()" done to them (and thus, need to be run // through "stripslashes()" before use). // o FALSE otherwise. // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_wordpressMagicQuotes\ // question_magic_quotes_server() // - - - - - - - - - - - - - - - // RETURNS // o TRUE if $_SERVER values have had "addslashes()" done to them // (and thus, need to be run through "stripslashes()" before use). // o FALSE otherwise. // ------------------------------------------------------------------------- // ========================================================================= // Base64 encode the specified fields ("pre-check")... // ========================================================================= $post_values_base64_encoded_pre_check_by_post_slug = array() ; // ------------------------------------------------------------------------- if ( count( $_POST ) > 0 ) { // --------------------------------------------------------------------- //pr( $_POST ) ; // --------------------------------------------------------------------- $array_storage_field_indices_to_base64_encode_pre_check = array_values( $pre_check_base64_encoded_array_storage_field_indices_by_slug ) ; // --------------------------------------------------------------------- foreach ( $array_storage_field_indices_to_base64_encode_pre_check as $field_index ) { // ----------------------------------------------------------------- $field_data = $selected_datasets_dmdd['array_storage_record_structure'][ $field_index ] ; // ----------------------------------------------------------------- $question_field_base64_encoded = FALSE ; // ----------------------------------------------------------------- if ( array_key_exists( 'array_storage_value_from' , $field_data ) && is_array( $field_data['array_storage_value_from'] ) ) { // ------------------------------------------------------------- foreach ( $field_data['array_storage_value_from'] as $add_edit => $value_from_details ) { // --------------------------------------------------------- if ( array_key_exists( 'method' , $value_from_details ) && array_key_exists( 'instance' , $value_from_details ) && $value_from_details['method'] === 'post' && is_string( $value_from_details['instance'] ) && $value_from_details['instance'] !== '' && array_key_exists( $value_from_details['instance'] , $_POST ) ) { if ( \greatKiwi_byFernTec_adSwapper_local_v0x1x211_wordpressMagicQuotes\question_magic_quotes_gpc() ) { $_POST[ $value_from_details['instance'] ] = \stripslashes( $_POST[ $value_from_details['instance'] ] ) ; } $post_values_base64_encoded_pre_check_by_post_slug[ $value_from_details['instance'] ] = $_POST[ $value_from_details['instance'] ] ; $_POST[ $value_from_details['instance'] ] = base64_encode( $_POST[ $value_from_details['instance'] ] ) ; $question_field_base64_encoded = TRUE ; break ; } // --------------------------------------------------------- } } // ----------------------------------------------------------------- if ( $question_field_base64_encoded ) { continue ; } // ----------------------------------------------------------------- $field_number = $field_index + 1 ; $safe_field_slug = htmlentities( $field_data['slug'] ) ; $msg = << 0 ) { // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // "ZEBRA FORM" SUBMISSION HANDLING // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: $old_POST = $_POST ; // $zebra_form_obj->validate() filters/sanitisers $_POST. Which // then stuffs out the custom/standard submission handling that // follows. // // Hence the need to save/restore $_POST. // --------------------------------------------------------------------- $zebra_form_happy = $zebra_form_obj->validate() ; // --------------------------------------------------------------------- $_POST = $old_POST ; // --------------------------------------------------------------------- if ( $zebra_form_happy === TRUE ) { // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // "STANDARD DATASET MANAGER" SUBMISSION HANDLING // ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // ================================================================= // STANDARD or CUSTOM SUBMISSION HANDLER ? // ================================================================= // ----------------------------------------------------------------- // Here we should have (eg):- // // $submission_options = array( // 'custom_submission_handler_function_name' => $custom_submission_handler_function_name // ) // // ----------------------------------------------------------------- if ( is_array( $submission_options ) && array_key_exists( 'custom_submission_handler_function_name' , $submission_options ) && is_string( $submission_options['custom_submission_handler_function_name'] ) ) { // ============================================================= // CUSTOM SUBMISSION HANDLER // ============================================================= if ( trim( $submission_options['custom_submission_handler_function_name'] ) === '' || strlen( $submission_options['custom_submission_handler_function_name'] ) > 512 ) { $msg = <<add('text', 'my_text'); // // // make the text field required // $obj->set_rule( // 'required' => array( // 'error', // variable to add the error message to // 'Field is required' // error message if value doesn't validate // ) // ) ; // // // don't forget to always call this method before rendering the form // if ($form->validate()) { // // // for the purpose of this example, we will do a custom // // validation after calling the "validate" method. for custom // // validations, using the "custom" rule is recommended instead // // // check if value's is between 1 and 10 // if ( $_POST['my_text'] < 1 // || // $_POST['my_text'] > 10 // ) { // $form->add_error( 'error' , // 'Value must be an integer between 1 and 10!' // ) ; // // } else { // // // put code here that is to be executed when the form values are ok // // } // // } // // // output the form using an automatically generated template // $form->render(); // // PARAMETERS // // string $error_block The name of the error block to append the // error message to (also the name of the PHP // variable that will be available in the // template file). // // string $error_message The error message to append to the error // block. // ------------------------------------------------------------------------- $zebra_form_obj->add_error( 'error' , substr( $error_message , strlen( '--ZEBRA--' ) ) ) ; // --------------------------------------------------------- $question_redisplay_form = TRUE ; // --------------------------------------------------------- } else { // --------------------------------------------------------- return standard_dataset_manager_error( $error_page_title , $error_message , $caller_apps_includes_dir , $question_front_end ) ; // --------------------------------------------------------- } // ------------------------------------------------------------- } // ----------------------------------------------------------------- } else { // ----------------------------------------------------------------- $question_redisplay_form = TRUE ; // Because Zebra Form wasn't happy (with the submission) // ----------------------------------------------------------------- } // ===================================================================== // RETURN TO WHERE-EVER (if requested/required)... // ===================================================================== if ( $question_redisplay_form !== TRUE ) { // ================================================================= // Does $SUBMISSION_OPTIONS have any instructions as to where we // should return to ? // ================================================================= // ----------------------------------------------------------------- // Here we should have (eg):- // // $submission_options = array( // 'return_to' => array( // 'function_name' => $get_return_to_url_function_name // ) // ) // ) // // ----------------------------------------------------------------- if ( is_array( $submission_options ) && array_key_exists( 'return_to' , $submission_options ) ) { // ============================================================= // $SUBMISSION_OPTIONS['RETURN_TO']... // ============================================================= if ( ! is_array( $submission_options['return_to'] ) ) { $msg = << 512 ) { $msg = << window.parent.location.href = '{$url}' ; EOT; // ----------------------------------------------------------------- } // ===================================================================== // Fall through to RE-DISPLAY THE FORM... // ===================================================================== } // ========================================================================= // If the form is being re-displayed after a submission handler error - // then reset any $_POST values that were base64 encoded before the // submission handler was run... // ========================================================================= if ( isset( $question_redisplay_form ) && $question_redisplay_form === TRUE && count( $post_values_base64_encoded_pre_check_by_post_slug ) > 0 ) { // --------------------------------------------------------------------- foreach ( $post_values_base64_encoded_pre_check_by_post_slug as $post_slug => $original_post_value ) { $_POST[ $post_slug ] = $original_post_value ; } // --------------------------------------------------------------------- } // ========================================================================= // RENDER the form... // ========================================================================= // ------------------------------------------------------------------------- // mixed render ( [ string $template = ''] , [ boolean $return = false] , [ array $variables = ''] ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Returns or displays the rendered form. // // PARAMETERS // // string $template // The output of the form can be generated automatically, can be // given from a template file or can be generated programmatically // by a callback function. // // For the automatically generated template there are two options: // // o when $template is an empty string or is "*vertical", the // script will automatically generate an output where the // labels are above the controls and controls come one // under another (vertical view) // // o when $template is "*horizontal", the script will // automatically generate an output where the labels are // positioned to the left of the controls while the // controls come one under another (horizontal view) // // When templates are user-defined, $template needs to be a string // representing the path/to/the/template.php. // // The template file itself must be a plain PHP file where all the // controls added to the form (except for the hidden controls, // which are handled automatically) will be available as variables // with the names as described in the documentation for each of the // controls. Also, error messages will be available as described at // set_rule(). // // A special variable will also be available in the template file - // a variable with the name of the form and being an associative // array containing all the controls added to the form, as objects. // // The template file must not contain the
and
tags, // nor any of the controls added to the form as these are // generated automatically! // // There is a third method of generating the output and that is // programmatically, through a callback function. In this case // $template needs to be the name of an existing function. // // The function will be called with two arguments: // // o an associative array with the form's controls' ids and their // respective generated HTML, ready for echo-ing (except for // the hidden controls which will still be handled // automatically); // // note that this array will also contain variables assigned // through the assign() method as well as any server-side error // messages, as you would in a custom template (see set_rule() // method and read until the second highlighted box, inclusive) // // o an associative array with all the controls added to the // form, as objects // // THE USER FUNCTION MUST RETURN THE GENERATED OUTPUT! // // boolean $return // (Optional) If set to TRUE, the output will be returned instead // of being printed to the screen. // // Default is FALSE. // // array $variables // (Optional) An associative array in the form of "variable_name" // => "value" representing variable names and their associated // values, to be made available in custom template files. // // This represents a quicker alternative for assigning many // variables at once instead of calling the assign() method for // each variable. // ------------------------------------------------------------------------- $template = '' ; $return = TRUE ; $variables = array() ; // ------------------------------------------------------------------------- $add_edit_form = $zebra_form_obj->render( $template , $return , $variables ) ; // ------------------------------------------------------------------------- // For WordPress Admin section, restrict the form width to 98%... // ------------------------------------------------------------------------- // $add_edit_form = <<{$add_edit_form} //EOT; // Now we restrict the IFRAME to 98% // ------------------------------------------------------------------------- // Add any "inline_scripts_or_other_html"... // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $selected_datasets_dmdd ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $selected_datasets_dmdd['zebra_form'] ) ; if ( array_key_exists( 'inline_scripts_or_other_html' , $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] ) && is_string( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['inline_scripts_or_other_html'] ) && trim( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['inline_scripts_or_other_html'] ) !== '' ) { $add_edit_form .= "\n" . trim( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['inline_scripts_or_other_html'] ) ; } // ------------------------------------------------------------------------- // Add ONFOCUS / ONBLUR HANDLERS (to highlight the currently selected // field's background)... // ------------------------------------------------------------------------- // el.parentNode.style.backgroundColor = '#E4F9EB' ; // Light Green // el.parentNode.style.backgroundColor = '#F9E4F2' ; // Light Pink // el.parentNode.style.backgroundColor = '#F9EBE4' ; // Light Orange // el.parentNode.style.backgroundColor = '#C8F3EB' ; // Light Cyan $add_edit_form .= "\n" . << function greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_onfocus(el) { // el.parentNode.greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_oldBg = el.parentNode.style.backgroundColor ; // el.parentNode.style.backgroundColor = '#D6F6F0' ; // Light Cyan var ancestor ; if ( el.type === 'radio' ) { ancestor = el.parentNode.parentNode ; } else { ancestor = el.parentNode ; } ancestor.greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_oldBg = ancestor.style.backgroundColor ; ancestor.style.backgroundColor = '#D6F6F0' ; // Light Cyan } function greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_onblur(el) { if ( typeof el.parentNode.greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_oldBg !== undefined ) { // el.parentNode.style.backgroundColor = el.parentNode.greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_oldBg ; // delete el.parentNode.greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_oldBg ; var ancestor ; if ( el.type === 'radio' ) { ancestor = el.parentNode.parentNode ; } else { ancestor = el.parentNode ; } ancestor.style.backgroundColor = ancestor.greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_oldBg ; delete ancestor.greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_oldBg ; } } EOT; // ------------------------------------------------------------------------- // Focus the field to start editing with. If NO focus field was specified, // focus the first field... // ------------------------------------------------------------------------- $no_error_focus_field_slug = '' ; // ------------------------------------------------------------------------- if ( ( isset( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['focus_field_slug'] ) || $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['focus_field_slug'] === NULL ) && $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['focus_field_slug'] !== FALSE ) { // --------------------------------------------------------------------- $form_field_names = array() ; foreach( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_specs'] as $this_field_spec ) { $form_field_names[] = $this_field_spec['form_field_name'] ; } // --------------------------------------------------------------------- if ( count( $form_field_names ) > 0 ) { // ----------------------------------------------------------------- if ( is_string( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['focus_field_slug'] ) && in_array( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['focus_field_slug'] , $form_field_names , TRUE ) ) { $no_error_focus_field_slug = $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['focus_field_slug'] ; } else { $no_error_focus_field_slug = $form_field_names[0] ; } // ----------------------------------------------------------------- } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- // if ( $no_error_focus_field_slug !== '' // && // isset( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_specs'][ $no_error_focus_field_slug ]['type_specific_args']['id'] ) // && // is_string( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_specs'][ $no_error_focus_field_slug ]['type_specific_args']['id'] ) // && // ctype_graph( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_specs'][ $no_error_focus_field_slug ]['type_specific_args']['id'] ) // ) { // $no_error_focus_field_id = $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_specs'][ $no_error_focus_field_slug ]['type_specific_args']['id'] ; // // } else { // $no_error_focus_field_id = '' ; // // } // ------------------------------------------------------------------------- if ( isset( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_specs']['name'] ) && is_string( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_specs']['name'] ) && trim( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_specs']['name'] ) !== '' ) { $form_name = $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_specs']['name'] ; } else { $form_name = '' ; } // ------------------------------------------------------------------------- if ( isset( $error_field_slug ) && is_string( $error_field_slug ) && trim( $error_field_slug ) !== '' ) { if ( $form_name !== '' ) { $jQuery_selector_for_field_that_caused_error = << 0 ) { error_inputs.addClass( 'error' ) ; } EOT; } else { $set_class_for_field_that_caused_error = '' ; } // ------------------------------------------------------------------------- if ( $form_name !== '' ) { $jQuery_selector_get_all_class_equals_error_inputs = << function greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_focus() { var error_inputs ; {$set_class_for_field_that_caused_error} error_inputs = jQuery( '{$jQuery_selector_get_all_class_equals_error_inputs}' ) ; if ( typeof error_inputs === 'object' && error_inputs.length > 0 ) { error_inputs[0].focus() ; } else { if ( '{$no_error_focus_field_slug}' !== '' ) { document.getElementById( '{$no_error_focus_field_slug}' ).focus() ; } } } greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditRecord_zebraForm_focus() ; EOT; // ========================================================================= // If there are any "radio" buttons to be listed vertically, add the // necessary Javascript to the form... // ========================================================================= // ------------------------------------------------------------------------- // NOTE! // ----- // By default, Zebra Form listed a bunch of "radios" ACROSS the page. // // We list them DOWN the page by using Javascript to insert a "
" tag // in front of all but the first "radio" button. // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // NOTE! // ----- // Here we should have (eg):- // // $selected_datasets_dmdd['zebra_form'] = array( // // 'form_specs' => array( // 'name' => 'add_edit_teaser_settings' , // 'method' => 'POST' , // 'action' => '' , // 'attributes' => array() , // 'clientside_validation' => TRUE // ) , // // 'field_specs' => array( // // ... // // array( // 'form_field_name' => 'selected_layout_slug' , // 'zebra_control_type' => 'radios' , // 'label' => 'Layout/Style/Scripts' , // 'help_text' => 'xxx' , // 'attributes' => array( // 'style' => 'margin-left:1.5em' // ) , // 'rules' => array() , // 'type_specific_args' => array( // 'radios' => array( // 'p-and-h-tags-down-the-page' => 'P and H Tags - Down the Page (default)' , // 'p-and-h-tags-floating' => 'P and H Tags - Floating' , // 'div-and-span-tags-down-the-page' => 'DIV and SPAN Tags - Down the Page' , // 'div-and-span-tags-floating' => 'DIV and SPAN Tags - Floating' , // 'custom' => 'Custom (see below)' // ) , // 'question_vertical' => TRUE // ) // ) // // ... // // ) // // ) // // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // NOTE! // ----- // Here we should have (eg):- // //
// // // //
// // // //
//
// Select the HTML (layouts), CSS (styles) and Javascript (scripts) // you want the teasers displayed with.  This can be one of // the four built-in Layouts/Styles/Scripts.  Or some custom // HTML, CSS and Javascript you've created yourself. //
//
// //
// //
//
// //
//
// //
// //
//
// //
//
// // ... // //
// // ... // //
// // ------------------------------------------------------------------------- $vertical_radio_field_names = array() ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] // ) ; foreach ( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_specs'] as $zebra_field_index => $zebra_field_data ) { if ( $zebra_field_data['zebra_control_type'] === 'radios' && array_key_exists( 'type_specific_args' , $zebra_field_data ) && array_key_exists( 'question_vertical' , $zebra_field_data['type_specific_args'] ) && $zebra_field_data['type_specific_args']['question_vertical'] === TRUE ) { $vertical_radio_field_names[] = $zebra_field_data['form_field_name'] ; } } // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $vertical_radio_field_names ) ; if ( count( $vertical_radio_field_names ) > 0 ) { // --------------------------------------------------------------------- $commands = '' ; // --------------------------------------------------------------------- foreach ( $vertical_radio_field_names as $radio_name ) { $commands .= << function adSwapper_local_v0x1x211_make_zebra_radios_vertical( radio_name ) { return ; //alert(radio_name); var the_radios = jQuery( 'form#{$form_name} input[type="radio"][name="' + radio_name + '"]' ) ; var i , j = the_radios.length ; //alert( j ) ; for ( i=1 ; i EOT; // --------------------------------------------------------------------- } // ========================================================================= // Add in any "form fixup javascript"... // // NOTE! // ----- // The form fixup javascript specified is assumed to be NOT enclosed // in SCRIPT tags. // ========================================================================= //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] // ) ; if ( array_key_exists( 'form_fixup_javascript' , $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] ) && is_string( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_fixup_javascript'] ) && trim( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_fixup_javascript'] ) !== '' ) { $add_edit_form .= << {$selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_fixup_javascript']} EOT; //echo htmlentities( $add_edit_form ) ; } // ========================================================================= // Add in the FIELD GROUPS stuff (if the form has any)... // ========================================================================= //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( // $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] // ) ; if ( array_key_exists( 'field_groups' , $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] ) ) { // --------------------------------------------------------------------- $form_field_groups = $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['field_groups'] ; // --------------------------------------------------------------------- } elseif ( array_key_exists( 'get_field_groups_function_name' , $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] ) && is_string( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['get_field_groups_function_name'] ) && trim( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['get_field_groups_function_name'] ) !== '' && function_exists( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['get_field_groups_function_name'] ) ) { // ------------------------------------------------------------------------- // ( // $core_plugapp_dirs , // $all_application_dataset_definitions , // $dataset_slug , // $question_front_end , // $display_options , // $submission_options , // $selected_datasets_dmdd , // $dataset_title , // $dataset_records , // $record_indices_by_key , // $key_field_slug , // $question_adding , // $zebra_form_obj // ) // - - - - - - - - - - - - - - - - - - - - - - - // RETURNS // On SUCCESS // $field_groups = array( // array( // 'form_field_name' => 'xxx' // 'html_before' => 'yyy' // 'html_after' => 'zzz' // ) // ... // ) // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $form_field_groups = $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['get_field_groups_function_name']( $core_plugapp_dirs , $all_application_dataset_definitions , $dataset_slug , $question_front_end , $display_options , $submission_options , $selected_datasets_dmdd , $dataset_title , $dataset_records , $record_indices_by_key , $key_field_slug , $question_adding , $zebra_form_obj ) ; // --------------------------------------------------------------------- if ( is_string( $form_field_groups ) ) { return standard_dataset_manager_error( $home_page_title , $form_field_groups , $caller_apps_includes_dir , $question_front_end ) ; } // --------------------------------------------------------------------- } else { // --------------------------------------------------------------------- $form_field_groups = NULL ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( is_array( $form_field_groups ) && count( $form_field_groups ) > 0 ) { // --------------------------------------------------------------------- require_once( dirname( __FILE__ ) . '/zebra-form-field-group-support.php' ) ; // --------------------------------------------------------------------- $result = get_zebra_form_field_group_support( $form_field_groups ) ; // --------------------------------------------------------------------- if ( is_array( $result ) ) { return standard_dataset_manager_error( $home_page_title , $result[0] , $caller_apps_includes_dir , $question_front_end ) ; } // --------------------------------------------------------------------- $add_edit_form .= $result ; // --------------------------------------------------------------------- } // ========================================================================= // Get the URL of the DIR that Zebra Form is in... // ========================================================================= require_once( $caller_apps_includes_dir . '/path-utils.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_pathUtils\wp_path2url( // $path // ) // - - - - - - - - - - - - - - - - - // RETURNS:- // o $url on SUCCESS // o array( $error_message ) on FAILURE // ------------------------------------------------------------------------- $zebra_form_master_dir_path = $caller_apps_includes_dir . '/Zebra_Form-master' ; // ------------------------------------------------------------------------- $zebra_form_master_dir_url = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_pathUtils\wp_path2url( $zebra_form_master_dir_path ) ; // ------------------------------------------------------------------------- if ( is_array( $zebra_form_master_dir_url ) ) { return standard_dataset_manager_error( $home_page_title , $zebra_form_master_dir_url[0] , $caller_apps_includes_dir , $question_front_end ) ; } // ========================================================================= /* if ( isset( $question_redisplay_form ) && $question_redisplay_form === TRUE ) { $leave_iframe = << // window.parent.document = document ; window.parent.window.parent.document.getElementById( 'greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditForm_iframe' ).style.visibility = 'visible' ; EOT; } else { $leave_iframe = '' ; } */ // ========================================================================= // Create the HTML for the page to go in the IFRAME... // ========================================================================= // ------------------------------------------------------------------------- // NOTE! // ===== // We display the form proper in an IFRAME. To stop the WordPress and // theme CSS and Javascript from interfering with the Zebra Form CSS // and Javascript. // ------------------------------------------------------------------------- $includes_url = rtrim( includes_url() , '/' ) ; //pr( $includes_url ) ; // ------------------------------------------------------------------------- $iframe_page_html = << Manage "{$dataset_title}" Table {$add_edit_form} EOT; // ========================================================================= // SAVE the page in the BASEPRESS PAGE CACHE... // ========================================================================= require_once( $caller_apps_includes_dir . '/wordpress-page-cache.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_wordpressPageCache\set_page( // $page_name , // $question_session_specific , // $question_remote_ip_specific , // $question_user_agent_specific , // $question_page_key , // $page_content // ) // - - - - - - - - - - - - - - - - - - - // SAVES the specified PHP/HTML (or whatever) "page_content" into the // page cache. // // NOTES! // ====== // 1. Cached pages are stored in the wordPress MySQL database. This is to // eliminate the file access/permission problems that would occur if we // to store the cached pages as files on the disk. // // 2. This routine auto-creates the page cache table, if that table // doesn't yet exist. // // RETURNS // On SUCCESS! // - - - - - - // $page_key STRING (= blank string if $question_page_key = FALSE) // // On FAILURE! // - - - - - - // array( $error_message STRING ) // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // /apps-api.php // - - - - - - - - - - - - - - - // Defines:- // // get_plugin_root_dir_basename_raw() // // get_plugin_slug_dashed() // get_plugin_slug_underscored() // get_plugin_title() // get_plugin_camel_name() // get_plugin_version_raw() // get_plugin_version_alnum() // // get_plugin_root_dir() // convert_root_relative_plugin_pathspec_2_absolute() // get_plugins_app_defs_dir() // get_plugins_includes_dir() // get_single_apps_dot_app_dir() // get_core_plugapp_dirs() // // All in the:- // greatKiwi_byFernTec_adSwapper_local_v0x1x211_appsAPI // namespace. // // And where:- // get_core_plugapp_dirs() // // returns:- // array( // 'plugin_root_dir' => "xxx" , // 'plugins_includes_dir' => "xxx" , // 'plugins_app_defs_dir' => "xxx" , // 'dataset_manager_includes_dir' => "xxx" , // 'apps_dot_app_dir' => "xxx" , // 'apps_plugin_stuff_dir' => "xxx" // ) // ------------------------------------------------------------------------- // $fn = <<Raw Mode is {$raw_mode_is}; Turn it {$turn_raw_mode} EOT; // --------------------------------------------------------------------- } else { $raw_mode_button = '' ; } // ========================================================================= // DISPLAY the PAGE... // ========================================================================= // ------------------------------------------------------------------------- // Here we should have (eg):- // // $display_options = Array( // [question_show_email] => TRUE | FALSE // [question_show_page_header] => TRUE | FALSE // [question_show_table_header] => TRUE | FALSE // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $display_options ) ; $question_show_page_header = TRUE ; $question_show_table_header = TRUE ; // ------------------------------------------------------------------------- if ( is_array( $display_options ) ) { // --------------------------------------------------------------------- if ( array_key_exists( 'question_show_page_header' , $display_options ) && is_bool( $display_options['question_show_page_header'] ) ) { $question_show_page_header = $display_options['question_show_page_header'] ; } // --------------------------------------------------------------------- if ( array_key_exists( 'question_show_table_header' , $display_options ) && is_bool( $display_options['question_show_table_header'] ) ) { $question_show_table_header = $display_options['question_show_table_header'] ; } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( $question_show_page_header ) { if ( isset( $_GET['view_title'] ) && trim( $_GET['view_title'] ) !== '' && strip_tags( $_GET['view_title'] ) === $_GET['view_title'] ) { $page_title = htmlentities( $_GET['view_title'] ) ; } else { $page_title = 'Manage ' . $selected_datasets_dmdd['dataset_title_plural'] ; } } else { $page_title = '' ; } // ------------------------------------------------------------------------- if ( $question_show_table_header ) { // --------------------------------------------------------------------- if ( isset( $_GET['return_to'] ) && trim( $_GET['return_to'] ) !== '' && \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\ctype_alphanumeric_underscore_dash( $_GET['return_to'] ) && isset( $_GET['view_slug'] ) && trim( $_GET['view_slug'] ) !== '' && \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\ctype_alphanumeric_underscore_dash( $_GET['view_slug'] ) ) { // ----------------------------------------------------------------- require_once( dirname( __FILE__ ) . '/get-view-urls.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\get_show_view_url( // $caller_apps_includes_dir , // $question_front_end , // $view_slug = NULL // ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - // Returns the "show-view" URL. // // If $view_slug is NULL, then we use:- // $_GET['view_slug'] // // RETURNS // o On SUCCESS! // - - - - - - // STRING $url // // o On FAILURE! // - - - - - - // ARRAY( $error_message STRING ) // ------------------------------------------------------------------------- $page_title_href = get_show_view_url( $caller_apps_includes_dir , $question_front_end , $_GET['view_slug'] ) ; // ----------------------------------------------------------------- } else { // ----------------------------------------------------------------- require_once( dirname( __FILE__ ) . '/get-dataset-urls.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\get_manage_dataset_url( // $caller_apps_includes_dir , // $question_front_end , // $dataset_slug = NULL // ) // - - - - - - - - - - - - - - - - - // Returns the "manage-dataset" URL. // // If $dataset_slug is NULL, then we use:- // $_GET['dataset_slug'] // // RETURNS // o On SUCCESS! // - - - - - - // STRING $url // // o On FAILURE! // - - - - - - // ARRAY( $error_message STRING ) // ------------------------------------------------------------------------- $page_title_href = get_manage_dataset_url( $caller_apps_includes_dir , $question_front_end , NULL ) ; // ----------------------------------------------------------------- } // --------------------------------------------------------------------- if ( is_array( $page_title_href ) ) { return standard_dataset_manager_error( $home_page_title , $page_title_href[0] , $caller_apps_includes_dir , $question_front_end ) ; } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( $question_show_table_header ) { // --------------------------------------------------------------------- $sub_page_title = '' ; // --------------------------------------------------------------------- if ( $question_adding ) { $field_name = 'custom_form_title_add' ; } else { $field_name = 'custom_form_title_edit' ; } // --------------------------------------------------------------------- if ( array_key_exists( $field_name , $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_specs'] ) && is_string( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_specs'][ $field_name ] ) && trim( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_specs'][ $field_name ] ) !== '' ) { $sub_page_title = trim( $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ]['form_specs'][ $field_name ] ) ; } else { if ( $question_adding ) { $sub_page_title = 'Add ' . $selected_datasets_dmdd['dataset_title_singular'] ; } else { $sub_page_title = 'Edit ' . $selected_datasets_dmdd['dataset_title_singular'] ; } } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- $buttons_right = $raw_mode_button ; // ------------------------------------------------------------------------- if ( $question_show_page_header && $question_show_table_header ) { echo get_sub_page_header( $page_title , $page_title_href , $sub_page_title , $caller_apps_includes_dir , $question_front_end , $buttons_right ) ; } elseif ( $question_show_page_header ) { echo get_sub_page_header( $page_title , $page_title_href , $sub_page_title , $caller_apps_includes_dir , $question_front_end , $buttons_right ) ; } // ========================================================================= // Display any dataset-specific add/edit record page header... // ========================================================================= $zebra_form_def = $selected_datasets_dmdd['zebra_forms'][ $form_slug_underscored ] ; // ------------------------------------------------------------------------- if ( array_key_exists( 'custom_add_edit_record_page_header_fn' , $zebra_form_def ) && is_string( $zebra_form_def['custom_add_edit_record_page_header_fn'] ) && trim( $zebra_form_def['custom_add_edit_record_page_header_fn'] ) !== '' ) { // --------------------------------------------------------------------- if ( ! function_exists( $zebra_form_def['custom_add_edit_record_page_header_fn'] ) ) { $msg = <<( // $core_plugapp_dirs , // $all_application_dataset_definitions , // $selected_datasets_dmdd , // $dataset_slug , // $dataset_title , // $dataset_records , // $key_field_slug , // $record_indices_by_key , // $question_front_end , // $question_adding , // $form_slug_underscored , // $zebra_form_def // ) // - - - - - - - - - - - - - - - - - - - - - - - // Returns the HTML for a custom header to go at the top of the // add/edit record page. // // RETURNS // On SUCCESS // $header_html STRING // // On FAILURE // array( $error_message STRING ) // ------------------------------------------------------------------------- $custom_header = $zebra_form_def['custom_add_edit_record_page_header_fn']( $core_plugapp_dirs , $all_application_dataset_definitions , $selected_datasets_dmdd , $dataset_slug , $dataset_title , $dataset_records , $key_field_slug , $record_indices_by_key , $question_front_end , $question_adding , $form_slug_underscored , $zebra_form_def ) ; // --------------------------------------------------------------------- if ( is_array( $custom_header ) ) { return standard_dataset_manager_error( $home_page_title , $custom_header[0] , $caller_apps_includes_dir , $question_front_end ) ; } // --------------------------------------------------------------------- echo $custom_header ; // --------------------------------------------------------------------- } // ========================================================================= // PRE-DISPLAY FUNCTION ? // ========================================================================= // ------------------------------------------------------------------------- // Here we should have (eg):- // // $selected_datasets_dmdd = array( // ... // 'pre_display_function' => '\\' . __NAMESPACE__ . '\\some_function_name' , // 'pre_display_function_args' => // ... // ) // // ------------------------------------------------------------------------- if ( array_key_exists( 'pre_display_function' , $selected_datasets_dmdd ) && is_string( $selected_datasets_dmdd['pre_display_function'] ) && trim( $selected_datasets_dmdd['pre_display_function'] ) !== '' ) { // --------------------------------------------------------------------- if ( ! function_exists( $selected_datasets_dmdd['pre_display_function'] ) ) { $ln = __LINE__ - 2 ; $msg = <<( // $core_plugapp_dirs , // $all_application_dataset_definitions , // $display_options , // $submission_options , // $storage_mode , // $selected_datasets_dmdd , // $dataset_slug , // $dataset_title , // $dataset_records , // $key_field_slug , // $record_indices_by_key , // $question_front_end , // $question_adding , // $iframe_page_html , // $pre_display_function_args // ) // - - - - - - - - - - - - - - - - - - - - - - - // The "pre display" function is run once the form - for the record to // be added or edited - has been created. And just before it's displayed // to the screen. // // The idea is to run this function only if we're as certain as possible // that the user will see the add/edit form - and be able to submit it. // // Essentially; the "pre display" function's purpose is to let you run // some dataset specific PHP code - when you're as certain as possible // that the form will actually be displayed (for the user to view, edit // and submit). // // --- // // The "pre display" function can't modify the displayed form in any way. // apart from via any Javascript it returns. // // Also; the returned Javascript is added to the PARENT page - in which // the IFRAME that contains the add/edit form proper is embedded. So // the Javascript must take that into account if it wants to adjust any // content IN the IFRAME. The IFRAME has the ID:- // "greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditForm_iframe" // // The returned Javascript MUST include enclosing SCRIPT tags. // // RETURNS // On SUCCESS // $pre_display_function_returned_js STRING // (May be the empty string) // // On FAILURE // array( $error_message STRING ) // ------------------------------------------------------------------------- $pre_display_function_returned_js = $selected_datasets_dmdd['pre_display_function']( $core_plugapp_dirs , $all_application_dataset_definitions , $display_options , $submission_options , $storage_mode , $selected_datasets_dmdd , $dataset_slug , $dataset_title , $dataset_records , $key_field_slug , $record_indices_by_key , $question_front_end , $question_adding , $iframe_page_html , $pre_display_function_args ) ; // --------------------------------------------------------------------- if ( is_array( $pre_display_function_returned_js ) ) { return standard_dataset_manager_error( $home_page_title , $pre_display_function_returned_js[0] , $caller_apps_includes_dir , $question_front_end ) ; } // --------------------------------------------------------------------- } else { // --------------------------------------------------------------------- $pre_display_function_returned_js = '' ; // --------------------------------------------------------------------- } // ========================================================================= // Display the add/edit record form (in an IFRAME)... // ========================================================================= $min_iframe_height_in_px = 800 ; // ------------------------------------------------------------------------- echo <<

{$pre_display_function_returned_js} EOT; // NOTE! // ----- // The id="greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager_addEditForm_iframe" is // so that we can hide the IFRAME before submitting it - to avoid // the flash of content when the submitted page returns - but // before it redirects the page containing the IFRAME to the // dataset records listing page. // ========================================================================= // That's that! // ========================================================================= } // ============================================================================= // That's that! // =============================================================================