Plugin Directory

Changeset 573675


Ignore:
Timestamp:
07/17/2012 05:27:47 PM (14 years ago)
Author:
jamesewelch
Message:

1.0.1 Upload

Location:
beer-ratings/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • beer-ratings/trunk/assets/html/settings-help.html

    r572597 r573675  
    9696        <tr>
    9797          <td><b>#_OVERALLPCTL</b></td>
    98           <td>The overall percentage (rank among all beers).
     98          <td>The overall percentage represents a beer’s performance
     99           relative to all beers on an adjusted percentile basis.
    99100          This value will display full precision of the percentage
    100101          (up to 10 places to the right of the decimal).
    101102          To round the value, use #_OVERALLPCTL0. For 1 or 2 places
    102103          of precision use #_OVERALLPCTL1 or #_OVERALLPCTL2.
    103           Please note that #_OVERALLPCTL0 will not round to a whole
    104           number, so values such as 99.85 will render as 99 and not 100
    105           (just like on RateBeer.com).         
    106104          </td>
    107105        </tr>
    108106        <tr>
    109107          <td><b>#_STYLEPCTL</b></td>
    110           <td>The style percentage (rank among beers with same style).
     108          <td>The style percentage represents a beer’s performance relative
     109           to its peers in the same beer style category on an
     110           adjusted percentile basis.
    111111          This value will display full precision of the percentage
    112112          (up to 10 places to the right of the decimal).
    113113          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.
    118115          </td>
    119116        </tr>
     
    284281          (up to 10 places to the right of the decimal).
    285282          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>
    290285        </tr>
    291286        <tr>
     
    295290              <tr>
    296291          <td><b>#_OVERALLPCTL</b></td>
    297           <td>The overall percentage (rank among all beers).
     292          <td>The overall percentage represents a beer’s performance
     293           relative to all beers on an adjusted percentile basis.
    298294          This value will display full precision of the percentage
    299295          (up to 10 places to the right of the decimal).
    300296          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.         
    305298          </td>
    306299        </tr>
    307300        <tr>
    308301          <td><b>#_STYLEPCTL</b></td>
    309           <td>The style percentage (rank among beers with same style).
     302          <td>The style percentage represents a beer’s performance relative
     303           to its peers in the same beer style category on an
     304           adjusted percentile basis.
    310305          This value will display full precision of the percentage
    311306          (up to 10 places to the right of the decimal).
    312307          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.
    317309          </td>
    318310        </tr>
     
    428420          To round the value, use #_AVERAGERATING0. For 1 or 2 places
    429421          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>
    433423        </tr>
    434424        <tr>
     
    542532    </div>
    543533  </div>
    544  
    545   <!--
     534   
    546535  <h3 class="rb-toggleHeader"><a href="#">Best Beer (By Country) Placeholders [beerratings-bestbeer-country]</a></h3>
    547536  <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"> 
    552538       <h4>Description</h4>
    553        <p>Show best beers 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>
    554540       <h4>How to find the Country ID</h4>
    555541       <ol>
     
    568554          <dt>show_retired (optional)</dt>
    569555          <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>
    570560       </dl> 
    571561       <code>[beerratings-bestbeer-country id='213']</code>
    572        <p>You may also enter multiple style IDs 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>
    574564       <h4>API Test</h4>
    575565       <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=213
     566          http://www.ratebeer.com/json/tb.asp?k=YOUR_API_KEY&m=country&c=213
    577567       </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>
    578583       <h4>Output Fields</h4>
    579584       <table class="form-table">                       
     
    585590            <td><b>#_BEERNAME</b></td>
    586591            <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>
    595617          </tr>
    596618          <tr>
     
    609631            <td><b>#_BEERIMAGE</b></td>
    610632            <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>
    615714          </tr>
    616715           <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>
    617732          <td><b>#_BREWERLINK</b></td>
    618733          <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>   
    620735         <tr>
    621736          <td><b>#_BREWERIMAGEURL</b></td>
     
    625740          <td><b>#_BREWERIMAGE</b></td>
    626741          <td>An image HTML tag usingthe RateBeer.com brewer image (uses #_BREWERIMAGE as src and #_BREWERNAME as alt values).</td>
    627         </tr>   
     742        </tr>          
    628743        </table>
    629744    </div>
    630745  </div>
    631 -->
    632746 
    633747  <h3 class="rb-toggleHeader"><a href="#">Beer Review Placeholders [beerratings-beer-review]</a></h3>
  • beer-ratings/trunk/includes/BeerRatings.php

    r572597 r573675  
    8181      add_option('beerratings_beerlist_byplace_item',
    8282"<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}
    8484</li>" );
    8585
     
    113113         
    114114      // 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     
    128136          // beer by id
    129137      add_option('beerratings_beerlist_header', "<div class='beerratings_beer_list'>");
     
    131139      add_option('beerratings_beerlist_item',
    132140"<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} 
    137145</div>" );
    138146
     
    170178    }
    171179
    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!
    174185    */   
    175186    function deactivate_plugin() {
     187    }
     188     
     189    /*
     190    * Uninstall the plugin, remove saved options from db
     191    */   
     192    function uninstall_plugin() { 
     193 
    176194        delete_option('beerratings_ratebeer_apikey');
    177195        delete_option('beerratings_cachetime');
     
    206224        delete_option('beerratings_beerlist_bystyle_footer');
    207225       
    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               
    212234        delete_option('beerratings_placelist_header');
    213235        delete_option('beerratings_placelist_item');
     
    225247    $apiKey = get_option('beerratings_ratebeer_apikey');
    226248    if( empty( $apiKey ) ) {
    227         echo '<div class="error">
     249        echo '<div class="error fade">
    228250           <p>Beer Ratings Plugin: You must enter a valid RateBeer API Key.</p>
    229251        </div>';
  • beer-ratings/trunk/includes/BeerRatings_Settings.php

    r572597 r573675  
    229229                 update_option('beerratings_beerlist_bystyle_footer', htmlspecialchars_decode( $_POST['beerratings_beerlist_bystyle_footer']) );
    230230                 
    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                                 
    235239                 update_option('beerratings_placelist_header', htmlspecialchars_decode( $_POST['beerratings_placelist_header']) );
    236240                 update_option('beerratings_placelist_item', htmlspecialchars_decode( $_POST['beerratings_placelist_item']) );
     
    354358              </div>
    355359             
    356               <!--
     360             
    357361              <h3 class="rb-toggleHeader"><a href="#">Best Beer (By Country) Listings [beerratings-bestbeer-country]</a></h3>
    358362              <div style="display: block;" class="rb-toggleContainer">
     
    374378                 </div>
    375379              </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             
    377401             
    378402              <h3 class="rb-toggleHeader"><a href="#">Beer Review Listings [beerratings-beer-review]</a></h3>
  • beer-ratings/trunk/includes/BeerRatings_Shortcode.php

    r572597 r573675  
    125125     
    126126  /*
    127     * [beerratings-beer-style id='X']
     127    * [beerratings-bestbeer-style id='X']
    128128    */
    129129  function beerratings_bestbeer_style( $attrs, $content = null) {
     
    144144   
    145145  /*
    146     * [beerratings-beer-country id='X']
     146    * [beerratings-bestbeer-country id='X']
    147147    */
    148148  function beerratings_bestbeer_country( $attrs, $content = null) {
     
    162162  }
    163163     
     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 
    164184  /*
    165185    * [beerratings-beer-review id='X']
  • beer-ratings/trunk/includes/RateBeer/RateBeer_Beer.php

    r572597 r573675  
    3838            var $TimeEntered;
    3939            var $IsOut;
     40            var $BeerStyleID;
    4041            var $BeerStyleName;
    4142            var $IBU;
     
    7172    $this->IsOut = $beerInfo->IsOut;
    7273   
     74    $this->BeerStyleID = $beerInfo->BeerStyleID;
    7375    $this->BeerStyleName = $beerInfo->BeerStyleName;
     76   
    7477    $this->IBU = $beerInfo->IBU;
    7578    $this->Description = RateBeer::remove_notes($beerInfo->Description);
     
    8083    $this->BrewerImageURL = $this->get_brewer_image_url($beerInfo->BrewerID);
    8184     
     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     }
    8292    }
    8393
     
    122132        return $output;
    123133    }
    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         
    134191    /*
    135192    * 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']
    138194    */     
    139195  function get_best_beer_by_countryid( $attrs, $content = null) {
     
    141197        $country_ids = explode( ",", $attrs['id'] );
    142198        $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     
    149202        if( isset($attrs['show_retired'])){
    150203      if( $attrs['show_retired'] == 'false' ) {
     
    153206        }
    154207       
     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         
    155221        // if array of ids, then loop
    156222        if ( is_array( $country_ids ) ) {
     
    160226            // start looping
    161227            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 );               
    163229                if ($beers->error) {
    164230                    return;
     
    166232               
    167233                if (is_array($beers)) {     
     234                  $counter = 0;
    168235          foreach ( $beers as $beer ) {
     236           if($counter >= $limit){
     237              break; // exit foreach
     238            }
     239           
    169240            // assign vars
    170241            $this->set_beer_fields($beer);
     
    174245            } else {
    175246              // get layout
     247              $counter += 1;
    176248              $layout = stripslashes( get_option('beerratings_beerlist_bycountry_item') );
    177249              $output .= $this->apply_layout($layout);               
     
    234306            if($counter >= $limit){
    235307              break; // exit foreach
    236             }
    237             $counter += 1;
     308            }
    238309           
    239310            // assign vars           
     
    245316            } else {
    246317              // get layout
     318              $counter += 1;
    247319              $layout = stripslashes( get_option('beerratings_beerlist_bystyle_item') );
    248320              $output .= $this->apply_layout($layout);
     
    370442        return $output;
    371443  }
     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 }
    372548   
    373549  /*
     
    402578        return $beer_info;
    403579 }
    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   
    453581  /*
    454582  * Make JSON/API call for [beerratings-beer-style id='X']
     
    703831        case '#_AVERAGERATING0': 
    704832          if(!empty($this->AverageRating)){
    705             $replace = floor($this->AverageRating);
     833            $replace = round($this->AverageRating);
    706834          }
    707835          break;
     
    726854        case '#_OVERALLPCTL0': 
    727855          if(!empty($this->OverallPctl)){
    728             $replace = floor($this->OverallPctl);
     856            $replace = round($this->OverallPctl);
    729857          }
    730858          break;
     
    745873        case '#_STYLEPCTL0': 
    746874          if(!empty($this->StylePctl)){
    747             $replace = floor($this->StylePctl);
     875            $replace = round($this->StylePctl);
    748876          }
    749877          break; 
  • beer-ratings/trunk/index.php

    r572598 r573675  
    44   Plugin URI: http://www.jamesewelch.com/wp-beer-ratings
    55   Description: A plugin to show beer, brewer, and place information using RateBeer.com's API
    6    Version: 1.0
     6   Version: 1.0.1
    77   Author: James Welch
    88   Author URI: http://www.jamesewelch.com
     
    4646register_activation_hook( __FILE__, array( 'BeerRatings', 'activate_plugin' ) );
    4747register_deactivation_hook( __FILE__, array( 'BeerRatings', 'deactivate_plugin' ) );
    48  
     48register_uninstall_hook( __FILE__, array( 'BeerRatings', 'uninstall_plugin' ) );
     49
    4950 /* ---------------------------------- */ 
    5051/* add short codes                     */
     
    6263add_shortcode( 'beerratings-beer-place', array( 'BeerRatings_Shortcode', 'beerratings_beer_place') );   
    6364add_shortcode( 'beerratings-beer-brewer', array( 'BeerRatings_Shortcode', 'beerratings_beer_brewer') );
     65
    6466add_shortcode( 'beerratings-beer', array( 'BeerRatings_Shortcode', 'beerratings_beer_info') );
     67
    6568add_shortcode( 'beerratings-bestbeer-style', array ( 'BeerRatings_Shortcode', 'beerratings_bestbeer_style') );
     69add_shortcode( 'beerratings-bestbeer-season', array ( 'BeerRatings_Shortcode', 'beerratings_bestbeer_season') ); 
     70add_shortcode( 'beerratings-bestbeer-country', array ( 'BeerRatings_Shortcode', 'beerratings_bestbeer_country') ); 
    6671 
    6772/* ---------------------------------- */ 
  • beer-ratings/trunk/readme.txt

    r572795 r573675  
    55Requires at least: 3.0
    66Tested up to: 3.4
    7 Stable tag: 1.0
     7Stable tag: 1.0.1
    88License: GPLv2 ror later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    101101= 1.0 =
    102102* 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
    104112== Upgrade Notice ==
    105113 
Note: See TracChangeset for help on using the changeset viewer.