/** * Process a step * * @var string Version * @var int Step * @var int Startat * @var bool Check table status * @var string Response from a prompt * @var bool First run of the script * @var bool Received an HTML form response * @var array Values returned from an HTML form * @var array Options information */ private function process_step($version, $step, $startat, $checktable = true, $response = null, $firstrun = false, $only = false, $htmlsubmit = false, $htmldata = array(), $options = array()) { $script = $this->load_script($version); $startstep = $step ? $step : 1; $endstep = $script->stepcount; $xml = new vB_AJAX_XML_Builder($this->registry, 'text/xml', vB_Template_Runtime::fetchStyleVar('charset')); $xml->print_xml_header(); $xml->add_group('upgrade'); $only = ($this->scriptinfo['only'] or $only); if ($endstep) { $result = $this->execute_step($startstep, $startat, $script, $xml, $checktable, $response, $htmlsubmit, $htmldata, $options); if ($result and $result['returnvalue']['startat']) { $script->log_upgrade_step($startstep, $result['returnvalue']['startat'], $only); $nextstep = $startstep; } else { if ($result and ($result['returnvalue']['prompt'] or $result['returnvalue']['html'])) { $nextstep = $startstep; } else { if ($result) { $script->log_upgrade_step($startstep, 0, $only); if ($startstep == $endstep) { $version = $script->SHORT_VERSION; $nextstep = 0; } else { $nextstep = $startstep + 1; } } else { $nextstep = $startstep; } } } } else { $script->log_upgrade_step(0, 0, $only); $version = $script->SHORT_VERSION; $nextstep = 0; } if ($nextstep == 0) { if ($this->scriptinfo['version'] == 'final' or $only) { $this->scriptinfo['version'] = 'done'; $status = $this->phrase['core']['status_done']; } else { $this->scriptinfo = $this->get_upgrade_start($version); $nextscript = $this->load_script($this->scriptinfo['version']); if ($nextscript->stepcount) { $status = $this->fetch_status($nextscript->LONG_VERSION, 1, $nextscript->stepcount); } else { $status = $this->fetch_status($nextscript->LONG_VERSION); } } $nextstep = 1; $this->process_script_end(); } else { $status = $this->fetch_status($script->LONG_VERSION, $nextstep, $endstep); } if ($result['returnvalue']['startat']) { $xml->add_tag('startat', $result['returnvalue']['startat']); } else { if ($result['returnvalue']['prompt']) { $xml->add_tag('prompt', $result['returnvalue']['prompt']); if ($result['returnvalue']['confirm']) { $xml->add_tag('confirm', $result['returnvalue']['confirm']); } if ($result['returnvalue']['hidecancel']) { $xml->add_tag('hidecancel', true); } if ($result['returnvalue']['cancel']) { $xml->add_tag('cancel', $result['returnvalue']['cancel']); } if ($result['returnvalue']['ok']) { $xml->add_tag('ok', $result['returnvalue']['ok']); } if ($result['returnvalue']['title']) { $xml->add_tag('title', $result['returnvalue']['title']); } if ($result['returnvalue']['reset']) { $xml->add_tag('reset', true); } } else { if ($result['returnvalue']['html']) { $xml->add_tag('html', $result['returnvalue']['html']); if ($result['returnvalue']['width']) { $xml->add_tag('width', $result['returnvalue']['width']); } if ($result['returnvalue']['height']) { $xml->add_tag('height', $result['returnvalue']['height']); } if ($result['returnvalue']['cancel']) { $xml->add_tag('cancel', $result['returnvalue']['cancel']); } if ($result['returnvalue']['ok']) { $xml->add_tag('ok', $result['returnvalue']['ok']); } if ($result['returnvalue']['hidecancel']) { $xml->add_tag('hidecancel', true); } if ($result['returnvalue']['title']) { $xml->add_tag('title', $result['returnvalue']['title']); } if ($result['returnvalue']['reset']) { $xml->add_tag('reset', true); } } } } $xml->add_tag('status', $status); $xml->add_tag('longversion', $script->LONG_VERSION); $xml->add_tag('version', $this->scriptinfo['version']); $xml->add_tag('nextstep', $nextstep); if ($this->scriptinfo['version'] == 'done') { $xml->add_tag('upgradecomplete', $this->phrase['final'][$this->setuptype . '_complete']); $xml->add_tag('oktext', $this->phrase['final']['goto_admincp']); $xml->add_tag('canceltext', $this->phrase['final']['back_to_' . $this->setuptype]); } if ($firstrun or $result['returnvalue']['startat'] == 0 and $startstep == 1) { // Might be able to replace the array_merge with $this->endscripts --- Check if (in_array($this->scriptinfo['version'], array_merge(array('install'), $this->endscripts)) and $script->LONG_VERSION == $this->scriptinfo['version']) { $xml->add_tag('upgradenotice', $this->phrase['core']['processing_' . $this->scriptinfo['version']]); } else { // <!-- "upgradeing" is a purposeful typo --> $xml->add_tag('upgradenotice', sprintf($this->phrase['core']['upgradeing_to_x'], $script->LONG_VERSION)); } } $xml->close_group('upgrade'); $xml->print_xml_end(); }