setuppage.class.inc.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * Web page used for displaying the login form
  18. *
  19. * @author Erwan Taloc <erwan.taloc@combodo.com>
  20. * @author Romain Quetiez <romain.quetiez@combodo.com>
  21. * @author Denis Flaven <denis.flaven@combodo.com>
  22. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  23. */
  24. require_once("../application/nicewebpage.class.inc.php");
  25. define('INSTALL_LOG_FILE', '../setup.log');
  26. class SetupWebPage extends NiceWebPage
  27. {
  28. public function __construct($sTitle)
  29. {
  30. parent::__construct($sTitle);
  31. $this->add_linked_script("../js/jquery.blockUI.js");
  32. $this->add_linked_script("./setup.js");
  33. $this->add_style("
  34. body {
  35. background-color: #eee;
  36. margin: 0;
  37. padding: 0;
  38. font-size: 10pt;
  39. overflow-y: auto;
  40. }
  41. #setup {
  42. width: 600px;
  43. margin-left: auto;
  44. margin-right: auto;
  45. margin-top: 50px;
  46. padding: 20px;
  47. background-color: #fff;
  48. border: 1px solid #000;
  49. }
  50. .center {
  51. text-align: center;
  52. }
  53. h1 {
  54. color: #83b217;
  55. font-size: 16pt;
  56. }
  57. h2 {
  58. color: #000;
  59. font-size: 14pt;
  60. }
  61. .v-spacer {
  62. padding-top: 1em;
  63. }
  64. button {
  65. margin-top: 1em;
  66. padding-left: 1em;
  67. padding-right: 1em;
  68. }
  69. p.info {
  70. padding-left: 50px;
  71. background: url(../images/info-mid.png) no-repeat left -5px;
  72. height: 48px;
  73. }
  74. p.ok {
  75. padding-left: 50px;
  76. background: url(../images/clean-mid.png) no-repeat left -8px;
  77. height: 48px;
  78. }
  79. p.warning {
  80. padding-left: 50px;
  81. background: url(../images/messagebox_warning-mid.png) no-repeat left -5px;
  82. height: 48px;
  83. }
  84. p.error {
  85. padding-left: 50px;
  86. background: url(../images/stop-mid.png) no-repeat left -5px;
  87. height: 48px;
  88. }
  89. td.label {
  90. text-align: left;
  91. }
  92. td.input {
  93. text-align: left;
  94. }
  95. table.formTable {
  96. border: 0;
  97. cellpadding: 2px;
  98. cellspacing: 0;
  99. }
  100. .wizlabel, .wizinput {
  101. color: #000;
  102. font-size: 10pt;
  103. }
  104. .wizhelp {
  105. color: #333;
  106. font-size: 8pt;
  107. }
  108. #progress {
  109. border:1px solid #000000;
  110. width: 180px;
  111. height: 20px;
  112. line-height: 20px;
  113. text-align: center;
  114. margin: 5px;
  115. }
  116. ");
  117. }
  118. public function info($sText)
  119. {
  120. $this->add("<p class=\"info\">$sText</p>\n");
  121. $this->log_info($sText);
  122. }
  123. public function ok($sText)
  124. {
  125. $this->add("<p class=\"ok\">$sText</p>\n");
  126. $this->log_ok($sText);
  127. }
  128. public function warning($sText)
  129. {
  130. $this->add("<p class=\"warning\">$sText</p>\n");
  131. $this->log_warning($sText);
  132. }
  133. public function error($sText)
  134. {
  135. $this->add("<p class=\"error\">$sText</p>\n");
  136. $this->log_error($sText);
  137. }
  138. public function form($aData)
  139. {
  140. $this->add("<table class=\"formTable\">\n");
  141. foreach($aData as $aRow)
  142. {
  143. $this->add("<tr>\n");
  144. if (isset($aRow['label']) && isset($aRow['label']) && isset($aRow['help']))
  145. {
  146. $this->add("<td class=\"wizlabel\">{$aRow['label']}</td>\n");
  147. $this->add("<td class=\"wizinput\">{$aRow['input']}</td>\n");
  148. $this->add("<td class=\"wizhelp\">{$aRow['help']}</td>\n");
  149. }
  150. else if (isset($aRow['label']) && isset($aRow['help']))
  151. {
  152. $this->add("<td colspan=\"2\" class=\"wizlabel\">{$aRow['label']}</td>\n");
  153. $this->add("<td class=\"wizhelp\">{$aRow['help']}</td>\n");
  154. }
  155. else if (isset($aRow['label']) && isset($aRow['input']))
  156. {
  157. $this->add("<td class=\"wizlabel\">{$aRow['label']}</td>\n");
  158. $this->add("<td colspan=\"2\" class=\"wizinput\">{$aRow['input']}</td>\n");
  159. }
  160. else if (isset($aRow['label']))
  161. {
  162. $this->add("<td colspan=\"3\" class=\"wizlabel\">{$aRow['label']}</td>\n");
  163. }
  164. $this->add("</tr>\n");
  165. }
  166. $this->add("</table>\n");
  167. }
  168. public function output()
  169. {
  170. $this->s_content = "<div id=\"setup\">{$this->s_content}\n</div>\n";
  171. return parent::output();
  172. }
  173. public static function log_error($sText)
  174. {
  175. self::log("Error - ".$sText);
  176. }
  177. public static function log_warning($sText)
  178. {
  179. self::log("Warning - ".$sText);
  180. }
  181. public static function log_info($sText)
  182. {
  183. self::log("Info - ".$sText);
  184. }
  185. public static function log_ok($sText)
  186. {
  187. self::log("Ok - ".$sText);
  188. }
  189. public static function log($sText)
  190. {
  191. $hLogFile = @fopen(INSTALL_LOG_FILE, 'a');
  192. if ($hLogFile !== false)
  193. {
  194. $sDate = date('Y-m-d H:i:s');
  195. fwrite($hLogFile, "$sDate - $sText\n");
  196. fclose($hLogFile);
  197. }
  198. }
  199. } // End of class
  200. ?>