NvUpdate::step2 PHP Method

step2() public method

NvUpdate::step2()
public step2 ( mixed $array, mixed $substep )
$array mixed
$substep mixed
    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');
    }

Usage Example

Esempio n. 1
0
            // Khong co chuyen file
            if (empty($nv_update_config['updatelog']['data_list'])) {
                // Khong co chuyen CSDL luon
                $array['BackStepUrl'] = NV_BASE_SITEURL . 'install/update.php?step=2&substep=1';
            } else {
                $array['BackStepUrl'] = NV_BASE_SITEURL . 'install/update.php?step=2&substep=3';
            }
        } else {
            $array['BackStepUrl'] = NV_BASE_SITEURL . 'install/update.php?step=2&substep=4';
        }
        if ($nv_update_config['updatelog']['step'] < 2) {
            $nv_update_config['updatelog']['step'] = 2;
            $NvUpdate->set_data_log($nv_update_config['updatelog']);
        }
    }
    $contents = $NvUpdate->step2($array, $nv_update_config['substep']);
} elseif ($nv_update_config['step'] == 3) {
    // Hoan tat nang cap
    $array = array();
    // Lay thong tin phien ban va module
    if ($nv_Request->isset_request('load', 'get')) {
        $type = $nv_Request->get_title('load', 'get', '');
        if ($type == 'ver') {
            $version = nv_geVersion(0);
            $array['current_version'] = $global_config['version'];
            $array['newVersion'] = (string) $version['version'] . ' - ' . (string) $version['name'];
            $array['checkversion'] = false;
            if (nv_version_compare($global_config['version'], $version['version']) < 0) {
                $array['checkversion'] = true;
            }
            $NvUpdate->version_info($array);