/** * Gets the percentage of the backup process done so far. * * @return string */ public function getProgress() { // Get the overall percentage (based on domains complete so far) $remaining_steps = count($this->domain_chain); $remaining_steps++; $overall = 1 - $remaining_steps / $this->total_steps; // How much is this step worth? $this_max = 1 / $this->total_steps; // Get the percentage done of the current object if (!empty($this->class)) { $object = Factory::getDomainObject($this->class); } else { $object = null; } if (!is_object($object)) { $local = 0; } else { $local = $object->getProgress(); } $percentage = (int) (100 * ($overall + $local * $this_max)); if ($percentage < 0) { $percentage = 0; } elseif ($percentage > 100) { $percentage = 100; } return $percentage; }