diff --git a/features/awardsList.feature b/features/awardsList.feature new file mode 100644 index 0000000..e4d99d0 --- /dev/null +++ b/features/awardsList.feature @@ -0,0 +1,10 @@ +Feature: + As a visitor + I want to see a list of awards + So that I can learn what beers are successful + +Scenario: Empty List + Given there are no awards + When I go to the page "awardsList" + Then I should see "Awards-Competitions" + And I should see "There are currently no awards/competition entries in the database." \ No newline at end of file diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 0aacf5b..020e9b9 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -36,7 +36,7 @@ class FeatureContext extends MinkContext * Opens specified regular brewblogger page (not URL). * * @Given /^(?:|I )am on the page "(?P[^"]+)"$/ - * @When /^(?:|I )go to page "(?P[^"]+)"$/ + * @When /^(?:|I )go to the page "(?P[^"]+)"$/ */ public function goToBrewBloggerPage($page) { @@ -57,4 +57,13 @@ class FeatureContext extends MinkContext throw new \Behat\Mink\Exception\ExpectationException($message, $this->getSession()); } } + + + /** + * @Given /^there are no awards$/ + */ + public function thereAreNoAwards() + { + // Nothing to do here yet + } } diff --git a/features/calculators.feature b/features/calculators.feature new file mode 100644 index 0000000..a7cc678 --- /dev/null +++ b/features/calculators.feature @@ -0,0 +1,11 @@ +Feature: + As a brewer + I want to use calculators + So that I can work on beer recipes + +#Scenario: Calculator homepage +# Given I am on the page "tools" +# When I select "Force Carbonation Calculator" from "jumpMenu" +# Then I should be on the page "tools" +# And I should see "Saturation by Style" + diff --git a/features/login.feature b/features/login.feature index fc2a702..d29b665 100644 --- a/features/login.feature +++ b/features/login.feature @@ -3,7 +3,7 @@ Feature: I want to log in So that I can update the site -Scenario: +Scenario: Login Given I am on the page "login" When I fill in "loginUsername" with "nonpriv" And I fill in "loginPassword" with "user" diff --git a/index.php b/index.php index 8c08200..b5fa112 100644 --- a/index.php +++ b/index.php @@ -159,15 +159,13 @@ if (($page == "brewBlogCurrent") || ($page == "brewBlogDetail")) { $content .= include(SECTIONS . 'recipeList.inc.php'); $tplVars['page_title'] = 'Recipes'; } elseif ($page == "awardsList") { - ob_start(); - include(SECTIONS . 'awardsList.inc.php'); - $content .= ob_get_clean(); + $content .= include(SECTIONS . 'awardsList.inc.php'); + $tplVars['page_title'] = 'Awards-Competitions'; } elseif ($page == "login") { $content .= include(SECTIONS . 'login.inc.php'); } elseif ($page == "tools") { - ob_start(); - include(SECTIONS . 'tools.inc.php'); - $content .= ob_get_clean(); + $tplVars['page_title'] = 'Calculators'; + $content .= include(SECTIONS . 'tools.inc.php'); } elseif ($page == "about") { $content .= include(SECTIONS . 'about.inc.php'); $tplVars['page_title'] = 'About'; diff --git a/sections/awardsList.inc.php b/sections/awardsList.inc.php index 53bd443..62d90e3 100644 --- a/sections/awardsList.inc.php +++ b/sections/awardsList.inc.php @@ -1,75 +1,51 @@ - -
- - - - - -
There are currently no awards/competition entries in the database.

