wizardsteps.class.inc.php 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661
  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. require_once(APPROOT.'setup/parameters.class.inc.php');
  25. require_once(APPROOT.'setup/applicationinstaller.class.inc.php');
  26. require_once(APPROOT.'setup/parameters.class.inc.php');
  27. /**
  28. * First step of the iTop Installation Wizard: Welcome screen
  29. */
  30. class WizStepWelcome extends WizardStep
  31. {
  32. protected $bCanMoveForward;
  33. public function GetTitle()
  34. {
  35. return 'Welcome to '.ITOP_APPLICATION.' version '.ITOP_VERSION;
  36. }
  37. /**
  38. * Returns the label for the " Next >> " button
  39. * @return string The label for the button
  40. */
  41. public function GetNextButtonLabel()
  42. {
  43. return ' Continue >> ';
  44. }
  45. public function GetPossibleSteps()
  46. {
  47. return array('WizStepInstallOrUpgrade');
  48. }
  49. public function ProcessParams($bMoveForward = true)
  50. {
  51. return array('class' => 'WizStepInstallOrUpgrade', 'state' => '');
  52. }
  53. public function Display(WebPage $oPage)
  54. {
  55. // Store the misc_options for the future...
  56. $aMiscOptions = utils::ReadParam('option', array(), false, 'raw_data');
  57. $sMiscOptions = $this->oWizard->GetParameter('misc_options', json_encode($aMiscOptions));
  58. $this->oWizard->SetParameter('misc_options', $sMiscOptions);
  59. $oPage->add('<h1>iTop Installation Wizard</h1>');
  60. $aResults = SetupUtils::CheckPHPVersion($oPage);
  61. $this->bCanMoveForward = true;
  62. $aInfo = array();
  63. $aWarnings = array();
  64. $aErrors = array();
  65. foreach($aResults as $oCheckResult)
  66. {
  67. switch($oCheckResult->iSeverity)
  68. {
  69. case CheckResult::ERROR:
  70. $aErrors[] = $oCheckResult->sLabel;
  71. $this->bCanMoveForward = false;
  72. break;
  73. case CheckResult::WARNING:
  74. $aWarnings[] = $oCheckResult->sLabel;
  75. break;
  76. case CheckResult::INFO:
  77. $aInfo[] = $oCheckResult->sLabel;
  78. break;
  79. }
  80. }
  81. $sStyle = 'style="display:none;max-height:196px;overflow:auto;"';
  82. $sToggleButtons = '<button type="button" id="show_details" onclick="$(\'#details\').toggle(); $(this).toggle(); $(\'#hide_details\').toggle();">Show details</button><button type="button" id="hide_details" style="display:none;" onclick="$(\'#details\').toggle(); $(this).toggle(); $(\'#show_details\').toggle();">Hide details</button>';
  83. if (count($aErrors)> 0)
  84. {
  85. $sStyle = 'style="max-height:196px;overflow:auto;"';
  86. $sImage = "stop-mid.png";
  87. $sTitle = count($aErrors).' Error(s), '.count($aWarnings).' Warning(s).';
  88. }
  89. else if (count($aWarnings)> 0)
  90. {
  91. $sTitle = count($aWarnings).' Warning(s) '.$sToggleButtons;
  92. $sImage = "messagebox_warning-mid.png";
  93. }
  94. else
  95. {
  96. $sTitle = 'Ok. '.$sToggleButtons;
  97. $sImage = "clean-mid.png";
  98. }
  99. $oPage->add('<h2>Prerequisites validation: ');
  100. $oPage->add("<img style=\"vertical-align:middle;\" src=\"../images/$sImage\"> ");
  101. $oPage->add($sTitle);
  102. $oPage->add('</h2>');
  103. $oPage->add('<div id="details" '.$sStyle.'>');
  104. foreach($aErrors as $sText)
  105. {
  106. $oPage->error($sText);
  107. }
  108. foreach($aWarnings as $sText)
  109. {
  110. $oPage->warning($sText);
  111. }
  112. foreach($aInfo as $sText)
  113. {
  114. $oPage->ok($sText);
  115. }
  116. $oPage->add('</div>');
  117. if (!$this->bCanMoveForward)
  118. {
  119. $oPage->p('Sorry, the installation cannot continue. Please fix the errors and reload this page to launch the installation again.');
  120. }
  121. }
  122. public function CanMoveForward()
  123. {
  124. return $this->bCanMoveForward;
  125. }
  126. }
  127. /**
  128. * Second step of the iTop Installation Wizard: Install or Upgrade
  129. */
  130. class WizStepInstallOrUpgrade extends WizardStep
  131. {
  132. public function GetTitle()
  133. {
  134. return 'Install or Upgrade choice';
  135. }
  136. public function GetPossibleSteps()
  137. {
  138. return array('WizStepDetectedInfo', 'WizStepLicense');
  139. }
  140. public function ProcessParams($bMoveForward = true)
  141. {
  142. $sNextStep = '';
  143. $sInstallMode = utils::ReadParam('install_mode');
  144. $this->oWizard->SaveParameter('source_dir', '');
  145. $this->oWizard->SaveParameter('db_server', '');
  146. $this->oWizard->SaveParameter('db_user', '');
  147. $this->oWizard->SaveParameter('db_pwd', '');
  148. $this->oWizard->SaveParameter('db_name', '');
  149. $this->oWizard->SaveParameter('db_prefix', '');
  150. $this->oWizard->SaveParameter('db_backup', false);
  151. $this->oWizard->SaveParameter('db_backup_path', '');
  152. if ($sInstallMode == 'install')
  153. {
  154. $this->oWizard->SetParameter('install_mode', 'install');
  155. $sNextStep = 'WizStepLicense';
  156. }
  157. else
  158. {
  159. $this->oWizard->SetParameter('install_mode', 'upgrade');
  160. $sNextStep = 'WizStepDetectedInfo';
  161. }
  162. return array('class' => $sNextStep, 'state' => '');
  163. }
  164. public function Display(WebPage $oPage)
  165. {
  166. $sInstallMode = $this->oWizard->GetParameter('install_mode', '');
  167. $sSourceDir = $this->oWizard->GetParameter('source_dir', '');
  168. $sDBServer = $this->oWizard->GetParameter('db_server', '');
  169. $sDBUser = $this->oWizard->GetParameter('db_user', '');
  170. $sDBPwd = $this->oWizard->GetParameter('db_pwd', '');
  171. $sDBName = $this->oWizard->GetParameter('db_name', '');
  172. $sDBPrefix = $this->oWizard->GetParameter('db_prefix', '');
  173. $bDBBackup = $this->oWizard->GetParameter('db_backup', false);
  174. $sDBBackupPath = $this->oWizard->GetParameter('db_backup_path', '');
  175. if ($sInstallMode == '')
  176. {
  177. $sDBBackupPath = APPROOT.'data/'.ITOP_APPLICATION.strftime('-backup-%Y-%m-%d.zip');
  178. $bDBBackup = true;
  179. $aPreviousInstance = SetupUtils::GetPreviousInstance(APPROOT);
  180. if ($aPreviousInstance['found'])
  181. {
  182. $sInstallMode = 'upgrade';
  183. $sSourceDir = APPROOT;
  184. $sDBServer = $aPreviousInstance['db_server'];
  185. $sDBUser = $aPreviousInstance['db_user'];
  186. $sDBPwd = $aPreviousInstance['db_pwd'];
  187. $sDBName = $aPreviousInstance['db_name'];
  188. $sDBPrefix = $aPreviousInstance['db_prefix'];
  189. //TODO: check if we can run the backup
  190. $sStyle = '';
  191. }
  192. else
  193. {
  194. $sInstallMode = 'install';
  195. }
  196. }
  197. $sUpgradeInfoStyle = '';
  198. if ($sInstallMode == 'install')
  199. {
  200. $sUpgradeInfoStyle = ' style="display: none;" ';
  201. }
  202. $oPage->add('<h2>What do you want to do?</h2>');
  203. $sChecked = ($sInstallMode == 'install') ? ' checked ' : '';
  204. $oPage->p('<input id="radio_install" type="radio" name="install_mode" value="install"'.$sChecked.'/><label for="radio_install">&nbsp;Install a new '.ITOP_APPLICATION.'</label>');
  205. $sChecked = ($sInstallMode == 'upgrade') ? ' checked ' : '';
  206. $oPage->p('<input id="radio_update" type="radio" name="install_mode" value="upgrade"'.$sChecked.'/><label for="radio_update">&nbsp;Upgrade an existing '.ITOP_APPLICATION.' instance</label>');
  207. //$oPage->add('<fieldset id="upgrade_info"'.$sUpgradeInfoStyle.'>');
  208. //$oPage->add('<legend>Information about the previous instance:</legend>');
  209. $oPage->add('<table id="upgrade_info"'.$sUpgradeInfoStyle.'>');
  210. $oPage->add('<tr><td>Location on the disk:</td><td><input id="source_dir" type="text" name="source_dir" value="'.htmlentities($sSourceDir, ENT_QUOTES, 'UTF-8').'" size="25"/></td></tr>');
  211. SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix);
  212. $aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath);
  213. $bCanBackup = true;
  214. $sMySQLDumpMessage = '';
  215. foreach($aBackupChecks as $oCheck)
  216. {
  217. if ($oCheck->iSeverity == CheckResult::ERROR)
  218. {
  219. $bCanBackup = false;
  220. $sMySQLDumpMessage .= '<img src="../images/error.png"/>&nbsp;<b> Warning:</b> '.$oCheck->sLabel;
  221. }
  222. else
  223. {
  224. $sMySQLDumpMessage .= '<img src="../images/validation_ok.png"/> '.$oCheck->sLabel.' ';
  225. }
  226. }
  227. $sChecked = ($bCanBackup && ($bDBBackup == 'install')) ? ' checked ' : '';
  228. $sDisabled = $bCanBackup ? '' : ' disabled ';
  229. $oPage->add('<tr><td colspan="2"><input id="db_backup" type="checkbox" name="db_backup"'.$sChecked.$sDisabled.' value="1"/>&nbsp;Backup the '.ITOP_APPLICATION.' database before upgrading</td></tr>');
  230. $oPage->add('<tr><td colspan="2">Save the backup to: <input id="db_backup_path" type="text" name="db_backup_path" '.$sDisabled.'value="'.htmlentities($sDBBackupPath, ENT_QUOTES, 'UTF-8').'" size="25"/></td></tr>');
  231. $fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath);
  232. $sMessage = '';
  233. if ($fFreeSpace !== false)
  234. {
  235. $sMessage .= SetupUtils::HumanReadableSize($fFreeSpace).' free in '.dirname($sDBBackupPath);
  236. }
  237. $oPage->add('<tr><td colspan="2">');
  238. $oPage->add($sMySQLDumpMessage.'<br/><span id="backup_info" style="font-size:small;color:#696969;">'.$sMessage.'</span></td></tr>');
  239. $oPage->add('</table>');
  240. //$oPage->add('</fieldset>');
  241. $oPage->add_ready_script(
  242. <<<EOF
  243. $("#radio_update").bind('change', function() { if (this.checked ) { $('#upgrade_info').show(); WizardUpdateButtons(); } else { $('#upgrade_info').hide(); } });
  244. $("#radio_install").bind('change', function() { if (this.checked ) { $('#upgrade_info').hide(); WizardUpdateButtons(); } else { $('#upgrade_info').show(); } });
  245. $("#source_dir").bind('change keyup', function() { WizardAsyncAction('check_path', { source_dir: $('#source_dir').val() }); });
  246. $("#db_backup_path").bind('change keyup', function() { WizardAsyncAction('check_backup', { db_backup_path: $('#db_backup_path').val() }); });
  247. EOF
  248. );
  249. }
  250. public function AsyncAction(WebPage $oPage, $sCode, $aParameters)
  251. {
  252. switch($sCode)
  253. {
  254. case 'check_path':
  255. $sSourceDir = $aParameters['source_dir'];
  256. $aPreviousInstance = SetupUtils::GetPreviousInstance($sSourceDir);
  257. if ($aPreviousInstance['found'])
  258. {
  259. $sDBServer = htmlentities($aPreviousInstance['db_server'], ENT_QUOTES, 'UTF-8');
  260. $sDBUser = htmlentities($aPreviousInstance['db_user'], ENT_QUOTES, 'UTF-8');
  261. $sDBPwd = htmlentities($aPreviousInstance['db_pwd'], ENT_QUOTES, 'UTF-8');
  262. $sDBName = htmlentities($aPreviousInstance['db_name'], ENT_QUOTES, 'UTF-8');
  263. $sDBPrefix = htmlentities($aPreviousInstance['db_prefix'], ENT_QUOTES, 'UTF-8');
  264. $oPage->add_ready_script(
  265. <<<EOF
  266. $("#db_server").val('$sDBServer');
  267. $("#db_user").val('$sDBUser');
  268. $("#db_pwd").val('$sDBPwd');
  269. $("#db_name").val('$sDBName');
  270. $("#db_prefix").val('$sDBPrefix');
  271. EOF
  272. );
  273. }
  274. break;
  275. case 'check_db':
  276. SetupUtils:: AsyncCheckDB($oPage, $aParameters);
  277. break;
  278. case 'check_backup':
  279. $sDBBackupPath = $aParameters['db_backup_path'];
  280. $fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath);
  281. if ($fFreeSpace !== false)
  282. {
  283. $sMessage = htmlentities(SetupUtils::HumanReadableSize($fFreeSpace).' free in '.dirname($sDBBackupPath), ENT_QUOTES, 'UTF-8');
  284. $oPage->add_ready_script(
  285. <<<EOF
  286. $("#backup_info").html('$sMessage');
  287. EOF
  288. );
  289. }
  290. else
  291. {
  292. $oPage->add_ready_script(
  293. <<<EOF
  294. $("#backup_info").html('');
  295. EOF
  296. );
  297. }
  298. break;
  299. }
  300. }
  301. /**
  302. * Tells whether the "Next" button should be enabled interactively
  303. * @return string A piece of javascript code returning either true or false
  304. */
  305. public function JSCanMoveForward()
  306. {
  307. return
  308. <<<EOF
  309. if ($("#radio_install").attr("checked") == "checked")
  310. {
  311. ValidateField("db_name", false);
  312. ValidateField("db_new_name", false);
  313. ValidateField("db_prefix", false);
  314. return true;
  315. }
  316. else
  317. {
  318. var bRet = ($("#wiz_form").data("db_connection") !== "error");
  319. bRet = ValidateField("db_name", true) && bRet;
  320. bRet = ValidateField("db_new_name", true) && bRet;
  321. bRet = ValidateField("db_prefix", true) && bRet;
  322. return bRet;
  323. }
  324. EOF
  325. ;
  326. }
  327. }
  328. /**
  329. * Upgrade information
  330. */
  331. class WizStepDetectedInfo extends WizardStep
  332. {
  333. public function GetTitle()
  334. {
  335. return 'Detected Info';
  336. }
  337. public function GetPossibleSteps()
  338. {
  339. return array('WizStepUpgradeKeep', 'WizStepUpgradeAuto', 'WizStepLicense2');
  340. }
  341. public function ProcessParams($bMoveForward = true)
  342. {
  343. return array('class' => 'WizStepLicense2', 'state' => '');
  344. }
  345. public function Display(WebPage $oPage)
  346. {
  347. $oPage->p('Info about the detected version');
  348. $sSourceDir = $this->oWizard->GetParameter('source_dir', '');
  349. $aInstalledModules = SetupUtils::AnalyzeInstallation($this->oWizard);
  350. $sVersion = $aInstalledModules[ROOT_MODULE]['version_db'];
  351. if (preg_match('/^([0-9]+)\.([0-9]+)\.([0-9]+)\.(.*)$/', $sVersion, $aMatches))
  352. {
  353. $sVersion = $aMatches[1].'.'.$aMatches[2].'.'.$aMatches[3];
  354. }
  355. $sKnownManifestFile = APPROOT.'setup/known-versions/'.$sVersion.'/manifest.xml';
  356. if ($sSourceDir != '')
  357. {
  358. if (file_exists($sKnownManifestFile))
  359. {
  360. $aDMchanges = SetupUtils::CheckDataModelFiles($sKnownManifestFile, $sSourceDir);
  361. $aPortalChanges = SetupUtils::CheckPortalFiles($sKnownManifestFile, $sSourceDir);
  362. $aCodeChanges = SetupUtils::CheckApplicationFiles($sKnownManifestFile, $sSourceDir);
  363. $oPage->add("Changes detected compared to $sVersion:<br/>DataModel:<br/><pre>".print_r($aDMchanges, true)."</pre><br/>Portal:<br/><pre>".print_r($aPortalChanges, true)."</pre><br/>Code:<br/><pre>".print_r($aCodeChanges, true)."</pre>");
  364. }
  365. else
  366. {
  367. $oPage->p("Unknown version $sVersion. Do you want to upgrade anyway ??? NOT GUARANTEED AT ALL !!!");
  368. }
  369. }
  370. else
  371. {
  372. $oPage->p("No source dir provided assuming that the installed version '$sVersion' is genuine iTop build...");
  373. }
  374. }
  375. }
  376. /**
  377. * Keep or Upgrade choice
  378. */
  379. class WizStepUpgradeKeep extends WizardStep
  380. {
  381. public function GetTitle()
  382. {
  383. return 'Keep or Upgrade';
  384. }
  385. public function GetPossibleSteps()
  386. {
  387. return array('WizStepModulesChoice');
  388. }
  389. public function ProcessParams($bMoveForward = true)
  390. {
  391. return array('class' => 'WizStepModulesChoice', 'state' => 'start_upgrade');
  392. }
  393. public function Display(WebPage $oPage)
  394. {
  395. $oPage->p('Keep or Upgrade the data model');
  396. }
  397. }
  398. /**
  399. * Automatic Upgrade info
  400. */
  401. class WizStepUpgradeAuto extends WizardStep
  402. {
  403. public function GetTitle()
  404. {
  405. return 'Upgrade Information';
  406. }
  407. public function GetPossibleSteps()
  408. {
  409. return array('WizStepModulesChoice');
  410. }
  411. public function ProcessParams($bMoveForward = true)
  412. {
  413. return array('class' => 'WizStepModulesChoice', 'state' => 'start_upgrade');
  414. }
  415. public function Display(WebPage $oPage)
  416. {
  417. $oPage->p('Automatic Upgrade information');
  418. }
  419. }
  420. /**
  421. * License acceptation screen
  422. */
  423. class WizStepLicense extends WizardStep
  424. {
  425. public function GetTitle()
  426. {
  427. return 'License Agreement';
  428. }
  429. public function GetPossibleSteps()
  430. {
  431. return array('WizStepDBParams');
  432. }
  433. public function ProcessParams($bMoveForward = true)
  434. {
  435. $this->oWizard->SaveParameter('accept_license', 'no');
  436. return array('class' => 'WizStepDBParams', 'state' => '');
  437. }
  438. public function Display(WebPage $oPage)
  439. {
  440. $aLicenses = array();
  441. foreach (glob(APPROOT.'setup/licenses/*.xml') as $sFile)
  442. {
  443. $oXml = simplexml_load_file($sFile);
  444. foreach($oXml->license as $oLicense)
  445. {
  446. $aLicenses[] = $oLicense;
  447. }
  448. }
  449. $oPage->add('<h2>Licenses agreements for the components of '.ITOP_APPLICATION.'</h2>');
  450. $oPage->add_style('div a.no-arrow { background:transparent; padding-left:0;}');
  451. $oPage->add_style('.toggle { cursor:pointer; text-decoration:underline; color:#1C94C4; }');
  452. $oPage->add('<fieldset>');
  453. $oPage->add('<legend>Components of '.ITOP_APPLICATION.'</legend>');
  454. $oPage->add('<ul>');
  455. foreach($aLicenses as $index => $oLicense)
  456. {
  457. $oPage->add('<li><b>'.$oLicense->product.'</b>, licensed by '.$oLicense->author.' under the <b>'.$oLicense->license_type.' license</b>. (<span class="toggle" id="toggle_'.$index.'">Details</span>)');
  458. $oPage->add('<div id="license_'.$index.'" class="license_text" style="display:none;overflow:auto;max-height:10em;font-size:small;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;">'.$oLicense->text.'<div>');
  459. $oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");');
  460. $oPage->add_ready_script('$("#toggle_'.$index.'").click( function() { $("#license_'.$index.'").toggle(); } );');
  461. }
  462. $oPage->add('</ul>');
  463. $oPage->add('</fieldset>');
  464. $sChecked = ($this->oWizard->GetParameter('accept_license', 'no') == 'yes') ? ' checked ' : '';
  465. $oPage->p('<input type="checkbox" name="accept_license" id="accept" value="yes"'.$sChecked.'><label for="accept">&nbsp;I accept the terms of the licenses of the '.count($aLicenses).' components mentioned above.</label>');
  466. $oPage->add_ready_script('$("#accept").bind("click change", function() { WizardUpdateButtons(); });');
  467. }
  468. /**
  469. * Tells whether the "Next" button should be enabled interactively
  470. * @return string A piece of javascript code returning either true or false
  471. */
  472. public function JSCanMoveForward()
  473. {
  474. return 'return ($("#accept").attr("checked") === "checked");';
  475. }
  476. }
  477. /**
  478. * License acceptation screen (when upgrading)
  479. */
  480. class WizStepLicense2 extends WizStepLicense
  481. {
  482. public function GetPossibleSteps()
  483. {
  484. return array('WizStepUpgradeKeep', 'WizStepUpgradeAuto');
  485. }
  486. public function ProcessParams($bMoveForward = true)
  487. {
  488. return array('class' => 'WizStepUpgradeAuto', 'state' => '');
  489. }
  490. }
  491. /**
  492. * Database Connection parameters screen
  493. */
  494. class WizStepDBParams extends WizardStep
  495. {
  496. public function GetTitle()
  497. {
  498. return 'Database Configuration';
  499. }
  500. public function GetPossibleSteps()
  501. {
  502. return array('WizStepAdminAccount');
  503. }
  504. public function ProcessParams($bMoveForward = true)
  505. {
  506. $this->oWizard->SaveParameter('db_server', '');
  507. $this->oWizard->SaveParameter('db_user', '');
  508. $this->oWizard->SaveParameter('db_pwd', '');
  509. $this->oWizard->SaveParameter('db_name', '');
  510. $this->oWizard->SaveParameter('db_prefix', '');
  511. $this->oWizard->SaveParameter('new_db_name', '');
  512. $this->oWizard->SaveParameter('create_db', '');
  513. $this->oWizard->SaveParameter('db_new_name', '');
  514. return array('class' => 'WizStepAdminAccount', 'state' => '');
  515. }
  516. public function Display(WebPage $oPage)
  517. {
  518. $oPage->add('<h2>Configuration of the database connection:</h2>');
  519. $sDBServer = $this->oWizard->GetParameter('db_server', '');
  520. $sDBUser = $this->oWizard->GetParameter('db_user', '');
  521. $sDBPwd = $this->oWizard->GetParameter('db_pwd', '');
  522. $sDBName = $this->oWizard->GetParameter('db_name', '');
  523. $sDBPrefix = $this->oWizard->GetParameter('db_prefix', '');
  524. $sNewDBName = $this->oWizard->GetParameter('db_new_name', false);
  525. $oPage->add('<table>');
  526. SetupUtils::DisplayDBParameters($oPage, true, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sNewDBName);
  527. $oPage->add('</table>');
  528. $sCreateDB = $this->oWizard->GetParameter('create_db', 'no');
  529. if ($sCreateDB == 'no')
  530. {
  531. $oPage->add_ready_script('$("#existing_db").attr("checked", "checked");');
  532. }
  533. else
  534. {
  535. $oPage->add_ready_script('$("#create_db").attr("checked", "checked");');
  536. }
  537. }
  538. public function AsyncAction(WebPage $oPage, $sCode, $aParameters)
  539. {
  540. switch($sCode)
  541. {
  542. case 'check_db':
  543. SetupUtils:: AsyncCheckDB($oPage, $aParameters);
  544. break;
  545. }
  546. }
  547. /**
  548. * Tells whether the "Next" button should be enabled interactively
  549. * @return string A piece of javascript code returning either true or false
  550. */
  551. public function JSCanMoveForward()
  552. {
  553. return
  554. <<<EOF
  555. if ($("#wiz_form").data("db_connection") === "error") return false;
  556. var bRet = true;
  557. bRet = ValidateField("db_name", true) && bRet;
  558. bRet = ValidateField("db_new_name", true) && bRet;
  559. bRet = ValidateField("db_prefix", true) && bRet;
  560. return bRet;
  561. EOF
  562. ;
  563. }
  564. }
  565. /**
  566. * Administrator Account definition screen
  567. */
  568. class WizStepAdminAccount extends WizardStep
  569. {
  570. public function GetTitle()
  571. {
  572. return 'Administrator Account';
  573. }
  574. public function GetPossibleSteps()
  575. {
  576. return array('WizStepMiscParams');
  577. }
  578. public function ProcessParams($bMoveForward = true)
  579. {
  580. $this->oWizard->SaveParameter('admin_user', '');
  581. $this->oWizard->SaveParameter('admin_pwd', '');
  582. $this->oWizard->SaveParameter('confirm_pwd', '');
  583. $this->oWizard->SaveParameter('admin_language', 'EN US');
  584. return array('class' => 'WizStepMiscParams', 'state' => '');
  585. }
  586. public function Display(WebPage $oPage)
  587. {
  588. $sAdminUser = $this->oWizard->GetParameter('admin_user', 'admin');
  589. $sAdminPwd = $this->oWizard->GetParameter('admin_pwd', '');
  590. $sConfirmPwd = $this->oWizard->GetParameter('confirm_pwd', '');
  591. $sAdminLanguage = $this->oWizard->GetParameter('admin_language', 'EN US');
  592. $oPage->add('<h2>Definition of the Administrator Account</h2>');
  593. $oPage->add('<fieldset>');
  594. $oPage->add('<legend>Administrator Account</legend>');
  595. $oPage->add('<table>');
  596. $oPage->add('<tr><td>Login: </td><td><input id="admin_user" name="admin_user" type="text" size="25" maxlength="64" value="'.htmlentities($sAdminUser, ENT_QUOTES, 'UTF-8').'"><span id="v_admin_user"/></td><tr>');
  597. $oPage->add('<tr><td>Password: </td><td><input id="admin_pwd" name="admin_pwd" type="password" size="25" maxlength="64" value="'.htmlentities($sAdminPwd, ENT_QUOTES, 'UTF-8').'"><span id="v_admin_pwd"/></td><tr>');
  598. $oPage->add('<tr><td>Confirm password: </td><td><input id="confirm_pwd" name="confirm_pwd" type="password" size="25" maxlength="64" value="'.htmlentities($sConfirmPwd, ENT_QUOTES, 'UTF-8').'"></td><tr>');
  599. $sSourceDir = APPROOT.'dictionaries/';
  600. $aLanguages = SetupUtils::GetAvailableLanguages($sSourceDir);
  601. $oPage->add('<tr><td>Language: </td><td>');
  602. $oPage->add(SetupUtils::GetLanguageSelect($sSourceDir, 'admin_language', $sAdminLanguage));
  603. $oPage->add('</td></tr>');
  604. $oPage->add('</table>');
  605. $oPage->add('</fieldset>');
  606. $oPage->add_ready_script(
  607. <<<EOF
  608. $('#admin_user').bind('change keyup', function() { WizardUpdateButtons(); } );
  609. $('#admin_pwd').bind('change keyup', function() { WizardUpdateButtons(); } );
  610. $('#confirm_pwd').bind('change keyup', function() { WizardUpdateButtons(); } );
  611. EOF
  612. );
  613. }
  614. /**
  615. * Tells whether the "Next" button should be enabled interactively
  616. * @return string A piece of javascript code returning either true or false
  617. */
  618. public function JSCanMoveForward()
  619. {
  620. return
  621. <<<EOF
  622. bRet = ($('#admin_user').val() != '');
  623. if (!bRet)
  624. {
  625. $("#v_admin_user").html('<img src="../images/validation_error.png" title="This field cannot be empty"/>');
  626. }
  627. else
  628. {
  629. $("#v_admin_user").html('');
  630. }
  631. bPasswordsMatch = ($('#admin_pwd').val() == $('#confirm_pwd').val());
  632. if (!bPasswordsMatch)
  633. {
  634. $('#v_admin_pwd').html('<img src="../images/validation_error.png" title="Retyped password do not match"/>');
  635. }
  636. else
  637. {
  638. $('#v_admin_pwd').html('');
  639. }
  640. bRet = bPasswordsMatch && bRet;
  641. return bRet;
  642. EOF
  643. ;
  644. }}
  645. /**
  646. * Miscellaneous Parameters (URL, Sample Data)
  647. */
  648. class WizStepMiscParams extends WizardStep
  649. {
  650. public function GetTitle()
  651. {
  652. return 'Miscellaneous Parameters';
  653. }
  654. public function GetPossibleSteps()
  655. {
  656. return array('WizStepModulesChoice');
  657. }
  658. public function ProcessParams($bMoveForward = true)
  659. {
  660. $this->oWizard->SaveParameter('default_language', '');
  661. $this->oWizard->SaveParameter('application_url', '');
  662. $this->oWizard->SaveParameter('sample_data', 'yes');
  663. return array('class' => 'WizStepModulesChoice', 'state' => 'start_install');
  664. }
  665. public function Display(WebPage $oPage)
  666. {
  667. $sDefaultLanguage = $this->oWizard->GetParameter('default_language', $this->oWizard->GetParameter('admin_language'));
  668. $sApplicationURL = $this->oWizard->GetParameter('application_url', utils::GetDefaultUrlAppRoot());
  669. $sSampleData = $this->oWizard->GetParameter('sample_data', 'yes');
  670. $oPage->add('<h2>Additional parameters</h2>');
  671. $oPage->add('<fieldset>');
  672. $oPage->add('<legend>Default Language</legend>');
  673. $oPage->add('<table>');
  674. $sSourceDir = APPROOT.'dictionaries/';
  675. $aLanguages = SetupUtils::GetAvailableLanguages($sSourceDir);
  676. $oPage->add('<tr><td>Default Language: </td><td>');
  677. $oPage->add(SetupUtils::GetLanguageSelect($sSourceDir, 'default_language', $sDefaultLanguage));
  678. $oPage->add('</td></tr>');
  679. $oPage->add('</table>');
  680. $oPage->add('</fieldset>');
  681. $oPage->add('<fieldset>');
  682. $oPage->add('<legend>Application URL</legend>');
  683. $oPage->add('<table>');
  684. $oPage->add('<tr><td>URL: </td><td><input id="application_url" name="application_url" type="text" size="35" maxlength="1024" value="'.htmlentities($sApplicationURL, ENT_QUOTES, 'UTF-8').'"><span id="v_application_url"/></td><tr>');
  685. $oPage->add('<tr><td colspan="2">Change the value above if the end-users will be accessing the application by another path due to a specific configuration of the web server.</td><tr>');
  686. $oPage->add('</table>');
  687. $oPage->add('</fieldset>');
  688. $oPage->add('<fieldset>');
  689. $oPage->add('<legend>Sample Data</legend>');
  690. $oPage->add('<table>');
  691. $sChecked = ($sSampleData == 'yes') ? ' checked ' : '';
  692. $oPage->p('<input id="sample_data_yes" name="sample_data" type="radio" value="yes"'.$sChecked.'><label for="sample_data_yes">&nbsp;I am installing a <b>demo or test</b> instance, populate the database with some demo data.');
  693. $sChecked = ($sSampleData == 'no') ? ' checked ' : '';
  694. $oPage->p('<input id="sample_data_no" name="sample_data" type="radio" value="no"'.$sChecked.'><label for="sample_data_no">&nbsp;I am installing a <b>production</b> instance, create an empty database to start from.');
  695. $oPage->add('</table>');
  696. $oPage->add('</fieldset>');
  697. $oPage->add_ready_script(
  698. <<<EOF
  699. $('#application_url').bind('change keyup', function() { WizardUpdateButtons(); } );
  700. EOF
  701. );
  702. }
  703. /**
  704. * Tells whether the "Next" button should be enabled interactively
  705. * @return string A piece of javascript code returning either true or false
  706. */
  707. public function JSCanMoveForward()
  708. {
  709. return
  710. <<<EOF
  711. bRet = ($('#application_url').val() != '');
  712. if (!bRet)
  713. {
  714. $("#v_application_url").html('<img src="../images/validation_error.png" title="This field cannot be empty"/>');
  715. }
  716. else
  717. {
  718. $("#v_application_url").html('');
  719. }
  720. return bRet;
  721. EOF
  722. ;
  723. }
  724. }
  725. /**
  726. * Choice of the modules to be installed
  727. */
  728. class WizStepModulesChoice extends WizardStep
  729. {
  730. public function GetTitle()
  731. {
  732. $aStepInfo = $this->GetStepInfo();
  733. $sTitle = isset($aStepInfo['title']) ? $aStepInfo['title'] : 'Modules selection';
  734. return $sTitle;
  735. }
  736. public function GetPossibleSteps()
  737. {
  738. return array('WizStepModulesChoice', 'WizStepSummary');
  739. }
  740. public function ProcessParams($bMoveForward = true)
  741. {
  742. // Accumulates the selected modules:
  743. $index = $this->GetStepIndex();
  744. // use json_encode:decode to store a hash array: step_id => array(input_name => selected_input_id)
  745. $aSelectedChoices = json_decode($this->oWizard->GetParameter('selected_components', '{}'), true);
  746. $aSelected = utils::ReadParam('choice', array());
  747. $aSelectedChoices[$index] = $aSelected;
  748. $this->oWizard->SetParameter('selected_components', json_encode($aSelectedChoices));
  749. if ($this->GetStepInfo($index) == null)
  750. {
  751. throw new Exception('Internal error: invalid step "'.$index.'" for the choice of modules.');
  752. }
  753. else if ($bMoveForward)
  754. {
  755. if ($this->GetStepInfo(1 + $index) != null)
  756. {
  757. return array('class' => 'WizStepModulesChoice', 'state' => (1+$index));
  758. }
  759. else
  760. {
  761. // Exiting this step of the wizard, let's convert the selection into a list of modules
  762. $aModules = array();
  763. $sDisplayChoices = '<ul>';
  764. for($i = 0; $i <= $index; $i++)
  765. {
  766. $aStepInfo = $this->GetStepInfo($i);
  767. $sDisplayChoices .= $this->GetSelectedModules($aStepInfo, $aSelectedChoices[$i], $aModules);
  768. }
  769. $sDisplayChoices .= '</ul>';
  770. $this->oWizard->SetParameter('selected_modules', json_encode(array_keys($aModules)));
  771. $this->oWizard->SetParameter('display_choices', $sDisplayChoices);
  772. return array('class' => 'WizStepSummary', 'state' => '');
  773. }
  774. }
  775. }
  776. public function Display(WebPage $oPage)
  777. {
  778. $this->DisplayStep($oPage);
  779. }
  780. protected function DisplayStep($oPage)
  781. {
  782. $aStepInfo = $this->GetStepInfo();
  783. $oPage->add_style("div.choice { margin: 0.5em;}");
  784. $oPage->add_style("div.description { margin-left: 2em; }");
  785. $oPage->add_style(".choice-disabled { color: #999; }");
  786. $oPage->add('<table><tr>');
  787. $sBannerPath = isset($aStepInfo['banner']) ? $aStepInfo['banner'] : '';
  788. if (!empty($sBannerPath))
  789. {
  790. if (substr($sBannerPath, 0, 1) == '/')
  791. {
  792. // absolute path, means relative to APPROOT
  793. $sBannerUrl = utils::GetDefaultUrlAppRoot().$sBannerPath;
  794. }
  795. else
  796. {
  797. // relative path: i.e. relative to the directory containing the XML file
  798. $sFullPath = dirname($this->GetSourceFilePath()).'/'.$sBannerPath;
  799. $sRealPath = realpath($sFullPath);
  800. $sBannerUrl = utils::GetDefaultUrlAppRoot().str_replace(realpath(APPROOT), '', $sRealPath);
  801. }
  802. $oPage->add('<td><img src="'.$sBannerUrl.'"/><td>');
  803. }
  804. $sDescription = isset($aStepInfo['description']) ? $aStepInfo['description'] : '';
  805. $oPage->add('<td>'.$sDescription.'<td>');
  806. $oPage->add('</tr></table>');
  807. // Build the default choices
  808. $aDefaults = array();
  809. $this->GetDefaults($aStepInfo, $aDefaults);
  810. $index = $this->GetStepIndex();
  811. // retrieve the saved selection
  812. // use json_encode:decode to store a hash array: step_id => array(input_name => selected_input_id)
  813. $aParameters = json_decode($this->oWizard->GetParameter('selected_components', '{}'), true);
  814. if (!isset($aParameters[$index]))
  815. {
  816. $aParameters[$index] = $aDefaults;
  817. }
  818. $aSelectedComponents = $aParameters[$index];
  819. $oPage->add('<div style="max-height:250px;overflow:auto;border:#ccc 1px solid;">');
  820. $this->DisplayOptions($oPage, $aStepInfo, $aSelectedComponents);
  821. $oPage->add('</div>');
  822. $oPage->add_script(
  823. <<<EOF
  824. function CheckChoice(sChoiceId)
  825. {
  826. console.log('Ici !!');
  827. var oElement = $('#'+sChoiceId);
  828. var bChecked = (oElement.attr('checked') == 'checked');
  829. var sId = sChoiceId.replace('choice', '');
  830. if ((oElement.attr('type') == 'radio') && bChecked)
  831. {
  832. // Only the radio that is clicked is notified, let's warn the other radio buttons
  833. sName = oElement.attr('name');
  834. $('input[name="'+sName+'"]').each(function() {
  835. var sRadioId = $(this).attr('id');
  836. if (sRadioId != sChoiceId)
  837. {
  838. CheckChoice(sRadioId);
  839. }
  840. });
  841. }
  842. $('#sub_choices'+sId).each(function() {
  843. if (!bChecked)
  844. {
  845. $(this).addClass('choice-disabled');
  846. }
  847. else
  848. {
  849. $(this).removeClass('choice-disabled');
  850. }
  851. $('input', this).each(function() {
  852. if (bChecked)
  853. {
  854. if ($(this).attr('data-disabled') != 'disabled')
  855. {
  856. // Only non-mandatory fields can be enabled
  857. $(this).removeAttr('disabled');
  858. }
  859. }
  860. else
  861. {
  862. $(this).attr('disabled', 'disabled');
  863. }
  864. });
  865. });
  866. }
  867. EOF
  868. );
  869. $oPage->add_ready_script(
  870. <<<EOF
  871. $('.wiz-choice').bind('change', function() { CheckChoice($(this).attr('id')); } );
  872. $('.wiz-choice').trigger('change');
  873. EOF
  874. );
  875. }
  876. protected function GetDefaults($aInfo, &$aDefaults, $sParentId = '')
  877. {
  878. $aOptions = isset($aInfo['options']) ? $aInfo['options'] : array();
  879. foreach($aOptions as $index => $aChoice)
  880. {
  881. $sChoiceId = $sParentId.'_'.$index;
  882. if (isset($aChoice['default']) && $aChoice['default'])
  883. {
  884. $aDefaults[$sChoiceId] = $sChoiceId;
  885. }
  886. if (isset($aChoice['sub_options']))
  887. {
  888. $this->GetDefaults($aChoice['sub_options'], $aDefaults, $sChoiceId);
  889. }
  890. $index++;
  891. }
  892. $aAlternatives = isset($aInfo['alternatives']) ? $aInfo['alternatives'] : array();
  893. $sChoiceName = null;
  894. foreach($aAlternatives as $index => $aChoice)
  895. {
  896. $sChoiceId = $sParentId.'_'.$index;
  897. if ($sChoiceName == null)
  898. {
  899. $sChoiceName = $sChoiceId;
  900. }
  901. if (isset($aChoice['default']) && $aChoice['default'])
  902. {
  903. $aDefaults[$sChoiceName] = $sChoiceId;
  904. }
  905. if (isset($aChoice['sub_options']))
  906. {
  907. $this->GetDefaults($aChoice['sub_options'], $aDefaults, $sChoiceId);
  908. }
  909. $index++;
  910. }
  911. }
  912. /**
  913. * Converts the list of selected "choices" into a list of "modules": take into account the selected and the mandatory modules
  914. * @param hash $aInfo Info about the "choice" array('options' => array(...), 'alternatives' => array(...))
  915. * @param hash $aSelectedChoices List of selected choices array('name' => 'selected_value_id')
  916. * @param hash $aModules Return parameter: List of selected modules array('module_id' => true)
  917. * @param string $sParentId Used for recursion
  918. * @return void
  919. */
  920. protected function GetSelectedModules($aInfo, $aSelectedChoices, &$aModules, $sParentId = '', $sDisplayChoices = '')
  921. {
  922. if ($sParentId == '')
  923. {
  924. // Check once (before recursing) that the hidden modules are selected
  925. foreach(SetupUtils::AnalyzeInstallation($this->oWizard) as $sModuleId => $aModule)
  926. {
  927. if ($sModuleId != ROOT_MODULE)
  928. {
  929. if (($aModule['category'] == 'authentication') || (!$aModule['visible']))
  930. {
  931. $aModules[$sModuleId] = true;
  932. }
  933. }
  934. }
  935. }
  936. $aOptions = isset($aInfo['options']) ? $aInfo['options'] : array();
  937. foreach($aOptions as $index => $aChoice)
  938. {
  939. $sChoiceId = $sParentId.'_'.$index;
  940. if ( (isset($aChoice['mandatory']) && $aChoice['mandatory']) ||
  941. (isset($aSelectedChoices[$sChoiceId]) && ($aSelectedChoices[$sChoiceId] == $sChoiceId)) )
  942. {
  943. $sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
  944. if (isset($aChoice['modules']))
  945. {
  946. foreach($aChoice['modules'] as $sModuleId)
  947. {
  948. $aModules[$sModuleId] = true; // store the Id of the selected module
  949. }
  950. }
  951. // Recurse only for selected choices
  952. if (isset($aChoice['sub_options']))
  953. {
  954. $sDisplayChoices .= '<ul>';
  955. $sDisplayChoices = $this->GetSelectedModules($aChoice['sub_options'], $aSelectedChoices, $aModules, $sChoiceId, $sDisplayChoices);
  956. $sDisplayChoices .= '</ul>';
  957. }
  958. $sDisplayChoices .= '</li>';
  959. }
  960. $index++;
  961. }
  962. $aAlternatives = isset($aInfo['alternatives']) ? $aInfo['alternatives'] : array();
  963. $sChoiceName = null;
  964. foreach($aAlternatives as $index => $aChoice)
  965. {
  966. $sChoiceId = $sParentId.'_'.$index;
  967. if ($sChoiceName == null)
  968. {
  969. $sChoiceName = $sChoiceId;
  970. }
  971. if ( (isset($aChoice['mandatory']) && $aChoice['mandatory']) ||
  972. (isset($aSelectedChoices[$sChoiceName]) && ($aSelectedChoices[$sChoiceName] == $sChoiceId)) )
  973. {
  974. $sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
  975. if (isset($aChoice['modules']))
  976. {
  977. foreach($aChoice['modules'] as $sModuleId)
  978. {
  979. $aModules[$sModuleId] = true; // store the Id of the selected module
  980. }
  981. }
  982. // Recurse only for selected choices
  983. if (isset($aChoice['sub_options']))
  984. {
  985. $sDisplayChoices .= '<ul>';
  986. $sDisplayChoices = $this->GetSelectedModules($aChoice['sub_options'], $aSelectedChoices, $aModules, $sChoiceId, $sDisplayChoices);
  987. $sDisplayChoices .= '</ul>';
  988. }
  989. $sDisplayChoices .= '</li>';
  990. }
  991. $index++;
  992. }
  993. return $sDisplayChoices;
  994. }
  995. protected function GetStepIndex()
  996. {
  997. switch($this->sCurrentState)
  998. {
  999. case 'start_install':
  1000. case 'start_upgrade':
  1001. $index = 0;
  1002. break;
  1003. default:
  1004. $index = (integer)$this->sCurrentState;
  1005. }
  1006. return $index;
  1007. }
  1008. protected function GetStepInfo($idx = null)
  1009. {
  1010. $aStepInfo = null;
  1011. if ($idx === null)
  1012. {
  1013. $index = $this->GetStepIndex();
  1014. }
  1015. else
  1016. {
  1017. $index = $idx;
  1018. }
  1019. if (@file_exists($this->GetSourceFilePath()))
  1020. {
  1021. $aParams = new XMLParameters($this->GetSourceFilePath());
  1022. $aSteps = $aParams->Get('steps', array());
  1023. if (array_key_exists($index, $aSteps))
  1024. {
  1025. $aStepInfo = $aSteps[$index];
  1026. }
  1027. }
  1028. else if ($idx == 0)
  1029. {
  1030. // No wizard configuration provided, build a standard one:
  1031. $aAvailableModules = SetupUtils::AnalyzeInstallation($this->oWizard);
  1032. $aStepInfo = array(
  1033. 'title' => 'Modules Selection',
  1034. 'description' => '<h2>Select the modules to install. You can launch the installation again to install new modules, but you cannot remove already installed modules.</h2>',
  1035. 'banner' => '/images/modules.png',
  1036. 'options' => array(),
  1037. );
  1038. try
  1039. {
  1040. $sDefaultAppPath = utils::GetDefaultUrlAppRoot();
  1041. }
  1042. catch(Exception $e)
  1043. {
  1044. $sDefaultAppPath = '..';
  1045. }
  1046. foreach($aAvailableModules as $sModuleId => $aModule)
  1047. {
  1048. if ($sModuleId == ROOT_MODULE) continue; // Convention: the version number of the application is stored as a module named ROOT_MODULE
  1049. $sModuleLabel = $aModule['label'];
  1050. $sModuleHelp = $aModule['doc.more_information'];
  1051. $sMoreInfo = (!empty($aModule['doc.more_information'])) ? "<a href=\"$sDefaultAppPath{$aModule['doc.more_information']}\" target=\"_blank\">more info</a>": '';
  1052. if (($aModule['category'] != 'authentication') && ($aModule['visible']))
  1053. {
  1054. $aStepInfo['options'][$index] = array(
  1055. 'title' => $sModuleLabel,
  1056. 'description' => '',
  1057. 'more_info' => $sMoreInfo,
  1058. 'default' => true, // by default offer to install all modules
  1059. 'modules' => array($sModuleId),
  1060. );
  1061. switch($aModule['install']['flag'])
  1062. {
  1063. case MODULE_ACTION_MANDATORY:
  1064. $aStepInfo['options'][$index]['mandatory'] = true;
  1065. break;
  1066. }
  1067. $index++;
  1068. }
  1069. }
  1070. }
  1071. return $aStepInfo;
  1072. }
  1073. protected function DisplayOptions($oPage, $aStepInfo, $aSelectedComponents, $sParentId = '')
  1074. {
  1075. $aOptions = isset($aStepInfo['options']) ? $aStepInfo['options'] : array();
  1076. $aAlternatives = isset($aStepInfo['alternatives']) ? $aStepInfo['alternatives'] : array();
  1077. $index = 0;
  1078. foreach($aOptions as $index => $aChoice)
  1079. {
  1080. $sAttributes = '';
  1081. $sChoiceId = $sParentId.'_'.$index;
  1082. if (isset($aChoice['mandatory']) && $aChoice['mandatory'])
  1083. {
  1084. $oPage->add('<div class="choice"><input id="choice'.$sChoiceId.'" checked disabled data-disabled="disabled" type="checkbox"'.$sAttributes.'/><input type="hidden" name="choice['.$sChoiceId.']" value="'.$sChoiceId.'">&nbsp;');
  1085. }
  1086. else if (isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId))
  1087. {
  1088. $oPage->add('<div class="choice"><input class="wiz-choice" id="choice'.$sChoiceId.'" name="choice['.$sChoiceId.']" type="checkbox" checked value="'.$sChoiceId.'"/>&nbsp;');
  1089. }
  1090. else
  1091. {
  1092. $oPage->add('<div class="choice"><input class="wiz-choice" id="choice'.$sChoiceId.'" name="choice['.$sChoiceId.']" type="checkbox" value="'.$sChoiceId.'"/>&nbsp;');
  1093. }
  1094. $this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $sChoiceId);
  1095. $oPage->add('</div>');
  1096. $index++;
  1097. }
  1098. $sChoiceName = null;
  1099. foreach($aAlternatives as $index => $aChoice)
  1100. {
  1101. $sAttributes = '';
  1102. $sChoiceId = $sParentId.'_'.$index;
  1103. if ($sChoiceName == null)
  1104. {
  1105. $sChoiceName = $sChoiceId; // All radios share the same name
  1106. }
  1107. if (isset($aSelectedComponents[$sChoiceName]) && ($aSelectedComponents[$sChoiceName] == $sChoiceId))
  1108. {
  1109. $sAttributes = ' checked ';
  1110. }
  1111. $oPage->add('<div class="choice"><input class="wiz-choice" id="choice'.$sChoiceId.'" name="choice['.$sChoiceName.']" type="radio"'.$sAttributes.' value="'.$sChoiceId.'"/>&nbsp;');
  1112. $this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $sChoiceId);
  1113. $oPage->add('</div>');
  1114. $index++;
  1115. }
  1116. }
  1117. protected function DisplayChoice($oPage, $aChoice, $aSelectedComponents, $sChoiceId)
  1118. {
  1119. $oPage->add('<label for="choice'.$sChoiceId.'"><b>'.htmlentities($aChoice['title'], ENT_QUOTES, 'UTF-8').'</b></label>');
  1120. $sDescription = isset($aChoice['description']) ? htmlentities($aChoice['description'], ENT_QUOTES, 'UTF-8') : '';
  1121. $oPage->add('<div class="description">'.$sDescription.'<span id="sub_choices'.$sChoiceId.'">');
  1122. if (isset($aChoice['sub_options']))
  1123. {
  1124. $this->DisplayOptions($oPage, $aChoice['sub_options'], $aSelectedComponents, $sChoiceId);
  1125. }
  1126. $oPage->add('</span></div>');
  1127. }
  1128. protected function GetSourceFilePath()
  1129. {
  1130. return APPROOT.'datamodel/installation.xml';
  1131. }
  1132. }
  1133. /**
  1134. * Summary of the installation tasks
  1135. */
  1136. class WizStepSummary extends WizardStep
  1137. {
  1138. public function GetTitle()
  1139. {
  1140. $sMode = $this->oWizard->GetParameter('mode', 'install');
  1141. if ($sMode == 'install')
  1142. {
  1143. return 'Ready to install';
  1144. }
  1145. else
  1146. {
  1147. return 'Ready to upgrade';
  1148. }
  1149. }
  1150. public function GetPossibleSteps()
  1151. {
  1152. return array('WizStepDone');
  1153. }
  1154. /**
  1155. * Returns the label for the " Next >> " button
  1156. * @return string The label for the button
  1157. */
  1158. public function GetNextButtonLabel()
  1159. {
  1160. return ' Install ! ';
  1161. }
  1162. public function ProcessParams($bMoveForward = true)
  1163. {
  1164. return array('class' => 'WizStepDone', 'state' => '');
  1165. }
  1166. public function Display(WebPage $oPage)
  1167. {
  1168. $oPage->add_style(
  1169. <<<EOF
  1170. #params_summary {
  1171. height: 200px;
  1172. overflow: auto;
  1173. }
  1174. #params_summary div {
  1175. width:100;
  1176. margin-top:0;
  1177. padding-top: 0.5em;
  1178. padding-left: 0;
  1179. }
  1180. #params_summary div ul {
  1181. margin-left:0;
  1182. padding-left: 20px;
  1183. }
  1184. #params_summary div.closed ul {
  1185. display:none;
  1186. }
  1187. #params_summary div li {
  1188. list-style: none;
  1189. width: 100;
  1190. margin-left:0;
  1191. padding-left: 0em;
  1192. }
  1193. .title {
  1194. padding-left: 20px;
  1195. font-weight: bold;
  1196. cursor: pointer;
  1197. background: url(../images/minus.gif) 2px 2px no-repeat;
  1198. }
  1199. #params_summary div.closed .title {
  1200. background: url(../images/plus.gif) 2px 2px no-repeat;
  1201. }
  1202. #progress_content {
  1203. height: 200px;
  1204. overflow: auto;
  1205. text-align: center;
  1206. }
  1207. #installation_progress {
  1208. display: none;
  1209. }
  1210. EOF
  1211. );
  1212. $sMode = $this->oWizard->GetParameter('mode', 'install');
  1213. $sPreinstallationPhase = '';
  1214. $sDestination = ITOP_APPLICATION.(($sMode == 'install') ? ' version '.ITOP_VERSION.' is about to be installed ' : ' is about to be upgraded ');
  1215. $sDBDescription = ' <b>existing</b> database <b>'.$this->oWizard->GetParameter('db_name').'</b>';
  1216. if (($sMode == 'install') && ($this->oWizard->GetParameter('create_db') == 'yes'))
  1217. {
  1218. $sDBDescription = ' <b>new</b> database <b>'.$this->oWizard->GetParameter('db_new_name').'</b>';
  1219. }
  1220. $sDestination .= 'into the '.$sDBDescription.' on the server <b>'.$this->oWizard->GetParameter('db_server').'</b>.';
  1221. $oPage->add('<h2>'.$sDestination.'</h2>');
  1222. $oPage->add('<fieldset id="summary"><legend>Installation Parameters</legend>');
  1223. $oPage->add('<div id="params_summary">');
  1224. $oPage->add('<div class="closed"><span class="title">Database Parameters</span><ul>');
  1225. $oPage->add('<li>Server Name: '.$this->oWizard->GetParameter('db_server').'</li>');
  1226. $oPage->add('<li>DB User Name: '.$this->oWizard->GetParameter('db_user').'</li>');
  1227. $oPage->add('<li>DB user password: '.$this->oWizard->GetParameter('db_pwd').'</li>');
  1228. if (($sMode == 'install') && ($this->oWizard->GetParameter('create_db') == 'yes'))
  1229. {
  1230. $oPage->add('<li>Database Name: '.$this->oWizard->GetParameter('db_new_name').' (will be created)</li>');
  1231. }
  1232. else
  1233. {
  1234. $oPage->add('<li>Database Name: '.$this->oWizard->GetParameter('db_name').'</li>');
  1235. }
  1236. if ($this->oWizard->GetParameter('db_prefix') != '')
  1237. {
  1238. $oPage->add('<li>Prefix for the '.ITOP_APPLICATION.' tables: '.$this->oWizard->GetParameter('db_prefix').'</li>');
  1239. }
  1240. else
  1241. {
  1242. $oPage->add('<li>Prefix for the '.ITOP_APPLICATION.' tables: none</li>');
  1243. }
  1244. $oPage->add('</ul></div>');
  1245. $oPage->add('<div><span class="title">Data Model Configuration</span>');
  1246. $oPage->add($this->oWizard->GetParameter('display_choices'));
  1247. $oPage->add('</div>');
  1248. $oPage->add('<div class="closed"><span class="title">Other Parameters</span><ul>');
  1249. $oPage->add('<li>Default language: '.$this->oWizard->GetParameter('default_language').'</li>');
  1250. $oPage->add('<li>URL to access the application: '.$this->oWizard->GetParameter('application_url').'</li>');
  1251. if ($this->oWizard->GetParameter('sample_data') == 'yes')
  1252. {
  1253. $oPage->add('<li>Sample data will be loaded into the database.</li>');
  1254. }
  1255. $oPage->add('</ul></div>');
  1256. $oPage->add('<div class="closed"><span class="title">Admininistrator Account</span><ul>');
  1257. $oPage->add('<li>Login: '.$this->oWizard->GetParameter('admin_user').'</li>');
  1258. $oPage->add('<li>Password: '.$this->oWizard->GetParameter('admin_pwd').'</li>');
  1259. $oPage->add('<li>Language: '.$this->oWizard->GetParameter('admin_language').'</li>');
  1260. $oPage->add('</ul></div>');
  1261. $aMiscOptions = json_decode($this->oWizard->GetParameter('misc_options', '[]'), true /* bAssoc */);
  1262. if (count($aMiscOptions) > 0)
  1263. {
  1264. $oPage->add('<div class="closed"><span class="title">Miscellaneous Options</span><ul>');
  1265. foreach($aMiscOptions as $sKey => $sValue)
  1266. {
  1267. $oPage->add('<li>'.$sKey.': '.$sValue.'</li>');
  1268. }
  1269. $oPage->add('</ul></div>');
  1270. }
  1271. $aSelectedModules = json_decode($this->oWizard->GetParameter('selected_modules'), true);
  1272. /*
  1273. $oPage->add('<ul>Selected modules:');
  1274. sort($aSelectedModules);
  1275. foreach($aSelectedModules as $sModuleId)
  1276. {
  1277. $oPage->add('<li>'.$sModuleId.'</li>');
  1278. }
  1279. $oPage->add('</ul>');
  1280. */
  1281. $oPage->add_ready_script(
  1282. <<<EOF
  1283. $("#params_summary div").addClass('closed');
  1284. $("#params_summary .title").click(function() { $(this).parent().toggleClass('closed'); } );
  1285. $("#btn_next").bind("click.install", function(event) {
  1286. $('#summary').hide();
  1287. $('#installation_progress').show();
  1288. $(this).attr("disabled", "disabled"); event.preventDefault(); ExecuteStep("");
  1289. });
  1290. $("#wiz_form").data("installation_status", "not started")
  1291. EOF
  1292. );
  1293. // Prepare the parameters to execute the installation asynchronously
  1294. $sBackupDestination = '';
  1295. $sConfigurationFile = '';
  1296. $sDBName = $this->oWizard->GetParameter('db_name');
  1297. if ($sMode == 'upgrade')
  1298. {
  1299. if ($this->oWizard->GetParameter('db_backup', false))
  1300. {
  1301. $sSourceDir = $this->oWizard->GetParameter('source_dir', '');
  1302. if (!empty($sSourceDir))
  1303. {
  1304. $aPreviousInstance = SetupUtils::GetPreviousInstance($sSourceDir);
  1305. if ($aPreviousInstance['found'])
  1306. {
  1307. $sConfigurationFile = $aPreviousInstance['configuration_file'];
  1308. }
  1309. }
  1310. }
  1311. }
  1312. else
  1313. {
  1314. $sDBNewName = $this->oWizard->GetParameter('db_new_name', '');
  1315. if ($sDBNewName != '')
  1316. {
  1317. $sDBName = $sDBNewName; // Database will be created
  1318. }
  1319. }
  1320. $aInstallParams = array (
  1321. 'mode' => $sMode,
  1322. 'preinstall' => array (
  1323. 'copies' => array (
  1324. // 0 => array (
  1325. // 'source' => '',
  1326. // 'destination' => '',
  1327. // ),
  1328. ),
  1329. ),
  1330. 'source_dir' => 'datamodel',
  1331. 'target_env' => 'production',
  1332. 'workspace_dir' => '',
  1333. 'database' => array (
  1334. 'server' => $this->oWizard->GetParameter('db_server'),
  1335. 'user' => $this->oWizard->GetParameter('db_user'),
  1336. 'pwd' => $this->oWizard->GetParameter('db_pwd'),
  1337. 'name' => $sDBName,
  1338. 'prefix' => $this->oWizard->GetParameter('db_prefix'),
  1339. ),
  1340. 'url' => $this->oWizard->GetParameter('application_url'),
  1341. 'admin_account' => array (
  1342. 'user' => $this->oWizard->GetParameter('admin_user'),
  1343. 'pwd' => $this->oWizard->GetParameter('admin_pwd'),
  1344. 'language' => $this->oWizard->GetParameter('admin_language'),
  1345. ),
  1346. 'language' => $this->oWizard->GetParameter('default_language'),
  1347. 'selected_modules' => $aSelectedModules,
  1348. 'sample_data' => ($this->oWizard->GetParameter('sample_data', '') == 'yes') ? true : false ,
  1349. 'options' => json_decode($this->oWizard->GetParameter('misc_options', '[]'), true),
  1350. );
  1351. if ($sBackupDestination != '')
  1352. {
  1353. $aInstallParams['backup'] = array (
  1354. 'destination' => $sBackupDestination,
  1355. 'configuration_file' => $sConfigurationFile,
  1356. );
  1357. }
  1358. $sJSONData = json_encode($aInstallParams);
  1359. if (isset($aMiscOptions['generate_config']))
  1360. {
  1361. $oDoc = new DOMDocument('1.0', 'UTF-8');
  1362. $oDoc->preserveWhiteSpace = false;
  1363. $oDoc->formatOutput = true;
  1364. $oParams = new PHPParameters();
  1365. $oParams->LoadFromHash($aInstallParams);
  1366. $oParams->ToXML($oDoc, null, 'installation');
  1367. $sXML = $oDoc->saveXML();
  1368. $oPage->add('<div class="closed"><span class="title">XML Config file</span><ul><pre>');
  1369. $oPage->add(htmlentities($sXML, ENT_QUOTES, 'UTF-8'));
  1370. $oPage->add('</pre></ul></div>');
  1371. }
  1372. $oPage->add('</div>'); // params_summary
  1373. $oPage->add('</fieldset>');
  1374. $oPage->add('<fieldset id="installation_progress"><legend>Progress of the installation</legend>');
  1375. $oPage->add('<div id="progress_content">');
  1376. $oPage->add_linked_script('../setup/jquery.progression.js');
  1377. $oPage->add('<p class="center"><span id="setup_msg">Ready to start...</span></p><div style="display:block;margin-left: auto; margin-right:auto;" id="progress">0%</div>');
  1378. $oPage->add('</div>'); // progress_content
  1379. $oPage->add('</fieldset>');
  1380. $oPage->add('<input type="hidden" id="installer_parameters" value="'.htmlentities($sJSONData, ENT_QUOTES, 'UTF-8').'"/>');
  1381. }
  1382. public function AsyncAction(WebPage $oPage, $sCode, $aParameters)
  1383. {
  1384. $oParameters = new PHPParameters();
  1385. $sStep = $aParameters['installer_step'];
  1386. $sJSONParameters = $aParameters['installer_config'];
  1387. $oParameters->LoadFromHash(json_decode($sJSONParameters, true /* bAssoc */));
  1388. $oInstaller = new ApplicationInstaller($oParameters);
  1389. $aRes = $oInstaller->ExecuteStep($sStep);
  1390. if (($aRes['status'] != ApplicationInstaller::ERROR) && ($aRes['next-step'] != ''))
  1391. {
  1392. // Tell the web page to move the progress bar and to launch the next step
  1393. $sMessage = addslashes(htmlentities($aRes['next-step-label'], ENT_QUOTES, 'UTF-8'));
  1394. $oPage->add_ready_script(
  1395. <<<EOF
  1396. $("#wiz_form").data("installation_status", "running");
  1397. WizardUpdateButtons();
  1398. $('#setup_msg').html('$sMessage');
  1399. $('#progress').progression( {Current:{$aRes['percentage-completed']}, Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000'} );
  1400. //$("#percentage").html('{$aRes['percentage-completed']} % completed<br/>{$aRes['next-step-label']}');
  1401. ExecuteStep('{$aRes['next-step']}');
  1402. EOF
  1403. );
  1404. }
  1405. else if ($aRes['status'] != ApplicationInstaller::ERROR)
  1406. {
  1407. // Installation complete, move to the next step of the wizard
  1408. $oPage->add_ready_script(
  1409. <<<EOF
  1410. $("#wiz_form").data("installation_status", "completed");
  1411. $('#progress').progression( {Current:100, Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000'} );
  1412. WizardUpdateButtons();
  1413. $("#btn_next").unbind("click.install");
  1414. $("#btn_next").click();
  1415. EOF
  1416. );
  1417. }
  1418. else
  1419. {
  1420. $sMessage = addslashes(htmlentities($aRes['message'], ENT_QUOTES, 'UTF-8'));
  1421. $oPage->add_ready_script(
  1422. <<<EOF
  1423. $("#wiz_form").data("installation_status", "error");
  1424. WizardUpdateButtons();
  1425. $('#setup_msg').html('$sMessage');
  1426. EOF
  1427. );
  1428. }
  1429. }
  1430. /**
  1431. * Tells whether the "Next" button should be enabled interactively
  1432. * @return string A piece of javascript code returning either true or false
  1433. */
  1434. public function JSCanMoveForward()
  1435. {
  1436. return 'return (($("#wiz_form").data("installation_status") === "not started") || ($("#wiz_form").data("installation_status") === "completed"));';
  1437. }
  1438. /**
  1439. * Tells whether the "Next" button should be enabled interactively
  1440. * @return string A piece of javascript code returning either true or false
  1441. */
  1442. public function JSCanMoveBackward()
  1443. {
  1444. return 'var sStatus = $("#wiz_form").data("installation_status"); return ((sStatus === "not started") || (sStatus === "error"));';
  1445. }
  1446. }
  1447. /**
  1448. * Summary of the installation tasks
  1449. */
  1450. class WizStepDone extends WizardStep
  1451. {
  1452. public function GetTitle()
  1453. {
  1454. return 'Done';
  1455. }
  1456. public function GetPossibleSteps()
  1457. {
  1458. return array();
  1459. }
  1460. public function ProcessParams($bMoveForward = true)
  1461. {
  1462. return array('class' => '', 'state' => '');
  1463. }
  1464. public function Display(WebPage $oPage)
  1465. {
  1466. // Check if there are some manual steps required:
  1467. $aManualSteps = array();
  1468. $aAvailableModules = SetupUtils::AnalyzeInstallation($this->oWizard);
  1469. $sRootUrl = utils::GetAbsoluteUrlAppRoot();
  1470. $aSelectedModules = json_decode($this->oWizard->GetParameter('selected_modules'), true);
  1471. foreach($aSelectedModules as $sModuleId)
  1472. {
  1473. if (!empty($aAvailableModules[$sModuleId]['doc.manual_setup']))
  1474. {
  1475. $aManualSteps[$aAvailableModules[$sModuleId]['label']] = $sRootUrl.$aAvailableModules[$sModuleId]['doc.manual_setup'];
  1476. }
  1477. }
  1478. if (count($aManualSteps) > 0)
  1479. {
  1480. $oPage->add("<h2>Manual operations required</h2>");
  1481. $oPage->p("In order to complete the installation, the following manual operations are required:");
  1482. foreach($aManualSteps as $sModuleLabel => $sUrl)
  1483. {
  1484. $oPage->p("<a href=\"$sUrl\" target=\"_blank\">Manual instructions for $sModuleLabel</a>");
  1485. }
  1486. $oPage->add("<h2>Congratulations for installing iTop</h2>");
  1487. }
  1488. else
  1489. {
  1490. $oPage->add("<h2>Congratulations for installing iTop</h2>");
  1491. $oPage->ok("The installation completed successfully.");
  1492. }
  1493. // Form goes here.. No back button since the job is done !
  1494. $oPage->add('<table style="width:600px;border:0;padding:0;"><tr>');
  1495. $oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Free: Register your iTop version.\" href=\"http://www.combodo.com/register?product=iTop&version=".urlencode(ITOP_VERSION." revision ".ITOP_REVISION)."\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-register.gif\"/></td></a>");
  1496. $oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Get Professional Support from Combodo\" href=\"http://www.combodo.com/itopsupport\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-support.gif\"/></td></a>");
  1497. $oPage->add("<td><a style=\"background:transparent;padding:0;\" title=\"Get Professional Training from Combodo\" href=\"http://www.combodo.com/itoptraining\" target=\"_blank\"><img style=\"border:0\" src=\"../images/setup-training.gif\"/></td></a>");
  1498. $oPage->add('</tr></table>');
  1499. $sForm = '<form method="post" action="'.$this->oWizard->GetParameter('application_url').'/pages/UI.php">';
  1500. $sForm .= '<input type="hidden" name="auth_user" value="'.htmlentities($this->oWizard->GetParameter('admin_user'), ENT_QUOTES, 'UTF-8').'">';
  1501. $sForm .= '<input type="hidden" name="auth_pwd" value="'.htmlentities($this->oWizard->GetParameter('admin_pwd'), ENT_QUOTES, 'UTF-8').'">';
  1502. $sForm .= "<p style=\"text-align:center;width:100%\"><button id=\"enter_itop\" type=\"submit\">Enter iTop</button></p>";
  1503. $sForm .= '</form>';
  1504. $oPage->add('<img style="border:0" src="http://www.combodo.com/stats/?p='.urlencode(ITOP_APPLICATION).'&v='.urlencode(ITOP_VERSION).'"/>');
  1505. $sForm = addslashes($sForm);
  1506. $oPage->add_ready_script("$('#wiz_form').after('$sForm');");
  1507. }
  1508. public function CanMoveForward()
  1509. {
  1510. return false;
  1511. }
  1512. public function CanMoveBackward()
  1513. {
  1514. return false;
  1515. }
  1516. }