array( // // array( // // 'site_sid' => "xxx" // // 'ads' => array( // // // ... // // ) // // 'ad_indices_by_sid' => array( // => 0 , // => 1 , // ... // => M // ) // // 'next_free_ad_index' => <0...> // // 'question_all_ads_shown' => TRUE/FALSE // // ) // // ... // // ) // // 'site_indices_by_sid' => array( // => 0 , // => 1 , // ... // => M // ) // // 'current_site_index' => <0...> // // 'question_all_ads_shown' => TRUE/FALSE // // ) // // Where "sid" = "Sequential ID":- // // o Is the BIGINT "id" field of the Ad Swapper Central "available // sites" and "available ads" tables, // // o Converted to a string like:- // "9khc-zwmv" // // by "number2key()" // // In other words, these "sids" provide global unique ids for the sites and // ads. // ----------------------------------------------------------------------------- // ============================================================================= // die_if_bad_ad_type() // ============================================================================= function die_if_bad_ad_type( $ad_type ) { // ------------------------------------------------------------------------- if ( ! in_array( $ad_type , array( 'banner' , 'normal' ) , TRUE ) ) { $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; $ln = __LINE__ - 7 ; $msg = << array() , 'site_indices_by_sid' => array() , 'current_site_index' => 0 , 'question_all_ads_shown' => FALSE ) ; // ------------------------------------------------------------------------- die_if_bad_ads_list( $ads_list ) ; // ------------------------------------------------------------------------- return $ads_list ; // ------------------------------------------------------------------------- } // ============================================================================= // question_ads_list_is_empty() // ============================================================================= function question_ads_list_is_empty( $ads_list ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_adDisplayer\ // question_ads_list_is_empty( // $ads_list // ) // - - - - - - - - - - - - - - // Returns a flag that indicates whether or not the specified "ads list" // is empty (in the sense that has has NO ads). // // RETURNS // TRUE or FALSE // // die()s on error // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Here we should have (eg):- // // $ads_list = array( // // 'ads_grouped_by_site' => array( // // array( // // 'site_sid' => "xxx" // // 'ads' => array( // // // ... // // ) // // 'ad_indices_by_sid' => array( // => 0 , // => 1 , // ... // => M // ) // // 'next_free_ad_index' => <0...> // // 'question_all_ads_shown' => TRUE/FALSE // // ) // // ... // // ) // // 'site_indices_by_sid' => array( // => 0 , // => 1 , // ... // => M // ) // // 'current_site_index' => <0...> // // 'question_all_ads_shown' => TRUE/FALSE // // ) // // ------------------------------------------------------------------------- if ( count( $ads_list ) === 0 || ! array_key_exists( 'ads_grouped_by_site' , $ads_list ) || count( $ads_list['ads_grouped_by_site'] ) === 0 ) { return TRUE ; } // ------------------------------------------------------------------------- return FALSE ; // ------------------------------------------------------------------------- } // ============================================================================= // die_if_bad_ads_list() // ============================================================================= function die_if_bad_ads_list( $ads_list ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_adDisplayer\ // die_if_bad_ads_list( // $ads_list // ) // - - - - - - - - - // Dies if the the specified "ads list" appears INVALID (in the sense that // it's NOT an ARRAY that contains the variables that it's supposed to). // // RETURNS // Nothing // // die()s on error // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Here we should have (eg):- // // $ads_list = array( // // 'ads_grouped_by_site' => array( // // array( // // 'site_sid' => "xxx" // // 'ads' => array( // // // ... // // ) // // 'ad_indices_by_sid' => array( // => 0 , // => 1 , // ... // => M // ) // // 'next_free_ad_index' => <0...> // // 'question_all_ads_shown' => TRUE/FALSE // // ) // // ... // // ) // // 'site_indices_by_sid' => array( // => 0 , // => 1 , // ... // => M // ) // // 'current_site_index' => <0...> // // 'question_all_ads_shown' => TRUE/FALSE // // ) // // ------------------------------------------------------------------------- //echo '
' ;
//print_r( $ads_list ) ;
//echo '
' ; // ------------------------------------------------------------------------- if ( ! is_array( $ads_list ) || count( $ads_list ) < 1 ) { $msg = << 'array' , 'site_indices_by_sid' => 'array' , 'current_site_index' => 'integer' , 'question_all_ads_shown' => 'boolean' ) ; // ------------------------------------------------------------------------- foreach ( $required_toplevel_members as $name => $type ) { // --------------------------------------------------------------------- if ( ! array_key_exists( $name , $ads_list ) ) { $msg = << 'string' , 'ads' => 'array' , 'ad_indices_by_sid' => 'array' , 'next_free_ad_index' => 'integer' , 'question_all_ads_shown' => 'boolean' ) ; // ------------------------------------------------------------------------- foreach ( $ads_list['ads_grouped_by_site'] as $this_index => $this_site ) { // --------------------------------------------------------------------- foreach ( $required_sitelevel_members as $name => $type ) { // ----------------------------------------------------------------- if ( ! array_key_exists( $name , $this_site ) ) { $msg = <<