Merge branch 'master' of /home/arun/nubati.net/git/e-DoKo
[e-DoKo.git] / include / output.php
index 61fef6004fbe5d60d8c1087ec5db8ad54edc1570..a4b84a0e738d0a85246994c33bf0f13ef8aca504 100644 (file)
@@ -1,4 +1,23 @@
 <?php
+/* Copyright 2006, 2007, 2008, 2009, 2010 Arun Persaud <arun@nubati.net>
+ *
+ *   This file is part of e-DoKo.
+ *
+ *   e-DoKo is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   e-DoKo is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with e-DoKo.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
 /* make sure that we are not called from outside the scripts,
  * use a variable defined in config.php to check this
  */
@@ -12,16 +31,18 @@ function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
   global $RULES;
 
   echo "<div class=\"message\">\n<form action=\"index.php?action=new\" method=\"post\">\n";
-  echo "Do you want to continue playing?(This will start a new game, with $playerD as dealer.)\n";
+  $output = sprintf(_('Do you want to continue playing? (This will start a new game, with %s starting the game.)'),$playerA);
+  echo $output."\n";
   echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
   echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
   echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
-  echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES["dullen"]."\" />\n";
-  echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES["schweinchen"]."\" />\n";
-  echo "  <input type=\"hidden\" name=\"callrule\" value=\"".$RULES["call"]."\" />\n";
+  echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES['dullen']."\" />\n";
+  echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES['schweinchen']."\" />\n";
+  echo "  <input type=\"hidden\" name=\"callrule\" value=\"".$RULES['call']."\" />\n";
+  echo "  <input type=\"hidden\" name=\"lowtrump\" value=\"".$RULES['lowtrump']."\" />\n";
   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
-  echo "  <input type=\"submit\" value=\"keep playing\" />\n";
+  echo "  <input type=\"submit\" value=\""._('keep playing')."\" />\n";
   echo "</form>\n</div>";
   return;
 }
@@ -32,13 +53,10 @@ function output_form_for_new_game($names)
                         * after we selected them to make sure that each name
                         * only shows up once
                         */
-?>
-  <form action="index.php?action=new" method="post">
-    <h2> Select players (Remember: you need to be one of the players) </h2>
-
-   <div class="table">
-     <img class="table" src="pics/table.png" alt="table" />
-<?php
+  echo '  <form action="index.php?action=new" method="post">';
+  echo '    <h2> '._('Select players (Remember: you need to be one of the players)').' </h2>';
+  echo '   <div class="table">';
+  echo '     <img class="table" src="pics/table.png" alt="table" />';
 
   /* ask player for names */
 
@@ -77,42 +95,51 @@ function output_form_for_new_game($names)
        }
       echo "       </select>\n     </div>\n";
     }
