From 6dee053250744f58c8adb4f230633b3d9bb8ebde Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Tue, 21 Dec 2021 13:02:48 -0500 Subject: [PATCH] Installer updates to improve profile selection instruction and options. Added a refresh button on profile screen. Added new page at processwire.comw with description of all profiles. Other minor improvements in installer. --- install.php | 200 ++++++++++++++++++++++++++++------------------------ 1 file changed, 109 insertions(+), 91 deletions(-) diff --git a/install.php b/install.php index f873cb3d..60e8be0b 100644 --- a/install.php +++ b/install.php @@ -84,16 +84,6 @@ class Installer { */ protected $inSection = false; - /** - * Available color themes - * - */ - protected $colors = array( - 'classic', - 'warm', - ); - - /** * Execution controller * @@ -143,8 +133,16 @@ class Installer { */ protected function welcome() { $this->h("Welcome. This tool will guide you through the installation process."); - $this->p("Thanks for choosing ProcessWire! If you downloaded this copy of ProcessWire from somewhere other than processwire.com or our GitHub page, please download a fresh copy before installing. If you need help or have questions during installation, please stop by our support board and we'll be glad to help."); - $this->btn("Get Started", 0, 'sign-in'); + $this->p( + "Thanks for choosing ProcessWire! " . + "If you downloaded this copy of ProcessWire from somewhere other than " . + "processwire.com or " . + "our GitHub page, " . + "please download a fresh copy before installing. " . + "If you need help or have questions during installation, please stop by our " . + "support board and we'll be glad to help." + ); + $this->btn("Get Started", array('icon' => 'sign-in')); } @@ -209,7 +207,11 @@ class Installer { } return $profiles; } - + + /** + * Select profile + * + */ protected function selectProfile() { $options = ''; $out = ''; @@ -218,7 +220,6 @@ class Installer { foreach($profiles as $name => $profile) { $title = empty($profile['title']) ? ucfirst($profile['name']) : $profile['title']; - //$selected = $name == 'site-default' ? " selected='selected'" : ""; $options .= ""; $out .= ""; } - /* -

A site installation profile is a ready-to-use and modify site for ProcessWire. - If you are just getting started with ProcessWire, we recommend choosing the Regular - or Default site profile. If you already know what you are doing, - you might prefer the Blank site profile. - */ - + $path = rtrim(str_replace('install.php', '', $_SERVER['REQUEST_URI']), '/') . '/'; + $url = htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . 'site-name/'; + echo " -

A site installation profile is a ready-to-use and modify site for ProcessWire.

+

+ A site installation profile is a ready-to-use and modify site for ProcessWire. +

+

+ If you want something other than the included “blank” profile, please + download another site profile, + unzip and place its files in $url (replacing name with the profile name) + and click the “Refresh” button to make it available here. +

Enabled " . - "(recommended while sites are in development or while testing ProcessWire)
" . - " " + "
" . + " " ); $this->p( "You can also enable or disable debug mode at any time by editing the /site/config.php file and setting " . @@ -582,7 +597,7 @@ class Installer { ); $this->sectionStop(); - $this->btn("Continue", 4); + $this->btnContinue(array('value' => 4)); $this->p("Note: After you click the button above, be patient … it may take a minute.", "detail"); } @@ -662,7 +677,7 @@ class Installer { $driver_options = array( \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'", \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION - ); + ); try { $database = new \PDO($dsn, $values['dbUser'], $values['dbPass'], $driver_options); @@ -1043,14 +1058,13 @@ class Installer { $defaults = array( 'dbEngine' => 'MyISAM', 'dbCharset' => 'utf8', - ); + ); $options = array_merge($defaults, $options); if(self::TEST_MODE) return; $restoreOptions = array(); $replace = array(); if($options['dbEngine'] != 'MyISAM') { $replace['ENGINE=MyISAM'] = "ENGINE=$options[dbEngine]"; - // $this->alertWarn("Engine changed to '$options[dbEngine]', please keep an eye out for issues."); } if($options['dbCharset'] != 'utf8') { $replace['CHARSET=utf8'] = "CHARSET=$options[dbCharset]"; @@ -1062,7 +1076,6 @@ class Installer { $replace['(255)'] = '(250)'; // max ley length in utf8mb4 is 1000 (250 * 4) } } - // $this->alertWarn("Character set has been changed to '$options[dbCharset]', please keep an eye out for issues."); } if(count($replace)) $restoreOptions['findReplaceCreateTable'] = $replace; require("./wire/core/WireDatabaseBackup.php"); @@ -1090,7 +1103,7 @@ class Installer { 'userpass' => '', 'userpass_confirm' => '', 'useremail' => '', - ); + ); $clean = array(); @@ -1102,12 +1115,6 @@ class Installer { $this->sectionStart("fa-sign-in Admin Panel"); $this->input("admin_name", "Admin Login URL", $clean['admin_name'], false, "name"); - /* - $js = "$('link#colors').attr('href', $('link#colors').attr('href').replace(/main-.*$/, 'main-' + $(this).val() + '.css'))"; - echo "

Change for a live preview

"; - */ $this->clear(); $this->p( @@ -1119,7 +1126,7 @@ class Installer { $this->sectionStart("fa-user-circle Admin Account"); $this->p( "You will use this account to login to your ProcessWire admin. It will have superuser access, so please make sure " . - "to create a strong password." + "to create a strong password." ); $this->input("username", "User", $clean['username'], false, "name"); $this->input("userpass", "Password", $clean['userpass'], false, "password"); @@ -1136,7 +1143,7 @@ class Installer { $this->p($this->getRemoveableItems(true)); $this->sectionStop(); - $this->btn("Continue", 5); + $this->btnContinue(array('value' => 5)); } /** @@ -1159,17 +1166,17 @@ class Installer { 'label' => 'Remove installer (install.php) when finished', 'file' => "/install.php", 'path' => $root . "install.php", - ), + ), 'install-dir' => array( 'label' => 'Remove installer site profile assets (/site/install/)', 'path' => $root . "site/install/", 'file' => '/site/install/', - ), + ), 'gitignore' => array( 'label' => 'Remove .gitignore file', 'path' => $root . ".gitignore", 'file' => '/.gitignore', - ) + ) ); foreach($this->findProfiles() as $name => $profile) { @@ -1294,16 +1301,6 @@ class Installer { $this->sectionStart("fa-user-circle Admin Account Saved"); $this->ok("User account saved: {$user->name}"); - /* - $colors = $wire->sanitizer->pageName($input->post('colors')); - if(!in_array($colors, $this->colors)) $colors = reset($this->colors); - $theme = $wire->modules->getInstall('AdminThemeDefault'); - if($theme) {} // ignore - $configData = $wire->modules->getModuleConfigData('AdminThemeDefault'); - $configData['colors'] = $colors; - $wire->modules->saveModuleConfigData('AdminThemeDefault', $configData); - $this->ok("Saved admin color set $colors - you will see this when you login."); - */ $this->sectionStop(); $this->sectionStart("fa-life-buoy Complete & Secure Your Installation"); @@ -1338,9 +1335,9 @@ class Installer { "with new versions and important updates." ); $this->sectionStop(); - - $this->btn("Login to Admin", 1, 'sign-in', false, true, "./$adminName/"); - $this->btn("View Site ", 1, 'angle-right', true, false, "./"); + + $this->btn("Login to Admin", array('value' => 1, 'icon' => 'sign-in', 'float' => true, 'href' => "./$adminName/")); + $this->btn("View Site ", array('value' => 1, 'icon' => 'angle-right', 'secondary' => true, 'href' => "./")); // set a define that indicates installation is completed so that this script no longer runs if(!self::TEST_MODE) { @@ -1447,29 +1444,51 @@ class Installer { } /** - * Output a button - * + * Output a button + * * @param string $label - * @param string $value - * @param string $icon - * @param bool $secondary - * @param bool $float - * @param string $href + * @param array $options * */ - protected function btn($label, $value, $icon = 'angle-right', $secondary = false, $float = false, $href = '') { - $class = $secondary ? 'ui-priority-secondary' : ''; - if($float) $class .= " uk-float-left"; - $type = 'submit'; - if($href) $type = 'button'; - if($href) echo ""; - echo "\n

"; - if($href) echo "
"; + protected function btn($label, array $options = array()) { + $defaults = array( + 'name' => 'step', + 'value' => '0', + 'icon' => 'angle-right', + 'secondary' => false, + 'float' => false, + 'href' => '', + 'type' => 'submit', + 'class' => '', + ); + $options = array_merge($defaults, $options); + $options['class'] = trim($options['class'] . ' ' . ($options['secondary'] ? 'ui-priority-secondary' : '')); + if($options['float']) $options['class'] = trim("$options[class] uk-float-left"); + if($options['href']) { + $options['type'] = 'button'; + echo ""; + } + echo "\n" . + "

" . + "" . + "

"; + if($options['href']) echo "
"; echo " "; } + /** + * Output a continue button + * + * @param array $options + * + */ + protected function btnContinue(array $options = array()) { + $this->btn('Continue', $options); + } + /** * Output a headline * @@ -1533,7 +1552,6 @@ class Installer { $type = 'text'; $pattern = "pattern='[-_a-z0-9]{2,50}' "; if($name == 'admin_name') $width = ($width*2); - //$note = "(a-z 0-9)"; $note = "(a-z 0-9)"; } $inputWidth = $width - 15;