-
- - - - - - - "; ?> - - - - - - - - - - > - \"Edit"; else echo ""; } ?> - - - - - - - - - - - - - -
">
$display) echo "   •"; if ($view == "all") echo "   •   "; if ($total > $display) { echo "   "; paginate($display, $pg, $total); if ($view == "limited") { ?>   •   Entire List of Awards/Competition EntriesLimited List of Award/Competition Entries
Entered Name Sort AscendingSort DescendingStyle Sort AscendingSort DescendingCompetition Sort AscendingSort DescendingDate Sort AscendingSort DescendingPlace Sort AscendingSort DescendingBrewer Sort AscendingSort Descending
 Detail&filter=&id="> - - " border="0"/>
">
$display) echo "   •"; if ($view == "all") echo "   •   "; if ($total > $display) { echo "   "; paginate($display, $pg, $total); if ($view == "limited") { ?>   •   Entire List of Awards/Competition EntriesLimited List of Award/Competition Entries
- - + $filter, + 'view' => $view, + 'display' => $display, + 'image_src' => $imageSrc, + 'sort' => $sort, + 'dir' => $dir, + 'pg' => $pg, + 'pref' => $row_pref, + 'user' => $user, + 'user2' => isset($user2) ? : null, + 'login_username' => isset($_SESSION["loginUsername"]) ? : null, + 'color1' => $color1, + 'color2' => $color2, +); + +ob_start(); +paginate($display, $pg, $total); +$pageVars['paginate'] = ob_get_clean(); + +$pageVars['awards'] = array(); +do { + if (empty($row_awardsList)) { + continue; + } + $award = $row_awardsList; + + // Get brew style information for all listed styles + mysql_select_db($database_brewing, $brewing); + $query_styles = sprintf("SELECT * FROM styles WHERE brewStyle='%s'", $row_awardsList['awardStyle']); + $styles = mysql_query($query_styles, $brewing) or die(mysql_error()); + $row_styles = mysql_fetch_assoc($styles); + $totalRows_styles = mysql_num_rows($styles); + ob_start(); + include('reference/styles.inc.php'); + $award['style_include'] = ob_get_clean(); + + // Get real user names + mysql_select_db($database_brewing, $brewing); + $query_user2 = sprintf("SELECT * FROM users WHERE user_name = '%s'", $row_awardsList['brewBrewerID']); + $user2 = mysql_query($query_user2, $brewing) or die(mysql_error()); + $row_user2 = mysql_fetch_assoc($user2); + $totalRows_user2 = mysql_num_rows($user2); + $award['user'] = $row_user2; + + $pageVars['awards'][] = $award; +} while ($row_awardsList = mysql_fetch_assoc($awardsList)); + +return $twig->render('awardsList.html.twig', $pageVars); \ No newline at end of file diff --git a/sections/tools.inc.php b/sections/tools.inc.php index dfc5ce0..3217b69 100644 --- a/sections/tools.inc.php +++ b/sections/tools.inc.php @@ -1,95 +1,30 @@ - - - - - - - - - - -
Choose: -
- -
-
- -
-
-Bitterness Calculator"; - else - echo "Bitterness Calculator"; - echo ' | '; - if ($section == "efficiency") - echo "Brewhouse Efficiency Calculator"; - else - echo "Brewhouse Efficiency Calculator"; - echo ' | '; - if ($section == "calories") - echo "Calories, Alcohol, and Plato Calculator"; - else - echo "Calories, Alcohol, and Plato Calculator"; - echo ' | '; - if ($section == "force_carb") - echo "Force Carbonation Calculator"; - else - echo "Force Carbonation Calculator"; - echo '
'; +$pageVars = array( + 'current_section' => $section, + 'sections' => array( + 'bitterness' => 'Bitterness Calculator', + 'efficiency' => 'Brewhouse Efficiency Calculator', + 'calories' => 'Calories, Alcohol, and Plato Calculator', + 'force_carb' => 'Force Carbonation Calculator', + 'plato' => 'Plato/Brix/SG Calculator', + 'sugar' => 'Priming Sugar Calculator', + 'strike' => 'Strike Water Temperature Calculator', + 'water' => 'Water Amounts Calculator', + 'hyd' => 'Hydrometer Correction Calculator', + ), +); - // Second row - if ($section == "plato") - echo "Plato/Brix/SG Calculator"; - else - echo "Plato/Brix/SG Calculator"; - echo ' | '; - if ($section == "sugar") - echo "Priming Sugar Calculator"; - else - echo "Priming Sugar Calculator"; - echo ' | '; - if ($section == "strike") - echo "Strike Water Temperature Calculator"; - else - echo "Strike Water Temperature Calculator"; - echo ' | '; - if ($section == "water") - echo "Water Amounts Calculator"; - else - echo "Water Amounts Calculator"; - echo ' | '; - if ($section == "hyd") - echo "Hydrometer Correction Calculator"; - else - echo "Hydrometer Correction Calculator"; -?> -
+ob_start(); +if ($section == "calories") include (ADMIN_TOOLS.'gravity.php'); +elseif ($section == "bitterness") include (ADMIN_TOOLS.'bitterness.php'); +elseif ($section == "efficiency") include (ADMIN_TOOLS.'efficiency.php'); +elseif ($section == "water") include (ADMIN_TOOLS.'water_amounts.php'); +elseif ($section == "sugar") include (ADMIN_TOOLS.'priming.php'); +elseif ($section == "force_carb") include (ADMIN_TOOLS.'force_carb.php'); +elseif ($section == "plato") include (ADMIN_TOOLS.'sg.php'); +elseif ($section == "strike") include (ADMIN_TOOLS.'strike.php'); +elseif ($section == "hyd") include (ADMIN_TOOLS.'hydrometer.php'); +$pageVars['content'] = ob_get_clean(); +return $twig->render('tools.html.twig', $pageVars); diff --git a/twig/awardsList.html.twig b/twig/awardsList.html.twig new file mode 100644 index 0000000..8f77e43 --- /dev/null +++ b/twig/awardsList.html.twig @@ -0,0 +1,94 @@ +{% set total = awards|length %} +
+ {% if awards is empty %} + + + + +
There are currently no awards/competition entries in the database{% if filter != "all" %} for this member{% endif %}.

+
+{% else %} + {{ dump(awards) }} + {% if filter == "defualt" %} + {% set columns = 7 %} + {% else %} + {% set columns = 8 %} + {% endif %} + + + + + + {% if login_username is not empty %}{% endif %} + + + + + + {% if (pref.mode == "2") and (filter != "all") %}{% endif %} + + {% for award in awards %} + + {% if login_username is not empty %} + {% if (user.userLevel == "1") or (recipe.brewBrewerID == login_username) %} + + {% else %} + + {% endif %} + {% endif %} + + + + + + + {% if (pref.mode == "2") and (filter != "all") %}{% endif %} + + {% endfor %} + + + +
+ {{ total }} Total Awards/Competition Entries + {% if total > display %}echo "   •";{% endif %} + {% if view == "all" %}   •   {% endif %} + {% if total > display %} +     + {{ paginate }} + {% if view == "limited" %} +    •   Entire List of + {% if (pref.mode == "2") and (filter != "all") %}{{ user2.realFirstName }}'s {% endif %} + Awards/Competition Entries + {% endif %} + {% endif %} + {% if view == "all" %} + Limited List of + {% if (pref.mode == "2") and (filter != "all") %}{{ user2.realFirstName }}'s {% endif %} + Award/Competition Entries + {% endif %} +
Entered Name Sort AscendingSort DescendingStyle Sort AscendingSort DescendingCompetition Sort AscendingSort DescendingDate Sort AscendingSort DescendingPlace Sort AscendingSort DescendingBrewer Sort AscendingSort Descending
Edit {{ award.awardBrewName }} {{ award.awardBrewName }} + + {% if award.awardContestURL is not empty %}{% endif %}{{ award.awardContest }}{% if award.awardContestURL is not empty %}{% endif %}{{ award.awardDate|date("M j, Y") }}{% if award.awardPlace == "best" %}Best In Show{% elseif award.awardPlace == "1" %}1st (Gold){% elseif award.awardPlace == "2" %}2nd (Silver){% elseif award.awardPlace == "3" %}3rd (Bronze){% elseif award.awardPlace == "honMen" %}Honorable Mention{% else %}Entry Only{% endif %}{{ award.user.realFirstName }} {{ award.user.realLastName }}
+ {{ total }} Total Awards/Competition Entries + {% if total > display %}echo "   •";{% endif %} + {% if view == "all" %}   •   {% endif %} + {% if total > display %} +     + {{ paginate }} + {% if view == "limited" %} +    •   Entire List of + {% if (pref.mode == "2") and (filter != "all") %}{{ user2.realFirstName }}'s {% endif %} + Awards/Competition Entries + {% endif %} + {% endif %} + {% if view == "all" %} + Limited List of + {% if (pref.mode == "2") and (filter != "all") %}{{ user2.realFirstName }}'s {% endif %} + Award/Competition Entries + {% endif %} +
+ +{% endif %} \ No newline at end of file diff --git a/twig/tools.html.twig b/twig/tools.html.twig new file mode 100644 index 0000000..fa09502 --- /dev/null +++ b/twig/tools.html.twig @@ -0,0 +1,41 @@ + + {% if not checkmobile %} + + + + + + {% endif %} + + + +
Choose: +
+ +
+
+ {{ content }} +
+
+ {# Maybe move to batch? #} + {% for section, name in sections -%} + {%- if section == current_section -%} + {{ name }} + {%- else -%} + {{ name }} + {%- endif -%} + + {%- if section == "force_carb" -%} +
+ {%- elseif section == "hyd" -%}{# no output#} + {%- else -%} +  |  + {%- endif -%} + {%- endfor %} +
+