form_table_class.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2017 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 ">".'off'."</option>";
  92. echo "<option value='1' ";
  93. if ( @$value == 1 )
  94. echo "selected='selected'";
  95. echo ">".'on'."</option></select>";
  96. }
  97. else if ($type === "text")
  98. {
  99. echo "<textarea id='".$name."' name='".$name."' cols='38' rows='3' $extra >";
  100. if (isset($value))
  101. echo $value;
  102. echo "</textarea>";
  103. }
  104. else if ($type === "password")
  105. {
  106. echo "<input id='".$name."' type='password' name='".$name."' value='".$value."' size='".$size."' $extra />";
  107. }
  108. else
  109. {
  110. print_failure(get_lang_f('invalid_setting_type',$type));
  111. }
  112. if ( defined($name."_info") )
  113. {
  114. 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>";
  115. $this->i++;
  116. }
  117. else
  118. {
  119. echo "</td><td></td></tr>\n";
  120. }
  121. }
  122. public function add_custom_field($name,$data,$td_extra = "")
  123. {
  124. echo "<tr><td align='right' $td_extra><label for='".$name."'>".get_lang($name).":</label></td>";
  125. echo "<td align='left'>".$data."</td>\n";
  126. if ( defined($name."_info") )
  127. {
  128. 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";
  129. $this->i++;
  130. }
  131. else
  132. {
  133. echo "</tr>\n";
  134. }
  135. }
  136. public function end_table()
  137. {
  138. echo "</table>";
  139. }
  140. public function add_button($type,$name,$value)
  141. {
  142. echo "<p class='center'><input type='$type' name='$name' value='$value' /></p>";
  143. }
  144. public function end_form()
  145. {
  146. echo "</form>";
  147. echo "</div>";
  148. echo "<br />";
  149. }
  150. }
  151. ?>