/** * The standard form definition... obviously not much here */ function definition() { $ui = $this->uistage->get_ui(); $mform = $this->_form; $stage = $mform->addElement('hidden', 'stage', $this->uistage->get_stage()); $stage = $mform->addElement('hidden', $ui->get_name(), $ui->get_uniqueid()); $params = $this->uistage->get_params(); if (is_array($params) && count($params) > 0) { foreach ($params as $name => $value) { $stage = $mform->addElement('hidden', $name, $value); } } }
/** * The standard form definition... obviously not much here */ public function definition() { $ui = $this->uistage->get_ui(); $mform = $this->_form; $mform->setDisableShortforms(); $stage = $mform->addElement('hidden', 'stage', $this->uistage->get_stage()); $mform->setType('stage', PARAM_INT); $stage = $mform->addElement('hidden', $ui->get_name(), $ui->get_uniqueid()); $mform->setType($ui->get_name(), PARAM_ALPHANUM); $params = $this->uistage->get_params(); if (is_array($params) && count($params) > 0) { foreach ($params as $name => $value) { // TODO: Horrible hack, but current backup ui structure does not allow // to make this easy (only changing params to objects that would be // possible. MDL-38735. $intparams = array('contextid', 'importid', 'target'); $stage = $mform->addElement('hidden', $name, $value); if (in_array($name, $intparams)) { $mform->setType($name, PARAM_INT); } else { // Adding setType() to avoid missing setType() warnings. // MDL-39126: support $mform->setType() for additional backup parameters. $mform->setType($name, PARAM_RAW); } } } }
/** * This processes the current stage of the backup * @return bool */ public function process() { if ($this->progress >= self::PROGRESS_PROCESSED) { throw new backup_ui_exception('backupuialreadyprocessed'); } $this->progress = self::PROGRESS_PROCESSED; if (optional_param('previous', false, PARAM_BOOL) && $this->stage->get_stage() > $this->get_first_stage_id()) { $this->stage = $this->initialise_stage($this->stage->get_prev_stage(), $this->stage->get_params()); return false; } // Process the stage $processoutcome = $this->stage->process(); if ($processoutcome !== false) { $this->stage = $this->initialise_stage($this->stage->get_next_stage(), $this->stage->get_params()); } // Process UI event after to check changes are valid $this->controller->process_ui_event(); return $processoutcome; }