-?>
-    </div>
-
-     <h2 class="rules">Rules</h2>
-     <h3>Gameplay-related</h3>
-     <h4>Ten of hearts:</h4>
-     <p>
-       <select name="dullen">
-         <option value="none"> just normal non-trump  </option>
-         <option value="firstwins"> first ten of hearts wins the trick </option>
-         <option value="secondwins" selected="selected"> second ten of hearts wins the trick </option>
-       </select>
-     </p>
-     <h4>Schweinchen (both foxes), only in normal games or silent solos:</h4>
-     <p>
-       <select name="schweinchen">
-         <option value="none" selected="selected"> none </option>
-        <option value="both"> both become highest trump (automatic call at beginning of the game)   </option>
-        <option value="second"> first one normal, second one becomes highest (call during the game) </option>
-        <option value="secondaftercall">  second one become highest only in case re/contra was announced
-        </option>
-       </select>
-     </p>
-     <h4>Call Re/Contra, etc.:</h4>
-     <p>
-       <select name="callrule">
-        <option value="1st-own-card" selected="selected">  Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</option>
-        <option value="5th-card">  Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</option>
-        <option value="9-cards" > Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</option>
-       </select>
-     </p>
-     <h3>Scoring-related</h3>
-     <h4>(not yet implemented)</h4>
-     <p><input type="submit" value="start game"></p>
-     </form>
-<?php
+
+    echo '    </div>';
+    echo '';
+    echo '     <h2 class="rules">'._('Rules').'</h2>';
+    echo '     <h3>'._('Gameplay-related').'</h3>';
+    echo '     <h4>'._('Ten of hearts').':</h4>';
+    echo '     <p>';
+    echo '       <select name="dullen">';
+    echo '         <option value="none"> '._('just normal non-trump').'  </option>';
+    echo '         <option value="firstwins"> '._('first ten of hearts wins the trick').' </option>';
+    echo '         <option value="secondwins" selected="selected"> '.('second ten of hearts wins the trick').' </option>';
+    echo '       </select>';
+    echo '     </p>';
+    echo '     <h4>'._('Schweinchen (both foxes), only in normal games or silent solos').':</h4>';
+    echo '     <p>';
+    echo '       <select name="schweinchen">';
+    echo '         <option value="none" selected="selected"> '._('none').' </option>';
+    echo '      <option value="both"> '._('both become highest trump (automatic call at beginning of the game)').'   </option>';
+    echo '      <option value="second"> '._('first one normal, second one becomes highest (call during the game)').' </option>';
+    echo '      <option value="secondaftercall">  ',_('second one become highest only in case re/contra was announced');
+    echo '      </option>';
+    echo '       </select>';
+    echo '     </p>';
+    echo '     <h4>'._('Call Re/Contra, etc.').':</h4>';
+    echo '     <p>';
+    echo '       <select name="callrule">';
+    echo '      <option value="1st-own-card" selected="selected">  '._('Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.').'</option>';
+    echo '      <option value="5th-card"> '._('Can call re/contra until 5th card is played, 90 until 9th card is played, etc.').'</option>';
+    echo '      <option value="9-cards" > '._('Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.').'</option>';
+    echo '       </select>';
+    echo '     </p>';
+    echo '     <h4>'._('Low trump').'</h4>';
+    echo '     <p>';
+    echo '       '._('Player can\'t trump a fox, that is none of his trump is higher than a fox.');
+    echo '       <select name="lowtrump">';
+    echo '      <option value="poverty">'._('The trump will be treated as poverty and offered to another player.').'</option>';
+    echo '      <option value="cancel"> '._('The game will be canceled unless there is a solo.').'</option>';
+    echo '      <option value="none">   '._('Bad luck, the player needs to play a normal game.').'</option>';
+    echo '       </select>';
+    echo '     </p>';
+    echo '     <h3>'._('Scoring-related').'</h3>';
+    echo '     <h4>'._('(not yet implemented)').'</h4>';
+    echo '     <p><input type="submit" value="'._('start game').'"></p>';
+    echo '     </form>';
+
 }
 
 function output_table($data,$caption="",$class="",$id="")
