示例#1
0
 /**
  * @return array
  */
 protected function getPWStatus($showPass)
 {
     $config = \ProcessWire\wire('config');
     $on = Tools::tint('On', Tools::kTintError);
     $off = Tools::tint('Off', Tools::kTintInfo);
     $none = Tools::tint('None', Tools::kTintInfo);
     $version = $config->version;
     $latestVersion = parent::getVersion();
     if ($version !== $latestVersion) {
         $version .= Tools::tint(" (upgrade available: {$latestVersion})", Tools::kTintComment);
     }
     $adminUrl = $this->getAdminUrl();
     $advancedMode = $config->advanced ? $on : $off;
     $debugMode = $config->debug ? $on : $off;
     $timezone = $config->timezone;
     $hosts = implode(", ", $config->httpHosts);
     $adminTheme = $config->defaultAdminTheme;
     $dbHost = $config->dbHost;
     $dbName = $config->dbName;
     $dbUser = $config->dbUser;
     $dbPass = $showPass ? $config->dbPass : '******';
     $dbPort = $config->dbPort;
     $prepended = trim($config->prependTemplateFile);
     $appended = trim($config->appendTemplateFile);
     $prependedTemplateFile = $prepended != '' ? $prepended : $none;
     $appendedTemplateFile = $appended != '' ? $appended : $none;
     $installPath = getcwd();
     $status = [['Version', $version], ['Admin URL', $adminUrl], ['Advanced mode', $advancedMode], ['Debug mode', $debugMode], ['Timezone', $timezone], ['HTTP hosts', $hosts], ['Admin theme', $adminTheme], ['Prepended template file', $prependedTemplateFile], ['Appended template file', $appendedTemplateFile], ['Database host', $dbHost], ['Database name', $dbName], ['Database user', $dbUser], ['Database password', $dbPass], ['Database port', $dbPort], ['Installation path', $installPath]];
     return $status;
 }
示例#2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->fs = new Filesystem();
     $this->projectDir = $this->getDirectory($input);
     $this->projectName = basename($this->projectDir);
     $this->src = $input->getOption('src') ? $this->getAbsolutePath($input->getOption('src')) : null;
     $srcStatus = $this->checkExtractedSrc();
     $v = $input->getOption('v') ? true : false;
     $this->output = $output;
     $profile = $input->getOption('profile');
     $branch = $this->getZipURL($input);
     $logger = new Logger('name');
     $logger->pushHandler(new StreamHandler("php://output"));
     $this->installer = new Installer($logger, $this->projectDir, $v);
     $this->version = PwConnector::getVersion();
     try {
         if (!$this->checkAlreadyDownloaded() && $srcStatus !== 'extracted') {
             if (!$srcStatus) {
                 $this->checkProjectName()->download($branch);
             }
             $this->extract();
         }
         $this->cleanUp();
     } catch (Exception $e) {
     }
     try {
         $install = $input->getOption('no-install') ? false : true;
         if ($install) {
             $profile = $this->extractProfile($profile);
             $this->installer->getSiteFolder($profile);
             $this->checkProcessWireRequirements();
             $helper = $this->getHelper('question');
             $post = array('dbName' => '', 'dbUser' => '', 'dbPass' => '', 'dbHost' => 'localhost', 'dbPort' => '3306', 'dbEngine' => 'MyISAM', 'dbCharset' => 'utf8', 'timezone' => '', 'chmodDir' => '755', 'chmodFile' => '644', 'httpHosts' => '');
             $dbName = $input->getOption('dbName');
             if (!$dbName) {
                 $question = new Question('Please enter the database name : ', 'dbName');
                 $dbName = $helper->ask($input, $output, $question);
             }
             $post['dbName'] = $dbName;
             $dbUser = $input->getOption('dbUser');
             if (!$dbUser) {
                 $question = new Question('Please enter the database user name : ', 'dbUser');
                 $dbUser = $helper->ask($input, $output, $question);
             }
             $post['dbUser'] = $dbUser;
             $dbPass = $input->getOption('dbPass');
             if (!$dbPass) {
                 $question = new Question('Please enter the database password : '******'dbPass'] = $dbPass;
             $dbHost = $input->getOption('dbHost');
             if ($dbHost) {
                 $post['dbHost'] = $dbHost;
             }
             $dbPort = $input->getOption('dbPort');
             if ($dbPort) {
                 $post['dbPort'] = $dbPort;
             }
             $dbEngine = $input->getOption('dbEngine');
             if ($dbEngine) {
                 $post['dbEngine'] = $dbEngine;
             }
             $dbCharset = $input->getOption('dbCharset');
             if ($dbCharset) {
                 $post['dbCharset'] = $dbCharset;
             }
             $bundleNames = array('AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle');
             $timezone = $input->getOption('timezone');
             if (!$timezone) {
                 $question = new Question('Please enter the timezone : ', 'timezone');
                 $question->setAutocompleterValues(timezone_identifiers_list());
                 $timezone = $helper->ask($input, $output, $question);
             }
             $post['timezone'] = $timezone;
             $chmodDir = $input->getOption('chmodDir');
             if ($chmodDir) {
                 $post['chmodDir'] = $chmodDir;
             }
             $chmodFile = $input->getOption('chmodFile');
             if ($chmodFile) {
                 $post['chmodFile'] = $chmodFile;
             }
             $httpHosts = $input->getOption('httpHosts');
             if (!$httpHosts) {
                 $question = new Question('Please enter the hostname without www. Eg: pw.dev : ', 'httpHosts');
                 $httpHosts = $helper->ask($input, $output, $question);
             }
             $post['httpHosts'] = $httpHosts . "\n" . "www." . $httpHosts;
             $accountInfo = array('admin_name' => 'processwire', 'username' => '', 'userpass' => '', 'userpass_confirm' => '', 'useremail' => '', 'color' => 'classic');
             $adminUrl = $input->getOption('adminUrl');
             if ($adminUrl) {
                 $accountInfo['admin_name'] = $adminUrl;
             }
             $username = $input->getOption('username');
             if (!$username) {
                 $question = new Question('Please enter admin user name : ', 'username');
                 $username = $helper->ask($input, $output, $question);
             }
             $accountInfo['username'] = $username;
             $userpass = $input->getOption('userpass');
             if (!$userpass) {
                 $question = new Question('Please enter admin password : '******'password');
                 $question->setHidden(true);
                 $question->setHiddenFallback(false);
                 $userpass = $helper->ask($input, $output, $question);
             }
             $accountInfo['userpass'] = $userpass;
             $accountInfo['userpass_confirm'] = $userpass;
             $useremail = $input->getOption('useremail');
             if (!$useremail) {
                 $question = new Question('Please enter admin email address : ', 'useremail');
                 $useremail = $helper->ask($input, $output, $question);
             }
             $accountInfo['useremail'] = $useremail;
             $this->installProcessWire($post, $accountInfo);
             $this->cleanUpInstallation();
             $this->output->writeln("\n<info>Congratulations, ProcessWire has been successfully installed.</info>");
         }
     } catch (\Exception $e) {
         $this->cleanUp();
         throw $e;
     }
 }