示例#1
0
 /**
  * Returns an array with domain keys and domain class names for the current
  * analysis. The idea is that shifting this array walks through the analysis
  * process. When the array is empty, the analysis is done.
  *
  * @return array
  */
 public static function getDomainChain()
 {
     JLoader::import('joomla.filesystem.folder');
     $basepath = JPATH_ADMINISTRATOR . '/components/com_akeeba/alice/core/domain';
     $files = JFolder::files($basepath, '.php');
     $result = array();
     foreach ($files as $file) {
         if ($file == 'abstract.php') {
             continue;
         }
         $file = str_replace('.php', '', $file);
         $temp = AliceFactory::getDomainObject($file);
         $result[$temp->priority] = array('domain' => $file, 'class' => ucfirst($file), 'name' => $temp->getStepName());
         unset($temp);
     }
     // Sort domains by priority
     ksort($result);
     return $result;
 }
示例#2
0
 /**
  * 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 = AliceFactory::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;
     }
     if ($percentage > 100) {
         $percentage = 100;
     }
     return $percentage;
 }