Changeset 573675
- Timestamp:
- 07/17/2012 05:27:47 PM (14 years ago)
- Location:
- beer-ratings/trunk
- Files:
-
- 7 edited
-
assets/html/settings-help.html (modified) (9 diffs)
-
includes/BeerRatings.php (modified) (6 diffs)
-
includes/BeerRatings_Settings.php (modified) (3 diffs)
-
includes/BeerRatings_Shortcode.php (modified) (3 diffs)
-
includes/RateBeer/RateBeer_Beer.php (modified) (16 diffs)
-
index.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
beer-ratings/trunk/assets/html/settings-help.html
r572597 r573675 96 96 <tr> 97 97 <td><b>#_OVERALLPCTL</b></td> 98 <td>The overall percentage (rank among all beers). 98 <td>The overall percentage represents a beers performance 99 relative to all beers on an adjusted percentile basis. 99 100 This value will display full precision of the percentage 100 101 (up to 10 places to the right of the decimal). 101 102 To round the value, use #_OVERALLPCTL0. For 1 or 2 places 102 103 of precision use #_OVERALLPCTL1 or #_OVERALLPCTL2. 103 Please note that #_OVERALLPCTL0 will not round to a whole104 number, so values such as 99.85 will render as 99 and not 100105 (just like on RateBeer.com).106 104 </td> 107 105 </tr> 108 106 <tr> 109 107 <td><b>#_STYLEPCTL</b></td> 110 <td>The style percentage (rank among beers with same style). 108 <td>The style percentage represents a beers performance relative 109 to its peers in the same beer style category on an 110 adjusted percentile basis. 111 111 This value will display full precision of the percentage 112 112 (up to 10 places to the right of the decimal). 113 113 To round the value, use #_STYLEPCTL0. For 1 or 2 places 114 of precision use #_STYLEPCTL1 or #_STYLEPCTL2. 115 Please note that #_STYLEPCTL0 will not round to a whole 116 number, so values such as 99.85 will render as 99 and not 100 117 (just like on RateBeer.com). 114 of precision use #_STYLEPCTL1 or #_STYLEPCTL2. 118 115 </td> 119 116 </tr> … … 284 281 (up to 10 places to the right of the decimal). 285 282 To round the value, use #_AVERAGERATING0. For 1 or 2 places 286 of precision use #_AVERAGERATING1 or #_AVERAGERATING2. 287 Please note that #_AVERAGERATING0 will not round to a whole 288 number, so values such as 99.85 will render as 99 and not 100 289 (just like on RateBeer.com).</td> 283 of precision use #_AVERAGERATING1 or #_AVERAGERATING2. 284 </td> 290 285 </tr> 291 286 <tr> … … 295 290 <tr> 296 291 <td><b>#_OVERALLPCTL</b></td> 297 <td>The overall percentage (rank among all beers). 292 <td>The overall percentage represents a beers performance 293 relative to all beers on an adjusted percentile basis. 298 294 This value will display full precision of the percentage 299 295 (up to 10 places to the right of the decimal). 300 296 To round the value, use #_OVERALLPCTL0. For 1 or 2 places 301 of precision use #_OVERALLPCTL1 or #_OVERALLPCTL2. 302 Please note that #_OVERALLPCTL0 will not round to a whole 303 number, so values such as 99.85 will render as 99 and not 100 304 (just like on RateBeer.com). 297 of precision use #_OVERALLPCTL1 or #_OVERALLPCTL2. 305 298 </td> 306 299 </tr> 307 300 <tr> 308 301 <td><b>#_STYLEPCTL</b></td> 309 <td>The style percentage (rank among beers with same style). 302 <td>The style percentage represents a beers performance relative 303 to its peers in the same beer style category on an 304 adjusted percentile basis. 310 305 This value will display full precision of the percentage 311 306 (up to 10 places to the right of the decimal). 312 307 To round the value, use #_STYLEPCTL0. For 1 or 2 places 313 of precision use #_STYLEPCTL1 or #_STYLEPCTL2. 314 Please note that #_STYLEPCTL0 will not round to a whole 315 number, so values such as 99.85 will render as 99 and not 100 316 (just like on RateBeer.com). 308 of precision use #_STYLEPCTL1 or #_STYLEPCTL2. 317 309 </td> 318 310 </tr> … … 428 420 To round the value, use #_AVERAGERATING0. For 1 or 2 places 429 421 of precision use #_AVERAGERATING1 or #_AVERAGERATING2. 430 Please note that #_AVERAGERATING0 will not round to a whole 431 number, so values such as 99.85 will render as 99 and not 100 432 (just like on RateBeer.com).</td> 422 </td> 433 423 </tr> 434 424 <tr> … … 542 532 </div> 543 533 </div> 544 545 <!-- 534 546 535 <h3 class="rb-toggleHeader"><a href="#">Best Beer (By Country) Placeholders [beerratings-bestbeer-country]</a></h3> 547 536 <div style="display: block;" class="rb-toggleContainer"> 548 <div class="rb-toggleBlock"> 549 ########################################<br/> 550 This isn't working via RateBeer's API<br/> 551 ########################################<br/> 537 <div class="rb-toggleBlock"> 552 538 <h4>Description</h4> 553 <p>Show bestbeers by country. Optional userid shows you best beers the userid has not had.</p>539 <p>Show top 50 beers by country. Optional userid shows you best beers the userid has not had.</p> 554 540 <h4>How to find the Country ID</h4> 555 541 <ol> … … 568 554 <dt>show_retired (optional)</dt> 569 555 <dd>Default value is true. If set to 'false', then retired beers are not shown.</dd> 556 <dt>sort (optional)</dt> 557 <dd>The sorting method: 'rating', 'alpha'</dd> 558 <dt>limit (optional)</dt> 559 <dd>Default value is 50 (per country ID). Maximum value is 50 (per country ID). If you specify multiple country IDs, then the limit will apply to each individual country. For example, limit='5' with id='213,39' will return 5 beers for id=213 and 5 beers for id=214. The beers sorted by country, so the all beers id=213 will come before beers id=39.</dd> 570 560 </dl> 571 561 <code>[beerratings-bestbeer-country id='213']</code> 572 <p>You may also enter multiple styleIDs as shown in the examples below:</p>573 <code>[beerratings-bestbeer-country id='213,39' show_retired='false' ]</code>562 <p>You may also enter multiple country IDs as shown in the examples below:</p> 563 <code>[beerratings-bestbeer-country id='213,39' show_retired='false' limit='5' sort='rating']</code> 574 564 <h4>API Test</h4> 575 565 <p>Use the below URL to test your API key and see the raw JSON data.<br/> 576 http://www.ratebeer.com/json/ bcc.asp?k=YOUR_API_KEY&c=213566 http://www.ratebeer.com/json/tb.asp?k=YOUR_API_KEY&m=country&c=213 577 567 </p> 568 <h4>Conditions</h4> 569 <table class="form-table"> 570 <tr> 571 <td><b>{has_avg_rating}</b></td> 572 <td>Only render inner text if {has_avg_rating} is true.</td> 573 </tr> 574 <tr> 575 <td><b>{is_retired}</b></td> 576 <td>Only render inner text if {is_retired} is true.</td> 577 </tr> 578 <tr> 579 <td><b>{is_not_retired}</b></td> 580 <td>Only render inner text if {is_not_retired} is true.</td> 581 </tr> 582 </table> 578 583 <h4>Output Fields</h4> 579 584 <table class="form-table"> … … 585 590 <td><b>#_BEERNAME</b></td> 586 591 <td>The beer's name.</td> 587 </tr> 588 <tr> 589 <td><b>#_BREWERID</b></td> 590 <td>The unique identifer associated with the brewery.</td> 591 </tr> 592 <tr> 593 <td><b>#_BREWERNAME</b></td> 594 <td>The brewer's name.</td> 592 </tr> 593 <tr> 594 <td><b>#_AVERAGERATING</b></td> 595 <td>The beer's average rating. 596 This value will display full precision of the percentage 597 (up to 10 places to the right of the decimal). 598 To round the value, use #_AVERAGERATING0. For 1 or 2 places 599 of precision use #_AVERAGERATING1 or #_AVERAGERATING2. 600 </td> 601 </tr> 602 <tr> 603 <td><b>#_RATECOUNT</b></td> 604 <td>The number (count) of ratings.</td> 605 </tr> 606 <tr> 607 <td><b>#_RETIRED</b></td> 608 <td>A boolean indicating whether the beer is retired.</td> 609 </tr> 610 <tr> 611 <td><b>#_BEERSTYLENAME</b></td> 612 <td>The beer's style name.</td> 613 </tr> 614 <tr> 615 <td><b>#_USERHADIT</b></td> 616 <td>When using 'userid' attribute, this is a boolean indicating whether the user has had the beer.</td> 595 617 </tr> 596 618 <tr> … … 609 631 <td><b>#_BEERIMAGE</b></td> 610 632 <td>An image HTML tag usingthe RateBeer.com beer image (uses #_BEERIMAGE as src and #_BEERNAME as alt values).</td> 611 </tr> 612 <tr> 613 <td><b>#_BREWERURL</b></td> 614 <td>The URL to the RateBeer.com brewer web page.</td> 633 </tr> 634 </table> 635 </div> 636 </div> 637 638 <h3 class="rb-toggleHeader"><a href="#">Best Beer (By Season) Placeholders [beerratings-bestbeer-season]</a></h3> 639 <div style="display: block;" class="rb-toggleContainer"> 640 <div class="rb-toggleBlock"> 641 <h4>Description</h4> 642 <p>Show top 50 beers by season</p> 643 <h4>How to find the Season ID</h4> 644 <ul> 645 <li>1 = Winter</li> 646 <li>2 = Spring</li> 647 <li>3 = Summer</li> 648 <li>4 = Autumn</li> 649 <li>5 = Special</li> 650 <li>6 = Series</li> 651 </ul> 652 <h4>Code Example</h4> 653 <p>Attributes</p> 654 <dl> 655 <dt>id (required)</dt> 656 <dd>The season ID(s). If more than one, then use a comma delimitor.</dd> 657 <dt>sort (optional)</dt> 658 <dd>The sorting method: 'rating', 'alpha'</dd> 659 <dt>limit (optional)</dt> 660 <dd>Default value is 50 (per season ID). Maximum value is 50 (per season ID). If you specify multiple season IDs, then the limit will apply to each individual season. For example, limit='5' with id='1,2' will return 5 beers for id=1 and 5 beers for id=2. The beers sorted by season, so the all beers id=1 will come before beers id=2.</dd> 661 </dl> 662 <code>[beerratings-bestbeer-season id='1']</code> 663 <p>You may also enter multiple season IDs as shown in the examples below:</p> 664 <code>[beerratings-bestbeer-season id='1,2' limit='5' sort='rating']</code> 665 <h4>API Test</h4> 666 <p>Use the below URL to test your API key and see the raw JSON data.<br/> 667 http://www.ratebeer.com/json/tb.asp?k=YOUR_API_KEY&m=season&season=1 668 </p> 669 <h4>Conditions</h4> 670 <table class="form-table"> 671 <tr> 672 <td><b>{has_avg_rating}</b></td> 673 <td>Only render inner text if {has_avg_rating} is true.</td> 674 </tr> 675 </table> 676 <h4>Output Fields</h4> 677 <table class="form-table"> 678 <tr> 679 <td><b>#_BEERID</b></td> 680 <td>The unique identifer associated with the beer.</td> 681 </tr> 682 <tr> 683 <td><b>#_BEERNAME</b></td> 684 <td>The beer's name.</td> 685 </tr> 686 <tr> 687 <td><b>#_BREWERID</b></td> 688 <td>The unique identifer associated with the brewery.</td> 689 </tr> 690 <tr> 691 <td><b>#_BREWERNAME</b></td> 692 <td>The brewery's name.</td> 693 </tr> 694 <tr> 695 <td><b>#_RATECOUNT</b></td> 696 <td>The number (count) of ratings.</td> 697 </tr> 698 <tr> 699 <td><b>#_AVERAGERATING</b></td> 700 <td>The beer's average rating. 701 This value will display full precision of the percentage 702 (up to 10 places to the right of the decimal). 703 To round the value, use #_AVERAGERATING0. For 1 or 2 places 704 of precision use #_AVERAGERATING1 or #_AVERAGERATING2. 705 </td> 706 </tr> 707 <tr> 708 <td><b>#_BEERSTYLENAME</b></td> 709 <td>The beer's style name.</td> 710 </tr> 711 <tr> 712 <td><b>#_BEERURL</b></td> 713 <td>The URL to the RateBeer.com beer web page.</td> 615 714 </tr> 616 715 <tr> 716 <td><b>#_BEERLINK</b></td> 717 <td>A hyperlink to the RateBeer.com beer web page (uses #_BEERURL as href and #_BEERNAME as inner text values).</td> 718 </tr> 719 <tr> 720 <td><b>#_BEERIMAGEURL</b></td> 721 <td>The URL to the RateBeer.com beer image.</td> 722 </tr> 723 <tr> 724 <td><b>#_BEERIMAGE</b></td> 725 <td>An image HTML tag usingthe RateBeer.com beer image (uses #_BEERIMAGE as src and #_BEERNAME as alt values).</td> 726 </tr> 727 <tr> 728 <td><b>#_BREWERURL</b></td> 729 <td>The URL to the RateBeer.com brewer web page.</td> 730 </tr> 731 <tr> 617 732 <td><b>#_BREWERLINK</b></td> 618 733 <td>A hyperlink to the RateBeer.com brewer web page (uses #_BREWERURL as href and #_BREWERNAME as inner text values).</td> 619 </tr> 734 </tr> 620 735 <tr> 621 736 <td><b>#_BREWERIMAGEURL</b></td> … … 625 740 <td><b>#_BREWERIMAGE</b></td> 626 741 <td>An image HTML tag usingthe RateBeer.com brewer image (uses #_BREWERIMAGE as src and #_BREWERNAME as alt values).</td> 627 </tr> 742 </tr> 628 743 </table> 629 744 </div> 630 745 </div> 631 -->632 746 633 747 <h3 class="rb-toggleHeader"><a href="#">Beer Review Placeholders [beerratings-beer-review]</a></h3> -
beer-ratings/trunk/includes/BeerRatings.php
r572597 r573675 81 81 add_option('beerratings_beerlist_byplace_item', 82 82 "<li id='beer-#_BEERID' class='beerratings_beer_item'> 83 <b>#_BEERLINK</b> {has_avg_rating}( Avg Rating:#_AVERAGERATING2){/has_avg_rating}83 <b>#_BEERLINK</b> {has_avg_rating}(<b>Avg Rating:</b> #_AVERAGERATING2){/has_avg_rating} 84 84 </li>" ); 85 85 … … 113 113 114 114 // best beer by country 115 /* 116 add_option('beerratings_beerlist_bycountry_header', "<div class='beerratings_beer_list'>"); 117 118 add_option('beerratings_beerlist_bycountry_item', 119 "<div id='beer-#_BEERID' class='beerratings_beer_item'> 120 <span class='name'>#_BEERNAME</span> 121 by 122 <span class='brewer'>#_BREWERNAME</span> 123 </div>" ); 124 125 add_option('beerratings_beerlist_bycountry_footer', "</div>"); 126 */ 127 115 add_option('beerratings_beerlist_bestbycountry_header', "<ol class='beerratings_beer_list'>"); 116 117 add_option('beerratings_beerlist_bestbycountry_item', 118 "<li id='beer-#_BEERID'> 119 <b>#_BEERLINK</b><br/> 120 <b>Style:</b> #_BEERSTYLENAME {has_avg_rating}<b>Avg Rating:</b> #_AVERAGERATING2{/has_avg_rating} 121 </li>" ); 122 123 add_option('beerratings_beerlist_bestbycountry_footer', "</ol>"); 124 125 // best beer by season 126 add_option('beerratings_beerlist_bestbyseason_header', "<ol class='beerratings_beer_list'>"); 127 128 add_option('beerratings_beerlist_bestbyseason_item', 129 "<li id='beer-#_BEERID'> 130 <b>#_BEERLINK</b> by <b>#_BREWERLINK</b><br/> 131 <b>Style:</b> #_BEERSTYLENAME {has_avg_rating}<b>Avg Rating:</b> #_AVERAGERATING2{/has_avg_rating} 132 </li>" ); 133 134 add_option('beerratings_beerlist_bestbycountry_footer', "</ol>"); 135 128 136 // beer by id 129 137 add_option('beerratings_beerlist_header', "<div class='beerratings_beer_list'>"); … … 131 139 add_option('beerratings_beerlist_item', 132 140 "<div id='beer-#_BEERID' style='border: 1px solid #D6D6D6; border-radius: 6px 6px 6px 6px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); padding: 4px;margin-bottom:10px;'> 133 <b>#_BEERLINK</b> by <b>#_BREWERLINK</b><br/>134 <b>Style:</b> #_BEERSTYLENAME {has_abv}<b>ABV:</b> #_ALCOHOL%{/has_abv} {has_ibu}<b>IBU:</b> #_IBU{/has_ibu} </br>135 <b>Overall:</b> #_OVERALLPCTL2% <b>Style:</b> #_STYLEPCTL2%<br/> 136 {has_description} #_DESCRIPTION{/has_description}141 <b>#_BEERLINK</b> by <b>#_BREWERLINK</b><br/> 142 <b>Style:</b> #_BEERSTYLENAME {has_abv}<b>ABV:</b> #_ALCOHOL%{/has_abv} {has_ibu}<b>IBU:</b> #_IBU{/has_ibu} 143 {has_overallpctl}<br/><b>Overall:</b> #_OVERALLPCTL2%{/has_overallpctl} {has_stylepctl}<b>Style:</b> #_STYLEPCTL2%{/has_stylepctl} 144 {has_description}<br/>#_DESCRIPTION{/has_description} 137 145 </div>" ); 138 146 … … 170 178 } 171 179 172 /* 173 * Deactivate the plugin, remove saved options from db 180 /* 181 * Deactivate the plugin 182 * don't remove saved options from db 183 * because plugins are deactivated on 184 * updating and then reactivated! 174 185 */ 175 186 function deactivate_plugin() { 187 } 188 189 /* 190 * Uninstall the plugin, remove saved options from db 191 */ 192 function uninstall_plugin() { 193 176 194 delete_option('beerratings_ratebeer_apikey'); 177 195 delete_option('beerratings_cachetime'); … … 206 224 delete_option('beerratings_beerlist_bystyle_footer'); 207 225 208 // delete_option('beerratings_beerlist_bycountry_header'); 209 // delete_option('beerratings_beerlist_bycountry_item'); 210 // delete_option('beerratings_beerlist_bycountry_footer'); 211 226 delete_option('beerratings_beerlist_bycountry_header'); 227 delete_option('beerratings_beerlist_bycountry_item'); 228 delete_option('beerratings_beerlist_bycountry_footer'); 229 230 delete_option('beerratings_beerlist_byseason_header'); 231 delete_option('beerratings_beerlist_byseason_item'); 232 delete_option('beerratings_beerlist_byseason_footer'); 233 212 234 delete_option('beerratings_placelist_header'); 213 235 delete_option('beerratings_placelist_item'); … … 225 247 $apiKey = get_option('beerratings_ratebeer_apikey'); 226 248 if( empty( $apiKey ) ) { 227 echo '<div class="error ">249 echo '<div class="error fade"> 228 250 <p>Beer Ratings Plugin: You must enter a valid RateBeer API Key.</p> 229 251 </div>'; -
beer-ratings/trunk/includes/BeerRatings_Settings.php
r572597 r573675 229 229 update_option('beerratings_beerlist_bystyle_footer', htmlspecialchars_decode( $_POST['beerratings_beerlist_bystyle_footer']) ); 230 230 231 // update_option('beerratings_beerlist_bycountry_header', htmlspecialchars_decode( $_POST['beerratings_beerlist_bycountry_header']) ); 232 // update_option('beerratings_beerlist_bycountry_item', htmlspecialchars_decode( $_POST['beerratings_beerlist_bycountry_item']) ); 233 // update_option('beerratings_beerlist_bycountry_footer', htmlspecialchars_decode( $_POST['beerratings_beerlist_bycountry_footer']) ); 234 231 update_option('beerratings_beerlist_bycountry_header', htmlspecialchars_decode( $_POST['beerratings_beerlist_bycountry_header']) ); 232 update_option('beerratings_beerlist_bycountry_item', htmlspecialchars_decode( $_POST['beerratings_beerlist_bycountry_item']) ); 233 update_option('beerratings_beerlist_bycountry_footer', htmlspecialchars_decode( $_POST['beerratings_beerlist_bycountry_footer']) ); 234 235 update_option('beerratings_beerlist_byseason_header', htmlspecialchars_decode( $_POST['beerratings_beerlist_byseason_header']) ); 236 update_option('beerratings_beerlist_byseason_item', htmlspecialchars_decode( $_POST['beerratings_beerlist_byseason_item']) ); 237 update_option('beerratings_beerlist_byseason_footer', htmlspecialchars_decode( $_POST['beerratings_beerlist_byseason_footer']) ); 238 235 239 update_option('beerratings_placelist_header', htmlspecialchars_decode( $_POST['beerratings_placelist_header']) ); 236 240 update_option('beerratings_placelist_item', htmlspecialchars_decode( $_POST['beerratings_placelist_item']) ); … … 354 358 </div> 355 359 356 <!--360 357 361 <h3 class="rb-toggleHeader"><a href="#">Best Beer (By Country) Listings [beerratings-bestbeer-country]</a></h3> 358 362 <div style="display: block;" class="rb-toggleContainer"> … … 374 378 </div> 375 379 </div> 376 --> 380 381 <h3 class="rb-toggleHeader"><a href="#">Best Beer (By Season) Listings [beerratings-bestbeer-season]</a></h3> 382 <div style="display: block;" class="rb-toggleContainer"> 383 <div class="rb-toggleBlock"> 384 <table class="form-table"> 385 <tr valign="top"> 386 <th scope="row">Beer list header format </th> 387 <td><textarea rows='3' cols='60' name="beerratings_beerlist_byseason_header"><?php echo stripslashes ( htmlspecialchars( get_option('beerratings_beerlist_byseason_header') ) ); ?></textarea></td> 388 </tr> 389 <tr valign="top"> 390 <th scope="row">Beer list item format</th> 391 <td><textarea rows='10' cols='60' name="beerratings_beerlist_byseason_item"><?php echo stripslashes ( htmlspecialchars( get_option('beerratings_beerlist_byseason_item') ) ); ?></textarea></td> 392 </tr> 393 <tr valign="top"> 394 <th scope="row">Beer list footer format</th> 395 <td><textarea rows='3' cols='60' name="beerratings_beerlist_byseason_footer"><?php echo stripslashes ( htmlspecialchars( get_option('beerratings_beerlist_byseason_footer') ) ); ?></textarea></td> 396 </tr> 397 </table> 398 </div> 399 </div> 400 377 401 378 402 <h3 class="rb-toggleHeader"><a href="#">Beer Review Listings [beerratings-beer-review]</a></h3> -
beer-ratings/trunk/includes/BeerRatings_Shortcode.php
r572597 r573675 125 125 126 126 /* 127 * [beerratings-be er-style id='X']127 * [beerratings-bestbeer-style id='X'] 128 128 */ 129 129 function beerratings_bestbeer_style( $attrs, $content = null) { … … 144 144 145 145 /* 146 * [beerratings-be er-country id='X']146 * [beerratings-bestbeer-country id='X'] 147 147 */ 148 148 function beerratings_bestbeer_country( $attrs, $content = null) { … … 162 162 } 163 163 164 165 /* 166 * [beerratings-bestbeer-season id='X'] 167 */ 168 function beerratings_bestbeer_season( $attrs, $content = null) { 169 $apiKeyValidate = BeerRatings_Shortcode::validate_api_key(); 170 if(!empty($apiKeyValidate)){ 171 return $apiKeyValidate; 172 } 173 174 $rbb = new RateBeer_Beer(); 175 $output = $rbb->get_best_beer_by_seasonid($attrs, $content); 176 177 if(get_option('beerratings_creditlink') == '1'){ 178 $output .= BeerRatings::get_plugin_creditlink(); 179 } 180 181 return $output; 182 } 183 164 184 /* 165 185 * [beerratings-beer-review id='X'] -
beer-ratings/trunk/includes/RateBeer/RateBeer_Beer.php
r572597 r573675 38 38 var $TimeEntered; 39 39 var $IsOut; 40 var $BeerStyleID; 40 41 var $BeerStyleName; 41 42 var $IBU; … … 71 72 $this->IsOut = $beerInfo->IsOut; 72 73 74 $this->BeerStyleID = $beerInfo->BeerStyleID; 73 75 $this->BeerStyleName = $beerInfo->BeerStyleName; 76 74 77 $this->IBU = $beerInfo->IBU; 75 78 $this->Description = RateBeer::remove_notes($beerInfo->Description); … … 80 83 $this->BrewerImageURL = $this->get_brewer_image_url($beerInfo->BrewerID); 81 84 85 if (empty($this->BeerStyleName) && (!empty($this->BeerStyleID))){ 86 $this->BeerStyleName = RateBeer_Lookups::get_beer_style($this->BeerStyleID); 87 } 88 89 if (!empty($this->HadIt)) { 90 $this->UserHadIt = $this->HadIt; 91 } 82 92 } 83 93 … … 122 132 return $output; 123 133 } 124 125 /* 126 * gets the top beers 127 * [beerratings-beer-top mode=''] 128 * mode=country/season 129 */ 130 function get_top_beers( $attrs, $content = null) { 131 // TO DO 132 } 133 134 135 /* 136 * gets the best beer by seasonid 137 * [beerratings-beer-season id='X' limit='X' sort='x'] 138 */ 139 function get_best_beer_by_seasonid( $attrs, $content = null) { 140 $output = ""; 141 $season_ids = explode( ",", $attrs['id'] ); 142 $limit = $attrs['limit']; 143 144 if ( is_null( $limit ) || "" == $limit ) { 145 $limit = 50; 146 } else { 147 $limit = intval($limit); 148 if($limit > 50){ 149 $limit =50; 150 } 151 } 152 153 // if array of ids, then loop 154 if ( is_array( $season_ids ) ) { 155 $headerLayout = stripslashes( get_option('beerratings_beerlist_byseason_header') ); 156 $output .= $headerLayout; 157 158 // start looping 159 foreach ( $season_ids as $season_id ) { 160 $beers = $this->retrieve_best_beer_by_seasonid( $season_id, $sort); 161 if ($beers->error) { 162 return; 163 } 164 165 if (is_array($beers)) { 166 $counter = 0; 167 foreach ( $beers as $beer ) { 168 if($counter >= $limit){ 169 break; // exit foreach 170 } 171 172 // assign vars 173 $this->set_beer_fields($beer); 174 175 // get layout 176 $counter += 1; 177 $layout = stripslashes( get_option('beerratings_beerlist_byseason_item') ); 178 $output .= $this->apply_layout($layout); 179 } 180 } 181 } 182 183 $footerLayout = stripslashes( get_option('beerratings_beerlist_byseason_footer') ); 184 $output .= $footerLayout; 185 } 186 187 $output .= $this->get_ratebeer_copyright(); 188 return $output; 189 } 190 134 191 /* 135 192 * gets the best beer by countryid 136 * [beerratings-beer-country id='X'] 137 * currently the RateBeer API is broken, so this is not accessible 193 * [beerratings-beer-country id='X'] 138 194 */ 139 195 function get_best_beer_by_countryid( $attrs, $content = null) { … … 141 197 $country_ids = explode( ",", $attrs['id'] ); 142 198 $user_id = ''; 143 $show_retired = true; 144 145 if( isset($attrs['userid'])){ 146 $user_id = $attrs['userid']; 147 } 148 199 $limit = $attrs['limit']; 200 $show_retired = true; 201 149 202 if( isset($attrs['show_retired'])){ 150 203 if( $attrs['show_retired'] == 'false' ) { … … 153 206 } 154 207 208 if( isset($attrs['userid'])){ 209 $user_id = $attrs['userid']; 210 } 211 212 if ( is_null( $limit ) || "" == $limit ) { 213 $limit = 50; 214 } else { 215 $limit = intval($limit); 216 if($limit > 50){ 217 $limit =50; 218 } 219 } 220 155 221 // if array of ids, then loop 156 222 if ( is_array( $country_ids ) ) { … … 160 226 // start looping 161 227 foreach ( $country_ids as $country_id ) { 162 $beers = $this->retrieve_best_beer_by_countryid( $country_id, $user_id );228 $beers = $this->retrieve_best_beer_by_countryid( $country_id, $user_id, $sort ); 163 229 if ($beers->error) { 164 230 return; … … 166 232 167 233 if (is_array($beers)) { 234 $counter = 0; 168 235 foreach ( $beers as $beer ) { 236 if($counter >= $limit){ 237 break; // exit foreach 238 } 239 169 240 // assign vars 170 241 $this->set_beer_fields($beer); … … 174 245 } else { 175 246 // get layout 247 $counter += 1; 176 248 $layout = stripslashes( get_option('beerratings_beerlist_bycountry_item') ); 177 249 $output .= $this->apply_layout($layout); … … 234 306 if($counter >= $limit){ 235 307 break; // exit foreach 236 } 237 $counter += 1; 308 } 238 309 239 310 // assign vars … … 245 316 } else { 246 317 // get layout 318 $counter += 1; 247 319 $layout = stripslashes( get_option('beerratings_beerlist_bystyle_item') ); 248 320 $output .= $this->apply_layout($layout); … … 370 442 return $output; 371 443 } 444 445 /* 446 * Make JSON/API call for [beerratings-beer-season id='X'] 447 */ 448 function retrieve_best_beer_by_seasonid( $season_id, $sort ) { 449 // example: http://ratebeer.com/json/tb.asp?k=<YOUR_KEY>&m=season&s=1 450 if ( is_null( $season_id ) || "" == $season_id ) { 451 throw new Exception("Error"); 452 } 453 454 // validate country_id 455 if (filter_var($season_id, FILTER_VALIDATE_INT) == false) { 456 $country_id = 0; 457 } 458 459 // fix sorting options 460 if($sort == 'rating' ) { 461 $sort = 1; 462 } elseif ( $sort == 'alpha') { 463 $sort = 2; 464 } else { 465 $sort = ''; 466 } 467 468 $cache_filename = $this->get_cache_filepath( "bestbeer-season-" . $season_id . "-" . $sort ); 469 470 if ( $this->has_cache_file( $cache_filename ) ) { 471 $beers = $this->get_cache_file_contents( $cache_filename ) ; 472 } else { 473 $api_args = array( 474 'k' => $this->api_key, 475 'm' => 'season', 476 'season' => $season_id 477 ); 478 479 // optional, doesn't work if it's included with null 480 if (!empty($sort)){ 481 $api_args['s'] = $sort; 482 } 483 484 $url = $this->create_api_url( 'tb.asp', $api_args ); 485 $beers = $this->save_cache_file_contents( $url, $cache_filename); 486 } 487 488 // var_dump($beers); 489 return $beers; 490 } 491 492 /* 493 * Make JSON/API call for [beerratings-beer-country id='X'] 494 */ 495 function retrieve_best_beer_by_countryid( $country_id, $user_id, $sort ) { 496 // example: http://ratebeer.com/json/tb.asp?k=<YOUR_KEY>&m=country&c=213&u=<userid> 497 if ( is_null( $country_id ) || "" == $country_id ) { 498 throw new Exception("Error"); 499 } 500 501 // validate country_id 502 if (filter_var($country_id, FILTER_VALIDATE_INT) == false) { 503 $country_id = 0; 504 } 505 506 // validate user_id 507 if (filter_var($user_id, FILTER_VALIDATE_INT) == false) { 508 $user_id = ''; 509 } 510 511 // fix sorting options 512 if($sort == 'rating' ) { 513 $sort = 1; 514 } elseif ( $sort == 'alpha') { 515 $sort = 2; 516 } else { 517 $sort = ''; 518 } 519 520 $cache_filename = $this->get_cache_filepath( "bestbeer-country-" . $country_id . "-" . $user_id . "-" . $sort ); 521 522 if ( $this->has_cache_file( $cache_filename ) ) { 523 $beers = $this->get_cache_file_contents( $cache_filename ) ; 524 } else { 525 $api_args = array( 526 'k' => $this->api_key, 527 'm' => 'country', 528 'c' => $country_id 529 ); 530 531 // optional, doesn't work if it's included with null 532 if (!empty($user_id)){ 533 $api_args['u'] = $user_id; 534 } 535 536 // optional, doesn't work if it's included with null 537 if (!empty($sort)){ 538 $api_args['s'] = $sort; 539 } 540 541 $url = $this->create_api_url( 'tb.asp', $api_args ); 542 $beers = $this->save_cache_file_contents( $url, $cache_filename); 543 } 544 545 // var_dump($beers); 546 return $beers; 547 } 372 548 373 549 /* … … 402 578 return $beer_info; 403 579 } 404 405 /* 406 * Make JSON/API call for [beerratings-beer-country id='X'] 407 */ 408 function retrieve_best_beer_by_countryid( $country_id ) { 409 // example: http://www.ratebeer.com/json/bcc.asp?k=<YOUR_KEY>&c=213 410 411 if ( is_null( $country_id ) || "" == $country_id ) { 412 throw new Exception("Error"); 413 } 414 415 // validate country_id 416 if (filter_var($country_id, FILTER_VALIDATE_INT) == false) { 417 $country_id = 0; 418 } 419 420 // validate user_id 421 if (filter_var($user_id, FILTER_VALIDATE_INT) == false) { 422 $user_id = ''; 423 } 424 425 $cache_filename = $this->get_cache_filepath( "best-beer-country-" . $country_id . "-" . $user_id ); 426 427 if ( $this->has_cache_file( $cache_filename ) ) { 428 $beers = $this->get_cache_file_contents( $cache_filename ) ; 429 } else { 430 $api_args = array( 431 'k' => $this->api_key, 432 'c' => $country_id 433 ); 434 435 // optional, doesn't work if it's included with null 436 if (!empty($user_id)){ 437 $api_args['uid'] = $user_id; 438 } 439 440 // optional, doesn't work if it's included with null 441 if (!empty($sort)){ 442 $api_args['s'] = $sort; 443 } 444 445 $url = $this->create_api_url( 'bcc.asp', $api_args ); 446 $beers = $this->save_cache_file_contents( $url, $cache_filename); 447 } 448 449 // var_dump($placeBeers); 450 return $beers; 451 } 452 580 453 581 /* 454 582 * Make JSON/API call for [beerratings-beer-style id='X'] … … 703 831 case '#_AVERAGERATING0': 704 832 if(!empty($this->AverageRating)){ 705 $replace = floor($this->AverageRating);833 $replace = round($this->AverageRating); 706 834 } 707 835 break; … … 726 854 case '#_OVERALLPCTL0': 727 855 if(!empty($this->OverallPctl)){ 728 $replace = floor($this->OverallPctl);856 $replace = round($this->OverallPctl); 729 857 } 730 858 break; … … 745 873 case '#_STYLEPCTL0': 746 874 if(!empty($this->StylePctl)){ 747 $replace = floor($this->StylePctl);875 $replace = round($this->StylePctl); 748 876 } 749 877 break; -
beer-ratings/trunk/index.php
r572598 r573675 4 4 Plugin URI: http://www.jamesewelch.com/wp-beer-ratings 5 5 Description: A plugin to show beer, brewer, and place information using RateBeer.com's API 6 Version: 1.0 6 Version: 1.0.1 7 7 Author: James Welch 8 8 Author URI: http://www.jamesewelch.com … … 46 46 register_activation_hook( __FILE__, array( 'BeerRatings', 'activate_plugin' ) ); 47 47 register_deactivation_hook( __FILE__, array( 'BeerRatings', 'deactivate_plugin' ) ); 48 48 register_uninstall_hook( __FILE__, array( 'BeerRatings', 'uninstall_plugin' ) ); 49 49 50 /* ---------------------------------- */ 50 51 /* add short codes */ … … 62 63 add_shortcode( 'beerratings-beer-place', array( 'BeerRatings_Shortcode', 'beerratings_beer_place') ); 63 64 add_shortcode( 'beerratings-beer-brewer', array( 'BeerRatings_Shortcode', 'beerratings_beer_brewer') ); 65 64 66 add_shortcode( 'beerratings-beer', array( 'BeerRatings_Shortcode', 'beerratings_beer_info') ); 67 65 68 add_shortcode( 'beerratings-bestbeer-style', array ( 'BeerRatings_Shortcode', 'beerratings_bestbeer_style') ); 69 add_shortcode( 'beerratings-bestbeer-season', array ( 'BeerRatings_Shortcode', 'beerratings_bestbeer_season') ); 70 add_shortcode( 'beerratings-bestbeer-country', array ( 'BeerRatings_Shortcode', 'beerratings_bestbeer_country') ); 66 71 67 72 /* ---------------------------------- */ -
beer-ratings/trunk/readme.txt
r572795 r573675 5 5 Requires at least: 3.0 6 6 Tested up to: 3.4 7 Stable tag: 1.0 7 Stable tag: 1.0.1 8 8 License: GPLv2 ror later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 101 101 = 1.0 = 102 102 * initial upload to WordPress plugin gallery 103 103 104 = 1.0.1 = 105 * Updated help page for #_STYLEPCTL 106 * Updated help page for #_OVERALLPCTL 107 * Updated default item format for [beerratings-beer] to use conditionals around overall and style percentages 108 * Updated various tags using 'limit' and 'show_retired' attributes to not count retired as part of limit when show_retired='false'. 109 * Added [beerratings-bestbeer-country] tag and help documentation 110 * Added [beerratings-bestbeer-season] tag and help documentation 111 104 112 == Upgrade Notice == 105 113
Note: See TracChangeset
for help on using the changeset viewer.