diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php
index c59a5e63e..a6bb1fd7a 100644
--- a/system/src/Grav/Console/Gpm/InstallCommand.php
+++ b/system/src/Grav/Console/Gpm/InstallCommand.php
@@ -215,12 +215,14 @@ class InstallCommand extends Command
private function installDemoContent($package)
{
$demo_dir = $this->destination . DS . $package->install_path . DS . '_demo';
+ $dest_dir = $this->destination . DS . 'user';
+ $pages_dir = $dest_dir . DS . 'pages';
if (file_exists($demo_dir)) {
// Demo content exists, prompt to install it.
$this->output->writeln("Attention: ".$package->name . " contains demo content");
$helper = $this->getHelper('question');
- $question = new ConfirmationQuestion('Do you wish to install this demo content? (DANGER: May merge or overwrite existing user data) [y|N] ', false);
+ $question = new ConfirmationQuestion('Do you wish to install this demo content? [y|N] ', false);
if (!$helper->ask($this->input, $this->output, $question)) {
$this->output->writeln(" '- Skipped! ");
@@ -228,9 +230,30 @@ class InstallCommand extends Command
return;
}
+ // if pages folder exists in demo
+ if (file_exists($demo_dir . DS . 'pages')) {
+ $pages_backup = 'pages.' . date('m-d-Y-H-i-s');
+ $question = new ConfirmationQuestion('This will backup your current `user/pages` folder to `user/'. $pages_backup. '`, continue? [y|N]', false);
+
+ if (!$helper->ask($this->input, $this->output, $question)) {
+ $this->output->writeln(" '- Skipped! ");
+ $this->output->writeln('');
+ return;
+ }
+
+ // backup current pages folder
+ if (file_exists($dest_dir)) {
+ if (rename($pages_dir, $dest_dir . DS . $pages_backup)) {
+ $this->output->writeln(" |- Backing up pages... ok");
+ } else {
+ $this->output->writeln(" |- Backing up pages... failed");
+ }
+ }
+ }
+
// Confirmation received, copy over the data
$this->output->writeln(" |- Installing demo content... ok ");
- Utils::rcopy($demo_dir, $this->destination . DS . 'user');
+ Utils::rcopy($demo_dir, $dest_dir);
$this->output->writeln(" '- Success! ");
$this->output->writeln('');
}