form_table_class.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. ?>
  25. <style>
  26. .tip{
  27. display:none;
  28. }
  29. .image-tip:hover .tip, .tip:hover{
  30. font-weight:bold;
  31. display:block;
  32. padding: 4px 8px;
  33. color: #333;
  34. position: absolute;
  35. margin-left:16px;
  36. margin-top:-22px;
  37. z-index: 20;
  38. -moz-border-radius: 5px;
  39. -webkit-border-radius: 5px;
  40. border-radius: 5px;
  41. -moz-box-shadow: 0px 0px 4px #222;
  42. -webkit-box-shadow: 0px 0px 4px #222;
  43. box-shadow: 0px 0px 4px #222;
  44. background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
  45. background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc));
  46. background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
  47. background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
  48. background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
  49. background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
  50. text-align:left !important;
  51. }
  52. .center{
  53. margin-left:auto;
  54. margin-right:auto;
  55. text-align:center !important;
  56. }
  57. </style>
  58. <?php
  59. class FormTable {
  60. public function __construct()
  61. {
  62. $this->i = 0;
  63. }
  64. public function start_form($action, $method = "post", $extra = "")
  65. {
  66. echo "<div align='center'>";
  67. echo "<form action='".$action."' method='".$method."' $extra >";
  68. }
  69. public function start_table()
  70. {
  71. echo "<table class='center'>";
  72. }
  73. public function add_field_hidden($name, $value)
  74. {
  75. echo "<input type='hidden' name='".$name."' value='".@$value."'/>";
  76. }
  77. public function add_field($type, $name, $value, $size = 50, $extra = "")
  78. {
  79. echo "<tr><td align='right'><label for='".$name."'>".get_lang($name).":</label></td>";
  80. echo "<td align='left'>";
  81. if ($type === "string")
  82. {
  83. echo "<input type='text' id='".$name."' name='".$name."' value='".@$value."' size=".$size." $extra />";
  84. }
  85. else if ($type === "on_off")
  86. {
  87. echo "<select id='".$name."' name='".$name."' $extra >";
  88. echo "<option value='0' ";
  89. if ( @$value == 0 )
  90. echo "selected='selected'";
  91. echo ">". get_lang("off") ."</option>";
  92. echo "<option value='1' ";
  93. if ( @$value == 1 )
  94. echo "selected='selected'";
  95. echo ">". get_lang("on") ."</option></select>";
  96. }
  97. else if ($type === "checkbox")
  98. {
  99. echo "<input type='checkbox' id='".$name."' name='".$name."' value='1' $extra ";
  100. if ( @$value == 1 )
  101. echo "selected='selected'";
  102. echo ">";
  103. }
  104. else if ($type === "text")
  105. {
  106. echo "<textarea id='".$name."' name='".$name."' cols='".$size."' rows='3' $extra />";
  107. if (isset($value))
  108. echo $value;
  109. echo "</textarea>";
  110. }
  111. else if ($type === "password")
  112. {
  113. echo "<input id='".$name."' type='password' name='".$name."' value='".$value."' size='".$size."' $extra />";
  114. }
  115. else
  116. {
  117. print_failure(get_lang_f('invalid_setting_type',$type));
  118. }
  119. if ( defined("OGP_LANG_".$name."_info") )
  120. {
  121. echo "</td><td><div class='image-tip' id='".$this->i."' ><img src='images/icon_help_small.gif' ><span class='tip' id='".$this->i."' >".str_replace("'",'"',get_lang($name."_info"))."</span></div></td></tr>";
  122. $this->i++;
  123. }
  124. else
  125. {
  126. echo "</td><td></td></tr>\n";
  127. }
  128. }
  129. public function add_custom_field($name,$data,$td_extra = "")
  130. {
  131. echo "<tr><td align='right' $td_extra><label for='".$name."'>".get_lang($name).":</label></td>";
  132. echo "<td align='left'>".$data."</td>\n";
  133. if ( defined("OGP_LANG_".$name."_info") )
  134. {
  135. echo "<td><div class='image-tip' id='".$this->i."' ><img src='images/icon_help_small.gif' ><span class='tip' id='".$this->i."' >".str_replace("'",'"',get_lang($name."_info"))."</span></div></td>\n</tr>\n";
  136. $this->i++;
  137. }
  138. else
  139. {
  140. echo "</tr>\n";
  141. }
  142. }
  143. public function end_table()
  144. {
  145. echo "</table>";
  146. }
  147. public function add_button($type,$name,$value)
  148. {
  149. echo "<p class='center'><input type='$type' name='$name' value='$value' /></p>";
  150. }
  151. public function end_form()
  152. {
  153. echo "</form>";
  154. echo "</div>";
  155. echo "<br />";
  156. }
  157. }
  158. ?>