setuppage.class.inc.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. require_once("../application/nicewebpage.class.inc.php");
  3. define('INSTALL_LOG_FILE', '../setup.log');
  4. /**
  5. * Web page used for displaying the login form
  6. */
  7. class SetupWebPage extends NiceWebPage
  8. {
  9. public function __construct($sTitle)
  10. {
  11. parent::__construct($sTitle);
  12. $this->add_linked_script("../js/jquery.blockUI.js");
  13. $this->add_linked_script("./setup.js");
  14. $this->add_style("
  15. body {
  16. background-color: #eee;
  17. margin: 0;
  18. padding: 0;
  19. font-size: 10pt;
  20. overflow-y: auto;
  21. }
  22. #setup {
  23. width: 600px;
  24. margin-left: auto;
  25. margin-right: auto;
  26. margin-top: 50px;
  27. padding: 20px;
  28. background-color: #fff;
  29. border: 1px solid #000;
  30. }
  31. .center {
  32. text-align: center;
  33. }
  34. h1 {
  35. color: #83b217;
  36. font-size: 16pt;
  37. }
  38. h2 {
  39. color: #000;
  40. font-size: 14pt;
  41. }
  42. .v-spacer {
  43. padding-top: 1em;
  44. }
  45. button {
  46. margin-top: 1em;
  47. padding-left: 1em;
  48. padding-right: 1em;
  49. }
  50. p.info {
  51. padding-left: 50px;
  52. background: url(../images/info-mid.png) no-repeat left -5px;
  53. height: 48px;
  54. }
  55. p.ok {
  56. padding-left: 50px;
  57. background: url(../images/clean-mid.png) no-repeat left -8px;
  58. height: 48px;
  59. }
  60. p.warning {
  61. padding-left: 50px;
  62. background: url(../images/messagebox_warning-mid.png) no-repeat left -5px;
  63. height: 48px;
  64. }
  65. p.error {
  66. padding-left: 50px;
  67. background: url(../images/stop-mid.png) no-repeat left -5px;
  68. height: 48px;
  69. }
  70. td.label {
  71. text-align: left;
  72. }
  73. td.input {
  74. text-align: left;
  75. }
  76. table.formTable {
  77. border: 0;
  78. cellpadding: 2px;
  79. cellspacing: 0;
  80. }
  81. .wizlabel, .wizinput {
  82. color: #000;
  83. font-size: 10pt;
  84. }
  85. .wizhelp {
  86. color: #333;
  87. font-size: 8pt;
  88. }
  89. #progress {
  90. border:1px solid #000000;
  91. width: 180px;
  92. height: 20px;
  93. line-height: 20px;
  94. text-align: center;
  95. margin: 5px;
  96. }
  97. ");
  98. }
  99. public function info($sText)
  100. {
  101. $this->add("<p class=\"info\">$sText</p>\n");
  102. $this->log_info($sText);
  103. }
  104. public function ok($sText)
  105. {
  106. $this->add("<p class=\"ok\">$sText</p>\n");
  107. $this->log_ok($sText);
  108. }
  109. public function warning($sText)
  110. {
  111. $this->add("<p class=\"warning\">$sText</p>\n");
  112. $this->log_warning($sText);
  113. }
  114. public function error($sText)
  115. {
  116. $this->add("<p class=\"error\">$sText</p>\n");
  117. $this->log_error($sText);
  118. }
  119. public function form($aData)
  120. {
  121. $this->add("<table class=\"formTable\">\n");
  122. foreach($aData as $aRow)
  123. {
  124. $this->add("<tr>\n");
  125. if (isset($aRow['label']) && isset($aRow['label']) && isset($aRow['help']))
  126. {
  127. $this->add("<td class=\"wizlabel\">{$aRow['label']}</td>\n");
  128. $this->add("<td class=\"wizinput\">{$aRow['input']}</td>\n");
  129. $this->add("<td class=\"wizhelp\">{$aRow['help']}</td>\n");
  130. }
  131. else if (isset($aRow['label']) && isset($aRow['help']))
  132. {
  133. $this->add("<td colspan=\"2\" class=\"wizlabel\">{$aRow['label']}</td>\n");
  134. $this->add("<td class=\"wizhelp\">{$aRow['help']}</td>\n");
  135. }
  136. else if (isset($aRow['label']) && isset($aRow['input']))
  137. {
  138. $this->add("<td class=\"wizlabel\">{$aRow['label']}</td>\n");
  139. $this->add("<td colspan=\"2\" class=\"wizinput\">{$aRow['input']}</td>\n");
  140. }
  141. else if (isset($aRow['label']))
  142. {
  143. $this->add("<td colspan=\"3\" class=\"wizlabel\">{$aRow['label']}</td>\n");
  144. }
  145. $this->add("</tr>\n");
  146. }
  147. $this->add("</table>\n");
  148. }
  149. public function output()
  150. {
  151. $this->s_content = "<div id=\"setup\">{$this->s_content}\n</div>\n";
  152. return parent::output();
  153. }
  154. public static function log_error($sText)
  155. {
  156. self::log("Error - ".$sText);
  157. }
  158. public static function log_warning($sText)
  159. {
  160. self::log("Warning - ".$sText);
  161. }
  162. public static function log_info($sText)
  163. {
  164. self::log("Info - ".$sText);
  165. }
  166. public static function log_ok($sText)
  167. {
  168. self::log("Ok - ".$sText);
  169. }
  170. public static function log($sText)
  171. {
  172. $hLogFile = @fopen(INSTALL_LOG_FILE, 'a');
  173. if ($hLogFile !== false)
  174. {
  175. $sDate = date('Y-m-d H:i:s');
  176. fwrite($hLogFile, "$sDate - $sText\n");
  177. fclose($hLogFile);
  178. }
  179. }
  180. } // End of class
  181. ?>