protected function _prepare() { // Intialize the timer class $timer = AliceFactory::getTimer(); // Do we have a tag? if (!empty($this->_parametersArray['tag'])) { $this->tag = $this->_parametersArray['tag']; } // Save the log to analyze $registry = AliceFactory::getConfiguration(); $registry->set('volatile.alice.logToAnalyze', $this->_parametersArray['logToAnalyze']); // Make sure a tag exists (or create a new one) $this->tag = $this->getTag(); // Reset the log AliceUtilLogger::openLog($this->tag); AliceUtilLogger::ResetLog($this->tag); set_error_handler('aliceBackupErrorHandler'); // Reset the storage AliceUtilTempvars::reset($this->tag); // Get the domain chain $this->domain_chain = AliceUtilScripting::getDomainChain(); $this->total_steps = count($this->domain_chain) - 1; // Init shouldn't count in the progress bar // Mark this engine for Nesting Logging $this->nest_logging = true; // Preparation is over $this->array_cache = null; $this->setState('prepared'); //restore_error_handler(); }
public function domains() { $return = array(); $domains = AliceUtilScripting::getDomainChain(); foreach ($domains as $domain) { $return[] = array($domain['domain'], $domain['name']); } @ob_end_clean(); header('Content-type: text/plain'); echo '###' . json_encode($return) . '###'; flush(); JFactory::getApplication()->close(); }
protected function _run() { // Run in a loop until we run out of time, or breakflag is set $registry = AliceFactory::getConfiguration(); $timer = AliceFactory::getTimer(); // Let's check if I already have a stack coming from previous call $this->log = $registry->get('volatile.alice.logToAnalyze'); $this->checks = $registry->get('volatile.alice.' . $this->checksName . '.checks', array()); $this->totalChecks = $registry->get('volatile.alice.' . $this->checksName . '.totalChecks', 0); // No incoming stack, let's build it now if (!$this->checks) { $this->checks = AliceUtilScripting::getChecksStack($this->checksName); $this->totalChecks = count($this->checks); } while ($timer->getTimeLeft() > 0 && !$registry->get('volatile.breakflag', false) && count($this->checks)) { if ($this->getState() == 'postrun') { AliceUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Already finished"); $this->setStep("-"); $this->setSubstep(""); break; } else { // Did I finished every check? if (!$this->checks) { return; } $error = ''; $solution = ''; $className = array_shift($this->checks); $check = new $className($this->log); $this->setSubstep($check->getName()); $this->progress = ($this->totalChecks - count($this->checks)) / $this->totalChecks; // Well, check, do your job! try { $check->check(); } catch (Exception $e) { // Mhm... log didn't passed the check. Let's save the error and the suggested solution $error = $e->getMessage(); $solution = $check->getSolution(); } $result = $check->getResult(); $feedback = $registry->get('volatile.alice.feedback', array()); $feedback[] = array('check' => $check->getName(), 'result' => $result, 'error' => $error, 'solution' => $solution); $registry->set('volatile.alice.feedback', $feedback); unset($check); } } // Let's save everything $registry->set('volatile.alice.requirements.checks', $this->checks); $registry->set('volatile.alice.requirements.totalChecks', $this->totalChecks); $this->setState('postrun'); }