public function step2($array, $substep)
{
global $global_config;
$xtpl = new XTemplate('updatestep2.tpl', NV_ROOTDIR . '/install/tpl');
$xtpl->assign('LANG', $this->lang);
$xtpl->assign('CONFIG', $this->config);
$xtpl->assign('DATA', $array);
$xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
if ($substep == 1) {
// Back up cac file de phong bat trac
if ($array['data_backuped']) {
// Thong bao da backup CSDL vao luc
$xtpl->assign('DATA_MESSAGE', sprintf($this->lang['update_data_backuped'], nv_date('H:i d/m/Y', $array['data_backuped'])));
$xtpl->parse('main.step1.data_backuped');
}
if ($array['is_data_backup']) {
// Cho phep backup CSDL
$xtpl->assign('URL_DUMP_DB_BACKUP', NV_BASE_SITEURL . 'install/update.php?step=' . $this->config['step'] . '&substep=' . $substep . '&dump&checksess=' . NV_CHECK_SESSION);
$xtpl->parse('main.step1.is_data_backup');
} else {
// Thong bao khong cho backup CSDL nua
$xtpl->parse('main.step1.no_data_backup');
}
if ($array['file_backuped']) {
// Thong bao da backup CODE vao luc
$xtpl->assign('FILE_MESSAGE', sprintf($this->lang['update_file_backuped'], nv_date('H:i d/m/Y', $array['file_backuped'])));
$xtpl->parse('main.step1.file_backuped');
}
if ($array['is_file_backup']) {
// Cho phep backup CODE
$xtpl->assign('URL_DUMP_FILE_BACKUP', NV_BASE_SITEURL . 'install/update.php?step=' . $this->config['step'] . '&substep=' . $substep . '&dumpfile&checksess=' . NV_CHECK_SESSION);
$xtpl->parse('main.step1.is_file_backup');
}
$xtpl->parse('main.step1');
} elseif ($substep == 2) {
if ($this->config['update_auto_type'] == 0) {
$xtpl->parse('main.step2.manual');
} else {
if ($array['is_move_file']) {
$xtpl->parse('main.step2.automatic.semiautomatic');
} elseif ($this->config['update_auto_type'] == 1) {
$xtpl->parse('main.step2.automatic.fullautomatic');
} else {
$xtpl->parse('main.step2.automatic.info');
}
// Cong viec lien quan CSDL
if (!empty($array['data_list'])) {
foreach ($array['data_list'] as $w) {
$w['title'] = isset($this->lang[$w['langkey']]) ? $this->lang[$w['langkey']] : 'N/A';
$xtpl->assign('ROW', $w);
$xtpl->parse('main.step2.automatic.data.loop');
}
$xtpl->parse('main.step2.automatic.data');
} else {
$xtpl->parse('main.step2.automatic.nodata');
}
// Cong viec lien quan cac file
if (!empty($array['file_list'])) {
foreach ($array['file_list'] as $w) {
$xtpl->assign('ROW', $w);
$xtpl->parse('main.step2.automatic.file.loop');
}
$xtpl->parse('main.step2.automatic.file');
} else {
$xtpl->parse('main.step2.automatic.nofile');
}
$xtpl->parse('main.step2.automatic');
}
$xtpl->parse('main.step2');
} elseif ($substep == 3) {
if (!empty($array['errorStepMoveFile'])) {
$xtpl->parse('main.step3.error');
} else {
// Viet cac tien trinh
foreach ($array['task'] as $task) {
$xtpl->assign('ROW', $task);
$xtpl->parse('main.step3.data.loop');
}
if (!empty($array['stopprocess'])) {
// Dung cong viec do loi
global $nv_update_config;
$xtpl->assign('ERROR_MESSAGE', sprintf($this->lang['update_task_error_message'], $array['stopprocess']['title'], $nv_update_config['support_website']));
$xtpl->parse('main.step3.data.errorProcess');
} elseif ($array['AllPassed'] == true) {
// Hoan tat cong viec va chuyen sang buoc tiep theo
$xtpl->parse('main.step3.data.AllPassed');
} else {
// Tiep tuc khoi chay tien trinh
$xtpl->parse('main.step3.data.ConStart');
}
if ($array['AllPassed'] == true and empty($array['stopprocess'])) {
$xtpl->parse('main.step3.data.next_step');
}
$xtpl->parse('main.step3.data');
}
$xtpl->parse('main.step3');
} elseif ($substep == 4) {
global $sys_info, $nv_update_config;
if (!$array['getcomplete'] and !empty($array['file_list'])) {
if (substr($sys_info['os'], 0, 3) == 'WIN') {
$xtpl->parse('main.step4.win');
}
if ($array['FTP_nosupport']) {
$xtpl->parse('main.step4.FTP_nosupport');
} elseif ($array['check_FTP']) {
$xtpl->assign('ACTIONFORM', NV_BASE_SITEURL . 'install/update.php?step=' . $this->config['step'] . '&substep=' . $substep);
if (!empty($array['ftpdata']['error']) and $array['ftpdata']['show_ftp_error']) {
$xtpl->parse('main.step4.check_FTP.errorftp');
}
$xtpl->parse('main.step4.check_FTP');
}
}
$xtpl->assign('OK_MESSAGE', sprintf($this->lang['update_move_complete'], sizeof($nv_update_config['updatelog']['file_list'])));
if (empty($array['file_list'])) {
$xtpl->parse('main.step4.complete');
$xtpl->parse('main.step4.next_step');
} else {
$xtpl->assign('PROCESS_MESSAGE', sprintf($this->lang['update_move_num'], sizeof($array['file_list']), sizeof($nv_update_config['updatelog']['file_list'])));
$xtpl->parse('main.step4.process');
}
// Danh sach cac file se bi tac dong
foreach ($nv_update_config['updatelog']['file_list'] as $fileID => $fileName) {
$xtpl->assign('ROW', array('id' => $fileID, 'name' => $fileName, 'status' => in_array($fileName, $array['file_list']) ? '' : ' iok'));
$xtpl->parse('main.step4.loop');
}
$xtpl->parse('main.step4');
} elseif ($substep == 5) {
if ($array['error']) {
$xtpl->parse('main.step5.error');
} else {
$xtpl->parse('main.step5.guide');
}
$xtpl->parse('main.step5');
}
$xtpl->parse('main');
return $xtpl->text('main');
}