'; $boxwrap = '
'; $before_image='
'.stripslashes($book['title']).'' . stripslashes($s['name']) . ''; } $html .= $after_services; if(in_array('title', $showfields)) { $html .= '

'.stripslashes($book['title']).'

'; } if(in_array('subtitle', $showfields)) { $html .= '

'.stripslashes($book['subtitle']).'

'; } if(in_array('series', $showfields)) { $html .= '

'.stripslashes($book['series']).' '.stripslashes($book['series_num']).'

'; } if(in_array('author', $showfields)) { $html .= '

'.stripslashes($book['author']).'

'; } if(in_array('short_blurb', $showfields)) { $html .= '

'.stripslashes($book['short_blurb']).'

'; } if($book['book_page'] != '') { $html .= '
'; } $html .= $endbox; } return $html.'
'; } function btbe_generateRandomWidgetDisplay($book, $showfields, $icons_visible = false) { $html = ""; $boxwrap = '
'; $before_image='
'.stripslashes($book['title']).'' . stripslashes($s['name']) . ''; } $html .= $after_services; if(in_array('title', $showfields)) { $html .= '

'.stripslashes($book['title']).'

'; } if(in_array('subtitle', $showfields)) { $html .= '

'.stripslashes($book['subtitle']).'

'; } if(in_array('series', $showfields)) { $html .= '

'.stripslashes($book['series']).' '.stripslashes($book['series_num']).'

'; } if(in_array('author', $showfields)) { $html .= '

'.stripslashes($book['author']).'

'; } if(in_array('short_blurb', $showfields)) { $html .= '

'.stripslashes($book['short_blurb']).'

'; } if($book['book_page'] != '') { $html .= '
'; } $html .= $endbox; return $html; } function btbe_generatePageDisplay($book_array, $atts) { $html = ""; if(isset($atts['books']) && strpos($atts['books'], ',') !== false) { $book_array = btbe_reorderBooks($book_array, $atts['books']); } if(!isset($atts['type'])) { $atts['type'] = 'list'; } if($atts['type'] == 'list') { $html .= "
"; foreach ($book_array as $book) { $html .= '
'; if($book['book_page'] != "") { $html .= ''; } $html .= '
'; $html .= '

'.stripslashes($book['title']).'

'; if($book['subtitle'] != "") $html .= '

'.stripslashes($book['subtitle']).'

'; if($book['series'] != "") $html .= '

'.stripslashes($book['series']).' '.stripslashes($book['series_num']).'

'; if($book['author'] != "") $html .= '

'.stripslashes($book['author']).'

'; if($book['short_blurb'] != "") $html .= '

'.stripslashes(nl2br($book['short_blurb'])).'

'; if(@$atts['show_icons'] > 0) { $html .= btbe_addlinks($book['services'], true, $atts['show_icons']); } else { $html .= btbe_addlinks($book['services'], false); } $html .= '

'; } } if($atts['type'] == 'columns') { $boxwidth = 100/count($book_array); $padding = ($boxwidth/100)*2; $boxwrap = '
'; $afterbox = '
'; $html .= "
"; foreach ($book_array as $book) { $html .= $boxwrap; $html .= ''; if($book['short_blurb'] != "") $html .= "

".stripslashes(nl2br($book['short_blurb']))."

"; if($book['book_page'] != "") { $html .= ''; } if(@$atts['show_icons'] > 0) { $html .= btbe_addlinks($book['services'], true, $atts['show_icons']); } else { $html .= btbe_addlinks($book['services'], false); } $html .= $afterbox; } $html .= '

'; } if($atts['type'] == 'grid') { $perRow = isset($atts['per_row']) ? $atts['per_row'] : 4; $html .= btbe_compileGridStyles($perRow); $html .= "
"; $add_breaker = false; if($perRow > 5 && $perRow %2 == 0) { $add_breaker = $perRow/2; } if($perRow > 5 && $perRow %2 != 0) { $add_breaker = ceil($perRow/2); } $boxwrap = '
'; $afterbox = '
'; $before_image='
'.stripslashes($book['title']).'' . stripslashes($s['name']) . ''; } $html .= $after_services; if($book['book_page'] != '') { $html .= '
'; } $html .= $afterbox; if($add_breaker == $count) { $html .= "
"; } if($count == $perRow) { $html .= '
'; $count = 0; } } $html .= '

'; } if($atts['type'] == 'single') { include_once(dirname(__FILE__) . "/class_btbe_api_connections.php"); $html .= "
"; foreach ($book_array as $book) { $html .= ''; $html .= '

'.stripslashes($book['title']).'

'; if($book['subtitle'] != "") $html .= '

'.stripslashes($book['subtitle']).'

'; if($book['series'] != "") $html .= '

'.stripslashes($book['series']).' '.stripslashes($book['series_num']).'

'; if($book['author'] != "") $html .= '

'.stripslashes($book['author']).'

'; if($book['blurb'] != "") $html .= '

'.stripslashes(nl2br($book['blurb'])).'

'; if(@$atts['show_icons'] > 0) { $html .= btbe_addlinks($book['services'], true, $atts['show_icons']); } else { $html .= btbe_addlinks($book['services'], false); } $showreviews = false; if(@$book['isbn'] != '' || @$book['asin'] != '') { $reviewcode = '

Reviews

'; $reviewcode .= btbe_compileReviewsStyles(); } if(@$book['isbn'] != '') { global $wpdb; $goodreads = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}bb_apis WHERE api_name = 'goodreads'", ARRAY_A); if(@$goodreads[0]['access_key'] != '') { $reviewcode .= '
'.btbe_goodreads($book['isbn'], $goodreads[0]['access_key']).'
'; $showreviews = true; } } if(@$book['asin'] != '') { global $wpdb; $amazon = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}bb_apis WHERE api_name = 'amazon'", ARRAY_A); if(@$amazon[0]['access_key'] != '') { $amazon = $amazon[0]; $amazon_reviews = new Btbe_Amazon($amazon['assoc'], $amazon['access_key'], $amazon['secret']); $reviewcode .= '
'; $showreviews = true; } } if($showreviews) { $html.= $reviewcode; } $html .= '

'; } } if($atts['type'] == 'icons_only') { return btbe_addlinks($book_array[0]['services'], true); } if($atts['type'] == 'links_only') { return btbe_addlinks($book_array[0]['services']); } return $html; } function btbe_reorderBooks($book_array, $idstring) { $ordered_array = array(); $id_order = explode(',', $idstring); foreach ($id_order as $id) { foreach ($book_array as $idx => $book) { if($book['id'] == $id) { $ordered_array[] = $book; unset($book_array[$idx]); } } } return $ordered_array; } function btbe_addlinks($services, $useIcons = false, $size = 64) { $services = json_decode($services, true); if(empty($services)) { return ''; } if($useIcons) { $html = '
'; } else { $html = '

Buy this book on:
'; } $compiled_array = array(); foreach ($services as $s) { if($useIcons) { $compiled_array[] = ''; } else { $compiled_array[] = ''.$s['name'].''; } } if($useIcons) { $html .= implode('', $compiled_array); $html .= '

'; } else { $html .= implode(' | ', $compiled_array); $html .= '

'; } return $html; } function btbe_compileGridStyles($perRow) { $boxwidth = 100/$perRow; $padding = ($boxwidth/100)*2; $splitrow = $boxwidth*2; $splitrowpadding = ($splitrow/100)*2; $html = ''; return $html; } function btbe_compileReviewsStyles() { return ''; }