From 7acdb0d636fb3d7b302cebd71e0b70fceca024d8 Mon Sep 17 00:00:00 2001 From: sminnee Date: Thu, 6 Nov 2008 04:52:45 +0000 Subject: [PATCH] FEATURE: Improved cli execution of installer. BUGFIX: Removed excessively-specific includes that are no longer necessary thanks to r65385. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/trunk@65386 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- install.php | 111 +++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 58 deletions(-) diff --git a/install.php b/install.php index 795c13f..aff3445 100644 --- a/install.php +++ b/install.php @@ -283,11 +283,15 @@ class InstallRequirements { echo "
  • " . htmlentities($warning) . "
  • "; } } else { - ?> -

    I have installed SilverStripe CMS successfully!

    -

    Open the CMS tool
    - Open the site

    - +

    I have installed SilverStripe CMS successfully!

    +

    Open the CMS tool
    + Open the site

    + -

    Installing SilverStripe...

    -

    I am now running through the installation steps (this should take about 30 seconds)

    -

    If you receive a fatal error, refresh this page to continue the installation - +

    Installing SilverStripe...

    +

    I am now running through the installation steps (this should take about 30 seconds)

    +

    If you receive a fatal error, refresh this page to continue the installation + Creating 'mysite/_config.php' for use with _ss_environment.php...\n"; - flush(); + $this->statusMessage("Creating 'mysite/_config.php' for use with _ss_environment.php..."); $this->createFile("mysite/_config.php", <<Creating 'mysite/_config.php'...\n"; - flush(); - - + $this->statusMessage("Creating 'mysite/_config.php'..."); $devServers = $this->var_export_array_nokeys(explode("\n", $_POST['devsites'])); @@ -674,51 +679,26 @@ PHP ); } - echo "

  • Creating '.htaccess' file...
  • "; - flush(); + $this->statusMessage("Creating '.htaccess' file..."); $this->createHtaccess(); // Load the sapphire runtime $_SERVER['SCRIPT_FILENAME'] = dirname(realpath($_SERVER['SCRIPT_FILENAME'])) . '/sapphire/main.php'; chdir('sapphire'); - /** - * @TODO - Remove Dependance on CMS FOLDER. - * This will be refactored into dev/build - */ - require_once('core/Object.php'); - require_once('core/ViewableData.php'); - require_once('core/control/RequestHandler.php'); - require_once('core/control/Controller.php'); - require_once('../cms/code/LeftAndMain.php'); - require_once('../cms/code/CMSMenuItem.php'); - require_once('../cms/code/CMSMenu.php'); - require_once('core/i18n.php'); - require_once('core/i18nEntityProvider.php'); - require_once('core/model/DataObjectInterface.php'); - require_once('core/model/DataObject.php'); - require_once('email/Email.php'); - require_once('security/Security.php'); - require_once('dev/Debug.php'); - require_once('core/SSViewer.php'); + require_once('core/Core.php'); - require_once('core/ManifestBuilder.php'); - require_once('core/ClassInfo.php'); - require_once('core/control/Director.php'); - require_once('core/Session.php'); - require_once('core/control/RequestHandler.php'); - require_once('filesystem/Filesystem.php'); - - echo "
  • Building database schema...
  • "; - flush(); + $this->statusMessage("Building database schema..."); // Build database $_GET['flush'] = true; $con = new Controller(); $con->pushCurrent(); - ManifestBuilder::compileManifest(); - require(MANIFEST_FILE); + + global $databaseConfig; + DB::connect($databaseConfig); + $dbAdmin = new DatabaseAdmin(); $dbAdmin->init(); @@ -735,20 +715,25 @@ PHP // Syncing filesystem (so /assets/Uploads is available instantly, see ticket #2266) FileSystem::sync(); - - echo "
  • Checking mod_rewrite works
  • "; + + if(isset($_SERVER['HTTP_HOST'])) { + $this->statusMessage("Checking mod_rewrite works..."); + $modRewriteWorks = $this->checkModRewrite(); + } else { + $modRewriteWorks = true; + } $_SESSION['username'] = $config['admin']['username']; $_SESSION['password'] = $config['admin']['password']; - if($this->checkModRewrite()) { - if($this->errors) { - - } else { + if($modRewriteWorks && !$this->errors) { + if(isset($_SERVER['HTTP_HOST'])) { echo "

    Installed SilverStripe successfully. I will now try and direct you to home/successfullyinstalled to confirm that the installation was successful.

    "; + } else { + echo "\nSilverStripe successfully installed\n"; } } @@ -793,7 +778,7 @@ PHP function createFile($filename, $content) { $base = $this->getBaseDir(); - echo "
  • Creating $base$filename\n"; + $this->statusMessage("Creating $base$filename"); if((@$fh = fopen($base . $filename, 'w')) && fwrite($fh, $content) && fclose($fh)) { return true; @@ -924,8 +909,8 @@ TEXT; } function performModRewriteTest() { - if(!$_SERVER['HTTP_HOST']) { - echo "
  • Installer seems to be called from command-line, we're going to assume that rewriting is working.\n"; + if(!isset($_SERVER['HTTP_HOST']) || !$_SERVER['HTTP_HOST']) { + $this->statusMessage("Installer seems to be called from command-line, we're going to assume that rewriting is working."); return true; } @@ -975,6 +960,16 @@ TEXT; $retval .= ")"; return $retval; } + + /** + * Show an installation status message. + * The output differs depending on whether this is CLI or web based + */ + function statusMessage($msg) { + if(isset($_SERVER['HTTP_HOST'])) echo "
  • $msg
  • \n"; + else echo "$msg\n"; + flush(); + } } /**