Esempio n. 1
0
 function run()
 {
     loadApp($this->getMyComponentPathDefault() . 'class_stepinstall.php');
     //make sure it's not already installed
     if (file_exists(ANWIKI_INSTALL_LOCK)) {
         $sLinkHome = AnwUtils::link(AnwComponent::globalCfgHomePage());
         $sLinkForce = AnwStepInstall::linkStep(AnwStepInstall::getStepDefault());
         $this->out .= $this->tpl()->alreadyInstalled($sLinkHome, $sLinkForce, ANWIKI_INSTALL_LOCK, ANWIKI_INSTALL_STATUS);
         return;
     }
     //make sure writable dir is writable
     if (!file_exists(ANWIKI_INSTALL_STATUS)) {
         @touch(ANWIKI_INSTALL_STATUS);
     }
     if (!is_writable(ANWPATH_WRITABLE) || !is_writable(ANWIKI_INSTALL_STATUS)) {
         $this->out .= $this->tpl()->error($this->t_("err_notwritable_directory_explain", array('directory' => '<br/>' . ANWPATH_WRITABLE)), $this->t_("err_notwritable_t"));
         return;
     }
     //security
     define('ANWIKI_IN_INSTALL', true);
     //read next step
     $nCurrentStepStatus = self::getCurrentStepStatus();
     self::debug("current step status: " . $nCurrentStepStatus);
     //find step to execute
     $nStepOrder = (int) AnwEnv::_GET("step", AnwEnv::_POST("step", $nCurrentStepStatus));
     //do not go to next steps if previous steps were not completed
     if ($nStepOrder > $nCurrentStepStatus) {
         $nStepOrder = $nCurrentStepStatus;
     }
     //make sure step exists
     try {
         $sStepName = AnwStepInstall::getStepForOrder($nStepOrder);
     } catch (AnwException $e) {
         $nStepOrder = $nCurrentStepStatus;
         $sStepName = AnwStepInstall::getStepForOrder($nStepOrder);
     }
     //load the step
     $this->oStepInstall = AnwStepInstall::loadComponent($sStepName);
     AnwStepInstall::setActionInstall($this);
     $nCountSteps = count(AnwStepInstall::getAllSteps());
     $sLinkPrevious = $this->oStepInstall->linkStepPrevious();
     $sLinkNext = $this->oStepInstall->linkStepNext();
     $sTitleStep = $this->oStepInstall->getStepTitle();
     $this->out .= $this->tpl()->headerInstall($sTitleStep, $nStepOrder, $nCountSteps, $sLinkPrevious, $sLinkNext);
     //run the step
     $this->out .= $this->oStepInstall->runStepInstall();
     $this->out .= $this->tpl()->footerInstall($sTitleStep, $nStepOrder, $nCountSteps, $sLinkPrevious, $sLinkNext);
 }