wizardsteps.class.inc.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <?php
  2. // Copyright (C) 2012 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. * All the steps of the iTop installation wizard
  18. * @author Erwan Taloc <erwan.taloc@combodo.com>
  19. * @author Romain Quetiez <romain.quetiez@combodo.com>
  20. * @author Denis Flaven <denis.flaven@combodo.com>
  21. * @license http://www.opensource.org/licenses/gpl-3.0.html GPL
  22. */
  23. require_once(APPROOT.'setup/setuputils.class.inc.php');
  24. /**
  25. * First step of the iTop Installation Wizard: Welcome screen
  26. */
  27. class WizStepWelcome extends WizardStep
  28. {
  29. protected $bCanMoveForward;
  30. public function GetTitle()
  31. {
  32. return 'Welcome';
  33. }
  34. public function GetPossibleSteps()
  35. {
  36. return array('WizStepInstallOrUpgrade');
  37. }
  38. public function ProcessParams($bMoveForward = true)
  39. {
  40. return array('class' => 'WizStepInstallOrUpgrade', 'state' => '');
  41. }
  42. public function Display(WebPage $oPage)
  43. {
  44. $oPage->p('First step of the installation: check of the prerequisites');
  45. $aResults = SetupUtils::CheckPHPVersion($oPage);
  46. $this->bCanMoveForward = true;
  47. foreach($aResults as $oCheckResult)
  48. {
  49. switch($oCheckResult->iSeverity)
  50. {
  51. case CheckResult::ERROR:
  52. $this->bCanMoveForward = false;
  53. $oPage->error($oCheckResult->sLabel);
  54. break;
  55. case CheckResult::WARNING:
  56. $oPage->warning($oCheckResult->sLabel);
  57. break;
  58. case CheckResult::INFO:
  59. $oPage->ok($oCheckResult->sLabel);
  60. break;
  61. }
  62. }
  63. }
  64. public function CanMoveForward()
  65. {
  66. return $this->bCanMoveForward;
  67. }
  68. }
  69. /**
  70. * Second step of the iTop Installation Wizard: Install or Upgrade
  71. */
  72. class WizStepInstallOrUpgrade extends WizardStep
  73. {
  74. public function GetTitle()
  75. {
  76. return 'Install or Upgrade choice';
  77. }
  78. public function GetPossibleSteps()
  79. {
  80. return array('WizStepDetectedInfo', 'WizStepLicense');
  81. }
  82. public function ProcessParams($bMoveForward = true)
  83. {
  84. $sNextStep = '';
  85. $sInstallMode = utils::ReadParam('install_mode');
  86. if ($sInstallMode == 'install')
  87. {
  88. $this->oWizard->SetParameter('install_mode', 'install');
  89. $sNextStep = 'WizStepLicense';
  90. }
  91. else
  92. {
  93. $this->oWizard->SetParameter('install_mode', 'upgrade');
  94. $sNextStep = 'WizStepDetectedInfo';
  95. }
  96. return array('class' => $sNextStep, 'state' => '');
  97. }
  98. public function Display(WebPage $oPage)
  99. {
  100. $oPage->p('What do you want to do?');
  101. $sInstallMode = $this->oWizard->GetParameter('install_mode', 'install');
  102. $sChecked = ($sInstallMode == 'install') ? ' checked ' : '';
  103. $oPage->p('<input type="radio" name="install_mode" value="install"'.$sChecked.'/> Install a new iTop');
  104. $sChecked = ($sInstallMode == 'upgrade') ? ' checked ' : '';
  105. $oPage->p('<input type="radio" name="install_mode" value="upgrade"'.$sChecked.'/> Upgrade an existing iTop');
  106. }
  107. }
  108. /**
  109. * Upgrade information
  110. */
  111. class WizStepDetectedInfo extends WizardStep
  112. {
  113. public function GetTitle()
  114. {
  115. return 'Detected Info';
  116. }
  117. public function GetPossibleSteps()
  118. {
  119. return array('WizStepUpgradeKeep', 'WizStepUpgradeAuto', 'WizStepLicense2');
  120. }
  121. public function ProcessParams($bMoveForward = true)
  122. {
  123. return array('class' => 'WizStepUpgradeAuto', 'state' => '');
  124. }
  125. public function Display(WebPage $oPage)
  126. {
  127. $oPage->p('Info about the detected version');
  128. }
  129. }
  130. /**
  131. * Keep or Upgrade choice
  132. */
  133. class WizStepUpgradeKeep extends WizardStep
  134. {
  135. public function GetTitle()
  136. {
  137. return 'Keep or Upgrade';
  138. }
  139. public function GetPossibleSteps()
  140. {
  141. return array('WizStepModulesChoice');
  142. }
  143. public function ProcessParams($bMoveForward = true)
  144. {
  145. return array('class' => 'WizStepModulesChoice', 'state' => 'start_upgrade');
  146. }
  147. public function Display(WebPage $oPage)
  148. {
  149. $oPage->p('Keep or Upgrade the data model');
  150. }
  151. }
  152. /**
  153. * Automatic Upgrade info
  154. */
  155. class WizStepUpgradeAuto extends WizardStep
  156. {
  157. public function GetTitle()
  158. {
  159. return 'Upgrade Information';
  160. }
  161. public function GetPossibleSteps()
  162. {
  163. return array('WizStepModulesChoice');
  164. }
  165. public function ProcessParams($bMoveForward = true)
  166. {
  167. return array('class' => 'WizStepModulesChoice', 'state' => 'start_upgrade');
  168. }
  169. public function Display(WebPage $oPage)
  170. {
  171. $oPage->p('Automatic Upgrade information');
  172. }
  173. }
  174. /**
  175. * License acceptation screen
  176. */
  177. class WizStepLicense extends WizardStep
  178. {
  179. public function GetTitle()
  180. {
  181. return 'License Agreement';
  182. }
  183. public function GetPossibleSteps()
  184. {
  185. return array('WizStepDBParams');
  186. }
  187. public function ProcessParams($bMoveForward = true)
  188. {
  189. return array('class' => 'WizStepDBParams', 'state' => '');
  190. }
  191. public function Display(WebPage $oPage)
  192. {
  193. $oPage->p('Do you accept ALL the licenses?');
  194. }
  195. }
  196. /**
  197. * License acceptation screen (when upgrading)
  198. */
  199. class WizStepLicense2 extends WizStepLicense
  200. {
  201. public function GetPossibleSteps()
  202. {
  203. return array('WizStepUpgradeKeep', 'WizStepUpgradeAuto');
  204. }
  205. public function ProcessParams($bMoveForward = true)
  206. {
  207. return array('class' => 'WizStepUpgradeAuto', 'state' => '');
  208. }
  209. }
  210. /**
  211. * Database Connection parameters screen
  212. */
  213. class WizStepDBParams extends WizardStep
  214. {
  215. public function GetTitle()
  216. {
  217. return 'Database Configuration';
  218. }
  219. public function GetPossibleSteps()
  220. {
  221. return array('WizStepAdminAccount');
  222. }
  223. public function ProcessParams($bMoveForward = true)
  224. {
  225. return array('class' => 'WizStepAdminAccount', 'state' => '');
  226. }
  227. public function Display(WebPage $oPage)
  228. {
  229. $oPage->p('Please enter the DB parameters');
  230. }
  231. }
  232. /**
  233. * Administrator Account definition screen
  234. */
  235. class WizStepAdminAccount extends WizardStep
  236. {
  237. public function GetTitle()
  238. {
  239. return 'Administrator Account';
  240. }
  241. public function GetPossibleSteps()
  242. {
  243. return array('WizStepMiscParams');
  244. }
  245. public function ProcessParams($bMoveForward = true)
  246. {
  247. return array('class' => 'WizStepMiscParams', 'state' => '');
  248. }
  249. public function Display(WebPage $oPage)
  250. {
  251. $oPage->p('Please enter Admin Account name/pwd');
  252. }
  253. }
  254. /**
  255. * Miscellaneous Parameters (URL, Sample Data)
  256. */
  257. class WizStepMiscParams extends WizardStep
  258. {
  259. public function GetTitle()
  260. {
  261. return 'Miscellaneous Parameters';
  262. }
  263. public function GetPossibleSteps()
  264. {
  265. return array('WizStepModulesChoice');
  266. }
  267. public function ProcessParams($bMoveForward = true)
  268. {
  269. return array('class' => 'WizStepModulesChoice', 'state' => 'start_install');
  270. }
  271. public function Display(WebPage $oPage)
  272. {
  273. $oPage->p('Additional Parameters (URl, Sample Data)');
  274. }
  275. }
  276. /**
  277. * Choice of the modules to be installed
  278. */
  279. class WizStepModulesChoice extends WizardStep
  280. {
  281. public function GetTitle()
  282. {
  283. return 'Modules Selection';
  284. }
  285. public function GetPossibleSteps()
  286. {
  287. return array('WizStepSummary');
  288. }
  289. public function ProcessParams($bMoveForward = true)
  290. {
  291. return array('class' => 'WizStepSummary', 'state' => '');
  292. }
  293. public function Display(WebPage $oPage)
  294. {
  295. $oPage->p('Select the modules to install/upgrade.');
  296. }
  297. }
  298. /**
  299. * Summary of the installation tasks
  300. */
  301. class WizStepSummary extends WizardStep
  302. {
  303. public function GetTitle()
  304. {
  305. return 'Installation summary';
  306. }
  307. public function GetPossibleSteps()
  308. {
  309. return array('WizStepDone');
  310. }
  311. public function ProcessParams($bMoveForward = true)
  312. {
  313. return array('class' => 'WizStepDone', 'state' => '');
  314. }
  315. public function Display(WebPage $oPage)
  316. {
  317. $oPage->p('Summary of the installation.');
  318. }
  319. }
  320. /**
  321. * Summary of the installation tasks
  322. */
  323. class WizStepDone extends WizardStep
  324. {
  325. public function GetTitle()
  326. {
  327. return 'Done';
  328. }
  329. public function GetPossibleSteps()
  330. {
  331. return array();
  332. }
  333. public function ProcessParams($bMoveForward = true)
  334. {
  335. return array('class' => '', 'state' => '');
  336. }
  337. public function Display(WebPage $oPage)
  338. {
  339. $oPage->p('Installation Completed.');
  340. }
  341. public function CanMoveForward()
  342. {
  343. return false;
  344. }
  345. }