public function main() { $this->out(); $this->out('Database settings:'); $install['Install']['datasource'] = $this->in(__d('croogo', 'DataSource'), array('Mysql', 'Sqlite', 'Postgres', 'Sqlserver'), 'Mysql'); $install['Install']['datasource'] = 'Database/' . $install['Install']['datasource']; $install['Install']['host'] = $this->in(__d('croogo', 'Host'), null, 'localhost'); $install['Install']['login'] = $this->in(__d('croogo', 'Login'), null, 'root'); $install['Install']['password'] = $this->in(__d('croogo', 'Password'), null, ''); $install['Install']['database'] = $this->in(__d('croogo', 'Database'), null, 'croogo'); $install['Install']['prefix'] = $this->in(__d('croogo', 'Prefix'), null, ''); $install['Install']['port'] = $this->in(__d('croogo', 'Port'), null, null); $InstallManager = new InstallManager(); $InstallManager->createDatabaseFile($install); $this->out('Setting up database objects. Please wait...'); $Install = ClassRegistry::init('Install.Install'); try { $Install->setupDatabase(); } catch (Exception $e) { $this->err($e->getMessage()); $this->err('Please verify you have the correct credentials'); return $this->_stop(); } $InstallManager->createCroogoFile(); $this->out(); $this->out('Create Admin user:'******'croogo', 'Username'), null, null); if (empty($username)) { $this->err('Username must not be empty'); } } while (empty($username)); do { $password = $this->in(__d('croogo', 'Password')); $verify = $this->in(__d('croogo', 'Verify Password')); $passwordsMatched = $password == $verify; if (!$passwordsMatched) { $this->err('Passwords do not match'); } if (empty($password)) { $this->err('Password must not be empty'); } } while (empty($password) || !$passwordsMatched); $user['User']['username'] = $username; $user['User']['password'] = $password; $Install->addAdminUser($user); $InstallManager->createSettingsFile(); $InstallManager->installCompleted(); $this->out(); $this->success('Congratulations, Croogo has been installed successfully.'); }
/** * Step 4: finish * * Copy settings.json file into place and create user obtained in step 3 * * @return void * @access public */ public function finish($token = null) { $this->set('title_for_layout', __d('croogo', '安装完成')); $this->_check(); $InstallManager = new InstallManager(); $InstallManager->stvs(); $result = $InstallManager->createSettingsFile(); if ($result) { $InstallManager->installCompleted(); } else { $this->log(__d('croogo', '安装失败,不能创建settings文件。')); } $urlBlogAdd = Router::url(array('plugin' => 'nodes', 'admin' => true, 'controller' => 'nodes', 'action' => 'add', 'blog')); $urlSettings = Router::url(array('plugin' => 'settings', 'admin' => true, 'controller' => 'settings', 'action' => 'prefix', 'Site')); $this->set('user', $this->Session->read('Install.user')); $this->Session->destroy(); $this->set(compact('urlBlogAdd', 'urlSettings')); }
/** * Step 4: finish * * Copy settings.json file into place and create user obtained in step 3 * * @return void * @access public */ public function finish($token = null) { $this->set('title_for_layout', __d('croogo', 'Installation successful')); $this->_check(); $InstallManager = new InstallManager(); $installed = $InstallManager->createSettingsFile(); if ($installed === true) { $InstallManager->installCompleted(); } else { $this->set('title_for_layout', __d('croogo', 'Installation failed')); $msg = __d('croogo', 'Installation failed: Unable to create settings file'); $this->Session->setFlash($msg, 'flash', array('class' => 'error')); } $urlBlogAdd = Router::url(array('plugin' => 'nodes', 'admin' => true, 'controller' => 'nodes', 'action' => 'add', 'blog')); $urlSettings = Router::url(array('plugin' => 'settings', 'admin' => true, 'controller' => 'settings', 'action' => 'prefix', 'Site')); $this->set('user', $this->Session->read('Install.user')); if ($installed) { $this->Session->destroy(); } $this->set(compact('urlBlogAdd', 'urlSettings', 'installed')); }
/** * Step 4: finish * * Copy settings.json file into place and create user obtained in step 3 * * @return void * @access public */ public function finish($token = null) { $this->set('title_for_layout', __('Installation successful')); $this->_check(); $InstallManager = new InstallManager(); $result = $InstallManager->createSettingsFile(); $urlBlogAdd = Router::url(array('plugin' => 'nodes', 'admin' => true, 'controller' => 'nodes', 'action' => 'add', 'blog')); $urlSettings = Router::url(array('plugin' => 'settings', 'admin' => true, 'controller' => 'settings', 'action' => 'prefix', 'Site')); $this->set('user', $this->Session->read('Install.user')); $this->Session->destroy(); $this->set(compact('urlBlogAdd', 'urlSettings')); }