function run()
 {
     $sDirToDelete = $this->getActionInstall()->getMyComponentPathDefault();
     $sLinkHome = AnwUtils::link(AnwComponent::globalCfgHomePage());
     $sLinkEditConfig = AnwUtils::alink('editconfig');
     $sWebsite = '<a href="' . ANWIKI_WEBSITE . '" target="_blank">' . ANWIKI_WEBSITE . '</a>';
     $this->out .= $this->tpl()->showFinished($sDirToDelete, $sLinkHome, $sLinkEditConfig, $sWebsite);
     //lock install
     $asInstallInfo = array('install_timehuman' => date("Y-m-d H:i:s"), 'install_time' => time(), 'install_version_id' => ANWIKI_VERSION_ID, 'install_version_name' => ANWIKI_VERSION_NAME);
     AnwUtils::putFileSerializedObject(ANWIKI_INSTALL_LOCK, $asInstallInfo);
 }
 protected function initializeAdditional()
 {
     $sInitLog = "";
     //-----------------------------
     // create default home page
     //-----------------------------
     $oContentClass = AnwContentClasses::getContentClass('page');
     $sPageName = AnwComponent::globalCfgHomePage();
     $sPageLang = AnwComponent::globalCfgLangDefault();
     $sChangeComment = "Installation assistant";
     $oContent = new AnwContentPage($oContentClass);
     $sHomeTitle = $this->t_("local_homepage_title", array(), $sPageLang);
     $sHomeHead = $this->tpl()->homePageHead($sPageLang);
     $sHomeBody = $this->tpl()->homePageBody($sPageLang, ANWIKI_WEBSITE);
     $oContent->setContentFieldValues(AnwIContentClassPageDefault_page::FIELD_TITLE, array($sHomeTitle));
     $oContent->setContentFieldValues(AnwIContentClassPageDefault_page::FIELD_HEAD, array($sHomeHead));
     $oContent->setContentFieldValues(AnwIContentClassPageDefault_page::FIELD_BODY, array($sHomeBody));
     $oPage = AnwPage::createNewPage($oContentClass, $sPageName, $sPageLang, $sChangeComment, $oContent);
     $sInitLog .= $this->t_("initlog_pagecreated", array('pagename' => $sPageName)) . '<br/>';
     //-----------------------------
     // create default menu
     //-----------------------------
     $oContentClass = AnwContentClasses::getContentClass('menu');
     $sPageName = 'en/_include/menu';
     //TODO
     $sPageLang = Anwi18n::langExists('en') ? 'en' : AnwComponent::globalCfgLangDefault();
     //TODO
     $sChangeComment = "Installation assistant";
     $oContent = new AnwContentPage($oContentClass);
     //menu title
     $sMenuTitle = $this->t_("local_menu_title", array(), $sPageLang);
     $oContent->setContentFieldValues(AnwIContentClassPageDefault_menu::FIELD_TITLE, array($sMenuTitle));
     //items
     $oContentFieldItems = $oContentClass->getContentField(AnwIContentClassPageDefault_menu::FIELD_ITEMS);
     $oSubContentItem = new AnwContentPage($oContentFieldItems);
     //main link
     $oContentFieldMainLink = $oContentFieldItems->getContentField(AnwIContentFieldPage_menu_menuItem::FIELD_MAINLINK);
     $oSubContentMainLink = new AnwContentPage($oContentFieldMainLink);
     $sMainLinkTitle = $this->t_("local_menu_mainlink_title", array(), $sPageLang);
     $oSubContentMainLink->setContentFieldValues(AnwIPage_link::FIELD_TITLE, array($sMainLinkTitle));
     $oSubContentMainLink->setContentFieldValues(AnwIPage_link::FIELD_URL, array(AnwComponent::globalCfgHomePage()));
     $oSubContentMainLink->setContentFieldValues(AnwIPage_link::FIELD_TARGET, array(AnwIPage_link::TARGET_SELF));
     $oSubContentItem->setSubContents(AnwIContentFieldPage_menu_menuItem::FIELD_MAINLINK, array($oSubContentMainLink));
     $oContent->setSubContents(AnwIContentClassPageDefault_menu::FIELD_ITEMS, array($oSubContentItem));
     $oPage = AnwPage::createNewPage($oContentClass, $sPageName, $sPageLang, $sChangeComment, $oContent);
     $sInitLog .= $this->t_("initlog_pagecreated", array('pagename' => $sPageName)) . '<br/>';
     return $sInitLog;
 }
Example #3
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);
 }
Example #4
0
 static function redirect($destination = false, $bPermanent = false)
 {
     if (!$destination || !self::isSafeUrl($destination)) {
         $destination = self::link(AnwComponent::globalCfgHomePage());
     }
     // redirection fails if we don't remove html entity &amp;
     $destination = str_replace('&amp;', '&', $destination);
     if (self::isViewDebugAuthorized()) {
         print 'Redirection ';
         if ($bPermanent) {
             print 'PERMANENT ';
         }
         print ': <a href="' . self::xQuote($destination) . '">' . self::xText($destination) . '</a><br/>';
         print '<br/><br/><hr/>' . AnwDebug::getLog();
         exit;
     } else {
         if ($bPermanent) {
             header("HTTP/1.1 301 Moved Permanently");
         }
         header("Location: {$destination}");
         exit;
         //TODO properly close DB connexion?
     }
 }