$result[0] , 'records' => $result[1] , 'key_field_slug' => $result[2] , 'record_indices_by_key' => $result[3] ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- $dataset_records = $loaded_datasets[ $dataset_slug ]['records'] ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $dataset_records = Array( // // [0] => Array( // [created_server_datetime_utc] => 1421569635 // [last_modified_server_datetime_utc] => 1421569635 // [key] => cfe6de47-5c12-4397-b9f6-61af9d6fd1d5-1421569635-787371-1425 // [global_sid] => ncgh-vzkm // [ad_swapper_site_sid] => 2kcv-gwhz // [image_url] => http://localhost/plugdev/wp-content/uploads/2014/06/rookie-mag-postcards-from-wonderland.jpeg // [link_url] => http://www.google.co.nz // [alt_text] => // [description] => // [start_datetime] => // [end_datetime] => // [aspect_ratio_min] => // [aspect_ratio_max] => // [sequence_number] => // [question_display] => 1 // ) // // ... // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records , '$dataset_records' ) ; // ========================================================================= // Get the requested record... // ========================================================================= $requested_record = NULL ; // ------------------------------------------------------------------------- foreach ( $dataset_records as $this_index => $this_record ) { // --------------------------------------------------------------------- if ( array_key_exists( 'global_sid' , $this_record ) && $this_record['global_sid'] === $ad_sid ) { $requested_record = $this_record ; break ; } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( ! is_array( $requested_record ) ) { return << $result[0] , 'records' => $result[1] , 'key_field_slug' => $result[2] , 'record_indices_by_key' => $result[3] ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- $dataset_records = $loaded_datasets[ $dataset_slug ]['records'] ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $dataset_records = Array( // // [0] => Array( // [created_server_datetime_utc] => 1421545408 // [last_modified_server_datetime_utc] => 1421545408 // [key] => 10906d4d-6d60-4e39-b201-9bf2b52f4347-1421545408-370125-1421 // [ad_swapper_site_sid] => 2kcv-gwhz // [site_title] => Plugdev // [home_page_url] => http://localhost/plugdev // [general_description] => // [ads_wanted_description] => // [sites_wanted_description] => // [categories_available] => // [categories_wanted] => // [question_display_this_sites_ads_on_your_site] => 1 // [question_display_your_ads_on_this_site] => // ) // // ... // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records , '$dataset_records' ) ; // ========================================================================= // Get the requested record... // ========================================================================= $requested_record = NULL ; // ------------------------------------------------------------------------- foreach ( $dataset_records as $this_index => $this_record ) { // --------------------------------------------------------------------- if ( array_key_exists( 'ad_swapper_site_sid' , $this_record ) && $this_record['ad_swapper_site_sid'] === $site_sid ) { $requested_record = $this_record ; break ; } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( ! is_array( $requested_record ) ) { return << $result[0] , 'records' => $result[1] , 'key_field_slug' => $result[2] , 'record_indices_by_key' => $result[3] ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- $dataset_records = $loaded_datasets[ $dataset_slug ]['records'] ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $dataset_records = Array( // // [0] => Array( // [created_server_datetime_utc] => 1421545408 // [last_modified_server_datetime_utc] => 1421545408 // [key] => 10906d4d-6d60-4e39-b201-9bf2b52f4347-1421545408-370125-1421 // [ad_swapper_site_sid] => 2kcv-gwhz // [site_title] => Plugdev // [home_page_url] => http://localhost/plugdev // [general_description] => // [ads_wanted_description] => // [sites_wanted_description] => // [categories_available] => // [categories_wanted] => // [question_display_this_sites_ads_on_your_site] => 1 // [question_display_your_ads_on_this_site] => // ) // // ... // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records , '$dataset_records' ) ; // ========================================================================= // Get the requested record... // ========================================================================= $requested_record = NULL ; // ------------------------------------------------------------------------- foreach ( $dataset_records as $this_index => $this_record ) { // --------------------------------------------------------------------- if ( array_key_exists( 'site_unique_key' , $this_record ) && $this_record['site_unique_key'] === $site_unique_key ) { $requested_record = $this_record ; break ; } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( ! is_array( $requested_record ) ) { return << $result[0] , 'records' => $result[1] , 'key_field_slug' => $result[2] , 'record_indices_by_key' => $result[3] ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- $dataset_records = $loaded_datasets[ $dataset_slug ]['records'] ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $dataset_records = Array( // // [0] => Array( // [created_server_datetime_utc] => 1423272554 // [last_modified_server_datetime_utc] => 1423272554 // [key] => c6886167-8b81-43c4-9bbb-b7391a007356-1423272554-653172-1523 // [local_key] => 28aba5f6449b8e71f0b96c80a9156f20c0ca451a36e5483c7653579d6f554485 // [name] => right-sidebar // [title] => Right Sidebar // [description] => // [width_nominal] => 300 // [width_min] => // [width_max] => // [height_nominal] => 480 // [height_min] => // [height_max] => // [sequence_number] => // [question_disabled] => // [global_sid] => 23mk-hzcw // ) // // ... // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records , '$dataset_records' ) ; // ========================================================================= // Get the requested record... // ========================================================================= $requested_record = NULL ; // ------------------------------------------------------------------------- foreach ( $dataset_records as $this_index => $this_record ) { // --------------------------------------------------------------------- if ( array_key_exists( 'global_sid' , $this_record ) && $this_record['global_sid'] === $ad_slot_sid ) { $requested_record = $this_record ; break ; } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( ! is_array( $requested_record ) ) { return << "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__ ; $app_handle = 'ad-swapper' ; // --------------------------------------------------------------------- $core_plugapp_dirs = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_appsAPI\get_core_plugapp_dirs( $path_in_plugin , $app_handle ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- require_once( $core_plugapp_dirs['dataset_manager_includes_dir'] . '/mysql-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_mysqlSupport\ // auto_create_or_validate__return_table_name_for__datasets_mysql_table( // $core_plugapp_dirs , // $question_front_end , // $target_apps_apps_dir_relative_path , // $dataset_slug // ) // - - - - - - - - - - - - - - - - - // Auto-creates the dataset's MySQL table (if that table doesn't exist yet). // // Or validates the table if it does exist. Where, by validate, we mean // check that the table on disk is the same as defined in the dataset // definition. In other words, if the dataset definition has been updated // (but the table on disk hasn't), complain! // // $target_apps_apps_dir_relative_path is like (eg):- // o "teaser-maker" // o "basepress-users/reporting-module" // o etc. // // If the auto-creation/validation is successful, returns the table's // MySQL able name. // // RETURNS // On SUCCESS // $mysql_table_name STRING // // On FAILURE // ARRAY // $error_message STRING // ) // ------------------------------------------------------------------------- $question_front_end = FALSE ; // ------------------------------------------------------------------------- $mysql_table_name = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_mysqlSupport\auto_create_or_validate__return_table_name_for__datasets_mysql_table( $core_plugapp_dirs , $question_front_end , $selected_datasets_dmdd , $dataset_slug ) ; // ------------------------------------------------------------------------- if ( is_array( $mysql_table_name ) ) { return $mysql_table_name[0] ; } // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_basepressMysql\ // get_zero_or_more_records( // $sql // ) // - - - - - - - - - - - - - - - - - - - - - // NOTE! The INPUT $sql should NOT be escaped. // // RETURNS // On SUCCESS // - - - - - // The 0+ records specified by the SQL string (as a PHP numeric // array of records). Eg:- // // $records = array( // 0 => array( // 'field_name_1' => , // 'field_name_2' => , // ... ... // 'field_name_N' => // ) // ... // ) // // On FAILURE // - - - - - // An error message STRING. // ------------------------------------------------------------------------- $sql = << 1 ) { return << $result[0] , 'records' => $result[1] , 'key_field_slug' => $result[2] , 'record_indices_by_key' => $result[3] ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- $dataset_records = $loaded_datasets[ $dataset_slug ]['records'] ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $dataset_records = Array( // // [0] => Array( // [created_server_datetime_utc] => 1425197599 // [last_modified_server_datetime_utc] => 1425197599 // [key] => 20a9a031-0d81-49ea-8774-57c66a029156-1425197599-330451-1682 // [local_unique_key] => d4ky-9zyg-gp2w-hdyy // [global_unique_key] => 2222-2222-2222-2222-d4ky-9zyg-gp2w-hdyy // [name_slash_title] => Dog Lovers // [description] => Targeted at users who are dog lovers... // [collection_home_page_url] => http://www.ferntechnology.com/ // [question_moderated] => 1 // [question_disabled] => // ) // // ... // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records , '$dataset_records' ) ; // ========================================================================= // Get the requested record... // ========================================================================= $requested_record = NULL ; // ------------------------------------------------------------------------- foreach ( $dataset_records as $this_index => $this_record ) { // --------------------------------------------------------------------- if ( array_key_exists( 'global_unique_key' , $this_record ) && $this_record['global_unique_key'] === $collection_global_unique_key ) { $requested_record = $this_record ; break ; } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( ! is_array( $requested_record ) ) { return << $result[0] , 'records' => $result[1] , 'key_field_slug' => $result[2] , 'record_indices_by_key' => $result[3] ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- $dataset_records = $loaded_datasets[ $dataset_slug ]['records'] ; // ------------------------------------------------------------------------- // Here we should have (eg):- // // $dataset_records = Array( // // [0] => Array( // ) // // ... // // ) // // ------------------------------------------------------------------------- \greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records , '$dataset_records' ) ; // ========================================================================= // Get the requested record... // ========================================================================= $requested_record = NULL ; // ------------------------------------------------------------------------- foreach ( $dataset_records as $this_index => $this_record ) { // --------------------------------------------------------------------- if ( array_key_exists( 'collection_global_unique_key' , $this_record ) && $this_record['collection_global_unique_key'] === $collection_global_unique_key && array_key_exists( 'member_site_unique_key' , $this_record ) && $this_record['member_site_unique_key'] === $member_site_unique_key ) { $requested_record = $this_record ; break ; } // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( ! is_array( $requested_record ) ) { return <<