@@ -186,59 +213,78 @@ function display_link_card($card,$dir="english",$type="card")
 
 function output_check_for_sickness($me,$mycards)
 {
- ?>
-  <div class="sickness"> Thanks for joining the game...<br />
-
-    do you want to play solo?
-    <select name="solo" size="1">
-      <option selected="selected">No</option>
-      <option>trumpless</option>
-      <option>trump</option>
-      <option>queen</option>
-      <option>jack</option>
-      <option>club</option>
-      <option>spade</option>
-      <option>heart</option>
-    </select>
-    <br />
-
- <?php
-
-  echo "Wedding?";
+  global $RULES;
+
+  echo '  <div class="sickness"> '._('Thanks for joining the game').'...<br />';
+  echo '';
+  echo '    '._('Do you want to play solo?').'';
+  echo '    <select name="solo" size="1">';
+  echo '      <option selected="selected">'.'No'.'</option>';
+  echo '      <option>'.'trumpless'.'</option>';
+  echo '      <option>'.'trump'.'</option>';
+  echo '      <option>'.'queen'.'</option>';
+  echo '      <option>'.'jack'.'</option>';
+  echo '      <option>'.'club'.'</option>';
+  echo '      <option>'.'spade'.'</option>';
+  echo '      <option>'.'heart'.'</option>';
+  echo '    </select>';
+  echo '    <br />';
+
+  echo _('Wedding?');
   if(check_wedding($mycards))
      {
-       echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
-       echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
+       echo ' '._('yes')."<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
+       echo ' '._('no')." <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
      }
    else
      {
-       echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
+       echo ' '._('no')." <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
      };
 
-  echo "Do you have poverty?";
+  echo _('Do you have poverty?');
   if(count_trump($mycards)<4)
     {
-      echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
-      echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
+      echo ' '._('yes')."<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
+      echo ' '._('no')." <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
     }
   else
     {
-      echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
+      echo ' '._('no')." <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
     };
 
-   echo "Do you have too many nines?";
+  echo _('Do you have too many nines?');
   if(count_nines($mycards)>4)
      {
-       echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
-       echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
+       echo ' '._('yes')."<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
+       echo ' '._('no')." <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
      }
    else
      {
-       echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
+       echo ' '._('no')." <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
      };
 
+  if($RULES['lowtrump']=='cancel' || $RULES['lowtrump']=='poverty')
+    {
+      if($RULES['lowtrump']=='cancel')
+       echo _('Do you have low trump (cancel game)?');
+      else
+       echo _('Do you have low trump (poverty)?');
+
+      if(check_low_trump($mycards))
+       {
+         echo ' '._('yes')."<input type=\"radio\" name=\"lowtrump\" value=\"yes\" checked=\"checked\" />";
+         echo ' '._('no')." <input type=\"radio\" name=\"lowtrump\" value=\"no\" /> <br />\n";
+       }
+      else
+       {
+         echo ' '._('no')." <input type=\"hidden\" name=\"lowtrump\" value=\"no\" /> <br />\n";
+       };
+    }
+  else
+    echo "<input type=\"hidden\" name=\"lowtrump\" value=\"no\" />";
+
    echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
-   echo "<input type=\"submit\" value=\"count me in\" />\n";
+   echo "<input type=\"submit\" value=\""._('count me in')."\" />\n";
 
    echo "</div>\n";
 
@@ -247,74 +293,72 @@ function output_check_for_sickness($me,$mycards)
 
 function output_form_calls($me,$myparty)
 {
-  $highstart = "<span class=\"highcall\">";
-  $highend   = "</span>";
+  $highstart = '  <span class="highcall">';
+  $highend   = '</span>';
 
   $tmp = can_call(120,$me);
   if( $tmp )
     {
       if($tmp==2) echo $highstart;
       if($myparty=='re')
-       echo "re (120):";
+       echo '  re (120):';
       else if ($myparty=='contra')
-       echo "contra (120):";
+       echo '  contra (120):';
       else
-       echo " re/contra (120):";
-      echo " <input type=\"radio\" name=\"call\" value=\"120\" />";
+       echo '  re/contra (120):';
+      echo ' <input type="radio" name="call" value="120" />';
       if($tmp==2) echo $highend;
-      echo "<br />\n";
+      echo "\n";
     }
-  $tmp =  can_call(90,$me);
+  $tmp = can_call(90,$me);
   if( $tmp )
     {
       if($tmp==2) echo $highstart;
-      echo " 90:".
-       " <input type=\"radio\" name=\"call\" value=\"90\" />";
+      echo '  90:'.
+       ' <input type="radio" name="call" value="90" />';
       if($tmp==2) echo $highend;
-      echo "<br />\n";
+      echo "\n";
     }
   $tmp = can_call(60,$me);
   if( $tmp )
     {
       if($tmp==2) echo $highstart;
-      echo " 60:".
-       " <input type=\"radio\" name=\"call\" value=\"60\" />";
+      echo '  60:'.
+       ' <input type="radio" name="call" value="60" />';
       if($tmp==2) echo $highend;
-      echo "<br />\n";
+      echo "\n";
     }
   $tmp = can_call(30,$me);
   if( $tmp )
     {
       if($tmp==2) echo $highstart;
-      echo " 30:".
-       " <input type=\"radio\" name=\"call\" value=\"30\" />";
+      echo '  30:'.
+       ' <input type="radio" name="call" value="30" />';
       if($tmp==2) echo $highend;
-      echo "<br />\n";
+      echo "\n";
     }
   $tmp = can_call(0,$me);
   if( $tmp )
     {
       if($tmp==2) echo $highstart;
-      echo " 0:".
-       " <input type=\"radio\" name=\"call\" value=\"0\" />";
+      echo '  0:'.
+       ' <input type="radio" name="call" value="0" />';
       if($tmp==2) echo $highend;
-      echo "<br />\n".
-       " no call:".
-       " <input type=\"radio\" name=\"call\" value=\"no\" /> <br />";
+      echo "\n".
+       '  no call:'.
+       ' <input type="radio" name="call" value="no" />'."\n";
     }
 }
 
 function output_check_want_to_play($me)
 {
-   ?>
- <div class="joingame">
-   Do you want to play a game of DoKo? <br />
-   yes<input type="radio" name="in" value="yes" />
-   no<input type="radio" name="in" value="no" /> <br />
-<?php
+  echo ' <div class="joingame">';
+  echo '   '._('Do you want to play a game of DoKo?').' <br />';
+  echo '   '._('yes').'<input type="radio" name="in" value="yes" />';
+  echo '   '._('no').'<input type="radio" name="in" value="no" /> <br />';
   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
   echo "\n";
-  echo "<input type=\"submit\" value=\"submit\" />\n";
+  echo "<input type=\"submit\" value=\""._('submit')."\" />\n";
   echo " </div>\n";
 
   return;
@@ -332,7 +376,7 @@ function output_header()
      <title>e-Doko</title>
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
      <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
-     <link rel="stylesheet" type="text/css" href="css/standard023.css" />
+     <link rel="stylesheet" type="text/css" href="css/standard025.css" />
      <script type="text/javascript" src="include/game.js"> </script>
      <script type="text/javascript" src="include/jquery.js"> </script>
      <script type="text/javascript" src="include/jquery.tablesorter.js"></script>
@@ -340,12 +384,27 @@ function output_header()
         $(document).ready(function()
           {
               $("#ScoreTable").tablesorter({ widgets: ['zebra']});
+
+             $(".gameshidesession").click( function () {
+                 $(this).parent().children(".gamessession").toggle(300);
+               });
+
+             $(".gameshowall").click( function () {
+                 $(".gamessession").show(300);
+               });
+             $(".gamehideall").click( function () {
+                 $(".gamessession").hide(300);
+               });
+
+
            });
      </script>
   </head>
 <body onload="high_last();">
 <div class="header">
-<h1> Welcome to E-Doko </h1>
+<?php
+  echo '<h1> '._('Welcome to E-Doko').' </h1>';
+?>
 </div>
 <?php
 
@@ -359,7 +418,7 @@ function output_footer()
 
   echo "</div>\n\n";
   echo "<div class=\"footer\">\n";
-  echo "  <p class=\"left\"> copyright 2006-2009 Arun Persaud, Lance Thornton(graphics), Jeff Zerger(database support) <br />\n".
+  echo "  <p class=\"left\"> copyright 2006,2007,2008,2009,2010 Arun Persaud, Lance Thornton(graphics),  Jeff Zerger(database support) <br />\n".
     "  Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
     "  - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
     "  a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
@@ -382,12 +441,12 @@ function output_status()
 {
   global $defaulttimezone, $INDEX, $WIKI, $RSS;
 
-  if(isset($_SESSION["name"]))
+  if(isset($_SESSION['name']))
     {
-      $name = $_SESSION["name"];
+      $name = $_SESSION['name'];
 
       /* last logon time */
-      $myid  = DB_get_userid("name",$name);
+      $myid  = DB_get_userid('name',$name);
       $zone  = DB_get_user_timezone($myid);
 
       $time     = DB_get_user_timestamp($myid);
@@ -401,21 +460,21 @@ function output_status()
       /* logout info */
       echo "\n<div class=\"status\">\n";
       echo $name,"\n";
-      echo " | <a href=\"".$INDEX."\"> mypage </a>\n";
-      echo " | <a href=\"".$INDEX."?action=prefs\">settings</a>\n";
-      echo " | <a href=\"".$INDEX."?action=new\">new game</a>\n";
-      echo " | <a href=\"".$INDEX."?action=stats\">statistics</a>\n";
-      echo " | <a href=\"".$WIKI."\">wiki</a>\n";
-      echo " | <a href=\"".$RSS."?uid=".$myid."&amp;token=".$token."\">rss</a>\n";
-      echo " |&nbsp;&nbsp;&nbsp; <a href=\"".$INDEX."?action=logout\">logout</a>\n";
+      echo " | <a href=\"".$INDEX."\">"._('mypage')."</a>\n";
+      echo " | <a href=\"".$INDEX."?action=prefs\">"._('settings')."</a>\n";
+      echo " | <a href=\"".$INDEX."?action=new\">"._('new game')."</a>\n";
+      echo " | <a href=\"".$INDEX."?action=stats\">"._('statistics')."</a>\n";
+      echo " | <a href=\"".$WIKI."\">"._('wiki/bugs')."</a>\n";
+      echo " | <a href=\"".$RSS."?uid=".$myid."&amp;token=".$token."\">"._('atom')."</a>\n";
+      echo " |&nbsp;&nbsp;&nbsp; <a href=\"".$INDEX."?action=logout\">"._('logout')."</a>\n";
       echo "</div>\n";
 
-      echo "<div class=\"lastlogin\"><span>last login: ".date("r",$unixtime)."</span></div>\n";
+      echo "<div class=\"lastlogin\"><span>"._('last login').": ".date("r",$unixtime)."</span></div>\n";
     }
   else
     {
       echo "\n<div class=\"status\">\n";
-      echo "<a href=\"".$INDEX."\">login</a>\n";
+      echo "<a href=\"".$INDEX."\">"._('login')."</a>\n";
       echo "</div>\n";
     }
   return;
@@ -467,6 +526,26 @@ function output_select_timezone($name,$timezone="")
   return;
 }
 
+function output_select_language($name,$language="")
+{
+  $LOCALE = array ("English"     => "en",
+                  "Deutsch"     => "de" );
+
+  echo "  <select id=\"$name\" name=\"$name\" size=\"1\">\n";
+
+  foreach($LOCALE as $place=>$locale)
+    {
+      if($language==$locale)
+       echo "   <option value=\"$locale\" selected=\"selected\">$place</option>\n";
+      else
+       echo "   <option value=\"$locale\">$place</option>\n";
+    }
+  echo "  </select>\n";
+
+  return;
+}
+
+
 function output_password_recovery($email,$password)
 {
 ?>
@@ -501,7 +580,7 @@ function output_password_recovery($email,$password)
 
 function output_user_notes($userid,$gameid,$userstatus)
 {
-  echo "<div class=\"notes\"> Personal notes: <br />\n";
+  echo "<div class=\"notes\"> "._('Personal notes').": <br />\n";
   $notes = DB_get_notes_by_userid_and_gameid($userid,$gameid);
   foreach($notes as $note)
     echo "$note <hr />\n";
@@ -537,7 +616,7 @@ function output_exchanged_cards()
    */
 
   /* need some information about the game */
-  global $gameid,$mygametype, $PREF,$me,$mystatus;
+  global $gameid,$mygametype, $PREF,$me,$mystatus, $RULES;
 
   /* some variables to track where the people with poverty are sitting */
   $partnerpos1 = 0;
@@ -554,7 +633,7 @@ function output_exchanged_cards()
       for($mypos=1;$mypos<5;$mypos++)
        {
          $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
-         if($usersick == 'poverty')
+         if($usersick == 'poverty' || ($RULES['lowtrump']=='poverty' && $usersick=='lowtrump'))
            if($povertypos1)
              $povertypos2 = $mypos;
            else
@@ -630,7 +709,7 @@ function output_exchanged_cards()
                  else
                    display_card(0,$PREF['cardset']);
                }
-             if($trump_back1) echo "        Trump back";
+             if($trump_back1) echo '        '._('Trump back');
            }
          else if($mypos==$povertypos1)
            {
@@ -642,7 +721,7 @@ function output_exchanged_cards()
                  else
                    display_card(0,$PREF['cardset']);
              }
-             if($trump_back1) echo "        Trump back";
+             if($trump_back1) echo '        '._('Trump back');
            }
          else if($mypos==$povertypos2)
            {
@@ -654,7 +733,7 @@ function output_exchanged_cards()
                  else
                    display_card(0,$PREF['cardset']);
                }
-             if($trump_back2) echo "        Trump back";
+             if($trump_back2) echo '        '._('Trump back');
            }
          else if($mypos==$partnerpos2)
            {
@@ -667,7 +746,7 @@ function output_exchanged_cards()
                  else
                    display_card(0,$PREF['cardset']);
                }
-             if($trump_back2) echo "        Trump back";
+             if($trump_back2) echo '        '._('Trump back');
            }
          echo  "      </div>\n";
        }