From 436e0f04757f70979037302298544708f367d345 Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Sat, 29 Oct 2011 17:23:09 +1300 Subject: [PATCH] ENHANCEMENT: Make the installer work when CMS module isnt present --- dev/install/install.php5 | 49 ++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/dev/install/install.php5 b/dev/install/install.php5 index 149ce867b..bfc21a0c5 100644 --- a/dev/install/install.php5 +++ b/dev/install/install.php5 @@ -330,7 +330,6 @@ class InstallRequirements { $this->requireModule('mysite', array("File permissions", "mysite/ directory exists?")); $this->requireModule('sapphire', array("File permissions", "sapphire/ directory exists?")); - $this->requireModule('cms', array("File permissions", "cms/ directory exists?")); if($isApache) { $this->requireWriteable('.htaccess', array("File permissions", "Is the .htaccess file writeable?", null)); @@ -339,6 +338,9 @@ class InstallRequirements { } $this->requireWriteable('mysite/_config.php', array("File permissions", "Is the mysite/_config.php file writeable?", null)); + if (!$this->checkModuleExists('cms')) { + $this->requireWriteable('mysite/code/RootURLController.php', array("File permissions", "Is the mysite/code/RootURLController.php file writeable?", null)); + } $this->requireWriteable('assets', array("File permissions", "Is the assets/ directory writeable?", null)); $tempFolder = $this->getTempFolder(); @@ -578,6 +580,14 @@ class InstallRequirements { return true; } + /** + * Check that a module exists + */ + function checkModuleExists($dirname) { + $path = $this->getBaseDir() . $dirname; + return file_exists($path) && ($dirname == 'mysite' || file_exists($path . '/_config.php')); + } + /** * The same as {@link requireFile()} but does additional checks * to ensure the module directory is intact. @@ -936,7 +946,7 @@ class Installer extends InstallRequirements {
@@ -1035,7 +1045,7 @@ SSViewer::set_theme('$theme'); i18n::set_locale('$locale'); // enable nested URLs for this site (e.g. page/sub-page/) -SiteTree::enable_nested_urls(); +if (class_exists('SiteTree')) SiteTree::enable_nested_urls(); PHP ); @@ -1068,7 +1078,22 @@ SSViewer::set_theme('$theme'); i18n::set_locale('$locale'); // enable nested URLs for this site (e.g. page/sub-page/) -SiteTree::enable_nested_urls(); +if (class_exists('SiteTree')) SiteTree::enable_nested_urls(); +PHP + ); + } + + if (!$this->checkModuleExists('cms')) { + $this->writeToFile("mysite/code/RootURLController.php", <<Your site is now set up. Start adding controllers to mysite to get started."; + } + +} PHP ); } @@ -1133,15 +1158,18 @@ PHP $this->statusMessage("Checking that friendly URLs work..."); $this->checkRewrite(); } else { + $destinationURL = 'index.php/' . + ($this->checkModuleExists('cms') ? 'home/successfullyinstalled?flush=1' : '?flush=1'); + echo <<SilverStripe successfully installed; I am now redirecting you to your SilverStripe site... HTML; } @@ -1257,13 +1285,16 @@ TEXT; return true; } + $destinationURL = str_replace('install.php', '', $_SERVER['SCRIPT_NAME']) . + ($this->checkModuleExists('cms') ? 'home/successfullyinstalled?flush=1' : '?flush=1'); + echo <<Testing... HTML; }