Skip to content

Commit

Permalink
Updated Installer templates and files to use UIKit3 classes
Browse files Browse the repository at this point in the history
For feature #849. Updated all templates and files to use uikit3 (except bigdump yet). Added proper Migrate error form with back button. Fixed a few other small bugs.
  • Loading branch information
eSilverStrike committed Sep 6, 2019
1 parent 725e6e8 commit 8f702ea
Show file tree
Hide file tree
Showing 25 changed files with 463 additions and 681 deletions.
6 changes: 3 additions & 3 deletions public_html/admin/install/bigdump.php
Expand Up @@ -102,7 +102,7 @@
@date_default_timezone_set(@date_default_timezone_get());
}

$content = '<h1 class="heading">' . $LANG_MIGRATE[17] . '</h1>' . PHP_EOL;
$content = '<h1>' . $LANG_MIGRATE[17] . '</h1>' . PHP_EOL;

$error = false;
$file = false;
Expand Down Expand Up @@ -380,7 +380,7 @@
$queries_tota = $totalQueries;
}

$pct_bar = '<div style="height: 15px; width: ' . $pct_done . '% ;background-color: #000080; margin: 0;"></div>';
$pct_bar = '<progress class="uk-progress" value="' . $pct_done . '" max="100"></progress>';
} else {
$bytes_togo = ' ? ';
$bytes_tota = ' ? ';
Expand Down Expand Up @@ -433,7 +433,7 @@
// If there was an error, we offer a link to retry migration
if ($error) {
$error_gobackUrl .= '&site_url=' . urlencode($site_url) . '&site_admin_url=' . urlencode($site_admin_url);
$content .= '<p><a class="uk-button uk-button-primary uk-button-large" href="' . $error_gobackUrl . '">' . $LANG_BIGDUMP[30] . '</a></p><p>'
$content .= '<p><a class="uk-button uk-button-primary" href="' . $error_gobackUrl . '">' . $LANG_BIGDUMP[30] . '</a></p><p>'
. $LANG_BIGDUMP[31] . '</p>' . PHP_EOL;
}

Expand Down
91 changes: 50 additions & 41 deletions public_html/admin/install/classes/installer.class.php
Expand Up @@ -203,7 +203,7 @@ public function getAlertMessage($message, $type = 'notice', $title = '')
$retval .= '<h3>' . $title . '</h3>';
}
$retval .= '<div class="uk-alert uk-alert-' . $style . '">';
$retval .= '<span class="uk-badge uk-badge-' . $style . '">' . $type . '</span> ' . $message . '</div>' . PHP_EOL;
$retval .= '<span class="uk-label uk-label-' . $style . '">' . $type . '</span> ' . $message . '</div>' . PHP_EOL;

return $retval;
}
Expand All @@ -222,7 +222,7 @@ private function checkUploadedFileSize()
if ($postMaxSize && ($contentLength > $postMaxSize)) {
// If size exceeds, display an error message
$template = $this->getTemplateObject();
$content = '<h1 class="heading">' . $this->LANG['ERROR'][8] . '</h1>' . PHP_EOL
$content = '<h1>' . $this->LANG['ERROR'][8] . '</h1>' . PHP_EOL
. $this->getAlertMessage($this->LANG['ERROR'][7]);
$template->set('content', $content);
$template->display('index');
Expand All @@ -243,7 +243,7 @@ private function checkUpgradeMessage($currentVersion)

if ($this->doDatabaseUpgrades($currentVersion, true) && !empty($this->upgradeMessages)) {
$prompt = 'information';
$retval = '<h1 class="heading">' . $this->LANG['ERROR'][14] . '</h1>' . PHP_EOL; // Upgrade Notice
$retval = '<h1>' . $this->LANG['ERROR'][14] . '</h1>' . PHP_EOL; // Upgrade Notice
$this->env['site_url'] = $this->get('site_url', $this->post('site_url', $this->getSiteUrl()));
$this->env['site_admin_url'] = $this->get('site_admin_url', $this->post('site_admin_url', $this->getSiteAdminUrl()));

Expand Down Expand Up @@ -664,9 +664,16 @@ private function checkPermissions()

// number of files with wrong permissions
$numWrong = 0;
$retval_permissions = '<p><label class="perms-label"><strong>'
. $this->LANG['INSTALL'][10] . '</strong></label> ' . PHP_EOL
. '<strong>' . $this->LANG['INSTALL'][11] . '</strong></p>' . PHP_EOL;
$retval_permissions = '
<table class="uk-table uk-table-small">
<thead>
<tr>
<th><strong>' . $this->LANG['INSTALL'][10] . '</strong></th>
<th><strong>' . $this->LANG['INSTALL'][11] . '</strong></th>
</tr>
</thead>
<tbody>';

$chmodString = 'chmod -R 777 ';

// Files to check if writable
Expand Down Expand Up @@ -719,40 +726,42 @@ private function checkPermissions()
$checkSelinux = true;
$cmdSelinux .= $file . ' ';
}

$retval_permissions .= '<p class="clearboth">'
. '<label class="perms-label"><code>' . $file . '</code></label>' . PHP_EOL
. ' <span class="permissions-list">' . $this->LANG['INSTALL'][12] . ' ' . $permShouldBe . '</span> ('
. $this->LANG['INSTALL'][13] . ' ' . $permission . ')'
. '</p>' . PHP_EOL;

$retval_permissions .= '
<tr>
<td><code>' . $file . '</code></td>
<td><span class="uk-text-danger">' . $this->LANG['INSTALL'][12] . ' ' . $permShouldBe . '</span> (' . $this->LANG['INSTALL'][13] . ' ' . $permission . ')</td>
</tr>';

$chmodString .= $file . ' ';
$numWrong++;
}
}
$retval_permissions .= '</tbody></table>';

$retval_step = 1;

// Display permissions, etc
if ($checkSelinux) {
$retval .= '<h1 class="heading">' . $this->LANG['INSTALL'][101] . ' ' . $retval_step . ' - ' . $this->LANG['INSTALL'][97] . '</h1>' . PHP_EOL
$retval .= '<h1>' . $this->LANG['INSTALL'][101] . ' ' . $retval_step . ' - ' . $this->LANG['INSTALL'][97] . '</h1>' . PHP_EOL
. $this->LANG['INSTALL'][110];
$cmd = 'chcon -Rt httpd_user_rw_content_t ' . $cmdSelinux;
$retval .= '<pre><code>' . $cmd . PHP_EOL
. '</code></pre><br>' . PHP_EOL;
$retval_step++;
} elseif ($numWrong) {
// If any files have incorrect permissions
$retval .= '<h1 class="heading">' . $this->LANG['INSTALL'][101] . ' ' . $retval_step . ' - ' . $this->LANG['INSTALL'][97] . '</h1>' . PHP_EOL;
$retval .= '<h1>' . $this->LANG['INSTALL'][101] . ' ' . $retval_step . ' - ' . $this->LANG['INSTALL'][97] . '</h1>' . PHP_EOL;
$retval_step++;

if ($this->get('install_type') !== null) {
// If the user tried to start an installation before setting file permissions
$retval .= '<p>'
. '<div class="notice">'
. '<span class="error">' . $this->LANG['INSTALL'][38] . '</span> '
. '<div class="uk-alert-danger" uk-alert>'
. '<a class="uk-alert-close" uk-close></a>'
. '<span class="uk-label uk-label-danger">' . $this->LANG['INSTALL'][38] . '</span> '
. $this->LANG['INSTALL'][21]
. '</div>'
. '</p>' . PHP_EOL;
. '</div>' . PHP_EOL;
} else {
// The first page that is displayed during the "check_permissions" step
$retval .= '<p>' . $this->LANG['INSTALL'][9] . '</p>' . PHP_EOL
Expand All @@ -761,12 +770,11 @@ private function checkPermissions()

// List the files that have incorrect permissions and also what the permissions should be
// Also, list the auto-generated chmod command for advanced users
$retval .= '<div class="file-permissions">' . PHP_EOL
. $retval_permissions . '</div>' . PHP_EOL
. '<h2 class="clearboth">' . $this->LANG['INSTALL'][98] . '</h2>' . PHP_EOL
$retval .= $retval_permissions . PHP_EOL
. '<h2>' . $this->LANG['INSTALL'][98] . '</h2>' . PHP_EOL
. '<p>' . $this->LANG['INSTALL'][99] . '</p>' . PHP_EOL
. '<pre><code>' . $chmodString . PHP_EOL
. '</code></pre><br>' . PHP_EOL;
. '</code></pre>' . PHP_EOL;
$this->env['step']++;
} else {
// Set the install type if the user clicked one
Expand Down Expand Up @@ -894,11 +902,8 @@ public function getHelpLink($var)
global $LANG_HELP, $LANG_LABEL;

$id = 'help-' . $var;
return '<button uk-toggle="target: #' . $id . '; mode: click" type="button">?</button>' . PHP_EOL
. '<div id="' . $id . '" class="uk-card uk-card-secondary uk-card-body" hidden>'
. '<h3 class="uk-card-title">' . $LANG_LABEL[$var] . '</h3>'
. '<p>' . $LANG_HELP[$var] . '</p>'
. '</div>';

return '<span uk-icon="icon: info" uk-tooltip="' . htmlentities($LANG_HELP[$var]) . '"</span>';
}

/**
Expand Down Expand Up @@ -992,10 +997,10 @@ private function listOfSupportedDBs($gl_path, $selected_dbtype, $list_innodb = f
}

if (count($dbs) === 0) {
$retval = '<span class="error">' . $this->LANG['INSTALL'][108] . '</span>' . PHP_EOL;
$retval = '<span class="uk-text-danger uk-text-emphasis">' . $this->LANG['INSTALL'][108] . '</span>' . PHP_EOL;
} else {
$disabled = $isInstall ? '' : ' disabled';
$retval = '<select id="db_type" name="db_type"' . $disabled . ' class="uk-select">' . PHP_EOL
$retval = '<select id="db_type" name="db_type"' . $disabled . ' class="uk-select uk-width-auto">' . PHP_EOL
. $retval
. '</select>' . PHP_EOL;

Expand Down Expand Up @@ -3302,12 +3307,12 @@ public function getAlertMsg($mMessage, $mType = 'notice')

default:
$mType = $LANG_INSTALL[59];
$mStyle = 'notice';
$mStyle = 'primary';
break;
}

return '<div class="uk-alert uk-alert-large uk-alert-' . $mStyle . '">'
. '<span class="uk-badge uk-badge-' . $mStyle . '">' . $mType . '</span> ' . $mMessage . '</div>' . PHP_EOL;
return '<div class="uk-alert uk-alert-' . $mStyle . '">'
. '<span class="uk-label uk-label-' . $mStyle . '">' . $mType . '</span> ' . $mMessage . '</div>' . PHP_EOL;
}

/**
Expand Down Expand Up @@ -3610,7 +3615,7 @@ private function migrateStep1()

// Check if there are any files in the backups directory
if (count($backupFiles) > 0) {
$backupFileSelector = '<select name="backup_file" class="uk-select">' . PHP_EOL
$backupFileSelector = '<select name="backup_file" class="uk-select uk-width-auto">' . PHP_EOL
. '<option value="">' . $LANG_MIGRATE[10] . '</option>' . PHP_EOL;

// List each of the backup files in the backups directory
Expand All @@ -3637,7 +3642,7 @@ private function migrateStep1()
// Check if the plugins directory is writable by the web server before we even bother uploading anything
$isWritable = is_writable($backup_dir);
$this->env['backup_file'] = ($fileUploads && $isWritable)
? '<input class="uk-input" type="file" name="backup_file"><br>' . PHP_EOL
? '<input type="file" name="backup_file">' . PHP_EOL
: '';

if ($fileUploads) {
Expand Down Expand Up @@ -3759,16 +3764,16 @@ private function migrateStep2()
$display .= $LANG_MIGRATE[19] . $backup_file_copy . $LANG_MIGRATE[20] . $backup_dir . '.' . PHP_EOL;
} else {
$display .= '<p>' . $LANG_MIGRATE[21] . ' <code>' . $backupFile['name'] . '</code> ' . $LANG_MIGRATE[22] . '</p><br>' . PHP_EOL
. '<form action="index.php" method="post" class="uk-form"><p align="center">' . PHP_EOL
. '<form action="index.php" method="post"><p align="center">' . PHP_EOL
. '<input type="hidden" name="mode" value="migrate">' . PHP_EOL
. '<input type="hidden" name="step" value="3">' . PHP_EOL
. '<input type="hidden" name="dbconfig_path" value="' . htmlspecialchars($this->env['dbconfig_path']) . '">' . PHP_EOL
. '<input type="hidden" name="site_url" value="' . urlencode($_REQUEST['site_url']) . '">' . PHP_EOL
. '<input type="hidden" name="site_admin_url" value="' . urlencode($_REQUEST['site_admin_url']) . '">' . PHP_EOL
. '<input type="hidden" name="backup_file" value="' . $backupFile['name'] . '">' . PHP_EOL
. '<input type="hidden" name="language" value="' . $this->env['language'] . '">' . PHP_EOL
. '<button type="submit" class="uk-button uk-button-primary uk-button-large" name="overwrite_file" value="' . $LANG_MIGRATE[23] . '">' . $LANG_MIGRATE[23] . '</button>' . PHP_EOL
. '<button type="submit" class="uk-button uk-button-primary uk-button-large" name="no" value="' . $LANG_MIGRATE[24] . '" onclick="document.location=\'index.php\'">' . $LANG_MIGRATE[24] . '</button>' . PHP_EOL
. '<button type="submit" class="uk-button uk-button-primary" name="overwrite_file" value="' . $LANG_MIGRATE[23] . '">' . $LANG_MIGRATE[23] . '</button>' . PHP_EOL
. '<button type="submit" class="uk-button uk-button-primary" name="no" value="' . $LANG_MIGRATE[24] . '" onclick="document.location=\'index.php\'">' . $LANG_MIGRATE[24] . '</button>' . PHP_EOL
. '</p></form>' . PHP_EOL;
}
} else {
Expand Down Expand Up @@ -3840,6 +3845,10 @@ private function migrateStep2()
. '&site_admin_url=' . urlencode($_REQUEST['site_admin_url']));
break;
} // End switch ($_REQUEST['migration_type']
} else {
// Add prompt
$this->env['migrate_errors'] = $display;
$display = MicroTemplate::quick(PATH_LAYOUT, 'migrate_prompt_error', $this->env);
}

return $display;
Expand Down Expand Up @@ -4268,11 +4277,11 @@ private function migrateStep4()
}

$display .= '<p>' . $LANG_MIGRATE[36] . '</p>' . PHP_EOL
. '<form action="success.php" method="get" class="uk-form">' . PHP_EOL
. '<form action="success.php" method="get">' . PHP_EOL
. '<input type="hidden" name="type" value="migrate">' . PHP_EOL
. '<input type="hidden" name="language" value="' . $language . '">' . PHP_EOL
. '<input type="hidden" name="" value="">' . PHP_EOL
. '<p><button type="submit" class="uk-button uk-button-primary uk-button-large" name="" value="' . $LANG_INSTALL[62] . '">' . $LANG_INSTALL[62] . '&nbsp;&nbsp;' . $this->env['icon_arrow_next'] . '</button></p>' . PHP_EOL
. '<div class="uk-margin"><button type="submit" class="uk-button uk-button-primary" name="" value="' . $LANG_INSTALL[62] . '">' . $LANG_INSTALL[62] . '&nbsp;&nbsp;' . $this->env['icon_arrow_next'] . '</button></div>' . PHP_EOL
. '</form>';
} else {
header('Location: success.php?type=migrate&language=' . $language);
Expand Down Expand Up @@ -4319,7 +4328,7 @@ private function installEngine($installType, $installStep)
}
}

$retval .= '<h1 class="heading">'
$retval .= '<h1>'
. $this->LANG['INSTALL'][101] . ' ' . htmlspecialchars($this->request('display_step'))
. ' - ' . $this->LANG['INSTALL'][102]
. '</h1>' . PHP_EOL;
Expand Down Expand Up @@ -4560,7 +4569,7 @@ private function installEngine($installType, $installStep)
// If using MySQL check to see if InnoDB is supported
if ($DB['type'] === 'mysql-innodb' && !$this->isInnodbSupported()) {
// Warn that InnoDB tables are not supported
$retval .= MicroTemplate::quick(PATH_LAYOUT, 'step2-install', $this->env);
$retval .= MicroTemplate::quick(PATH_LAYOUT, 'step2-install', array_merge($this->env, $params));
} else {
// Continue on to step 3 where the installation will happen
if ($DB['type'] === 'mysql-innodb') {
Expand Down
54 changes: 41 additions & 13 deletions public_html/admin/install/configinfo.php
Expand Up @@ -58,18 +58,40 @@
unset($_CONF['mail_settings']['password']);
}

$display = "<html>\n<head><title>Configuration Settings</title></head>\n<body>\n";
$n = 0;
$display .= '<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border: thin black solid;">';
if (!isset($LANG_DIRECTION)) {
$LANG_DIRECTION = 'ltr';
}
$env['rtl'] = $LANG_DIRECTION ==='rtl' ? '-rtl' : '';

$display = '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="robots" content="noindex,nofollow">
<title>Configuration Settings</title>
<link rel="stylesheet" type="text/css" href="../../vendor/uikit3/css/uikit' . $env['rtl'] . '.min.css">
<link rel="stylesheet" type="text/css" href="layout/style' . $env['rtl'] . '.css">
<script src="../../vendor/uikit3/js/uikit.min.js"></script>
<script src="../../vendor/uikit3/js/uikit-icons.min.js"></script>
</head>
<body dir="' . $LANG_DIRECTION . '">';

$display .= '
<div class="uk-container">
<section class="uk-section uk-section-default uk-section-small">
<h1>Configuration Settings</h1>
<div class="uk-overflow-auto">
<table class="uk-table uk-table-striped">
<thead><tr><th>Option</th><th>Value</th></tr></thead>
<tbody>';

foreach ($_CONF as $option => $value) {
$display .= '<tr';
if ($n % 2 == 0) {
$display .= ' style="background-color: ' . $highlight_on . '">';
} else {
$display .= ' style="background-color: ' . $highlight_off . '">';
}
$display .= '<td style="border: thin black solid; padding: 2px;"><strong>$_CONF[\'<a href="'
$display .= '<tr>';
$display .= '<td><strong>$_CONF[\'<a href="'
. $docs . $option . '">' . $option . '</a>\']</strong></td>';
if (is_array($value)) {
ob_start();
Expand All @@ -82,10 +104,16 @@
} elseif (!isset($value)) {
$value = '&nbsp;';
}
$display .= '<td style="border: thin black solid; padding: 2px;"><strong>' . $value . '</strong></td>';
$display .= '<td>' . $value . '</td>';
$display .= '</tr>';
$n++;
}
$display .= "</table>\n</body>\n</html>";
$display .= '
</tbody>
</table>
</div>
</section>
</div>
</body>
</html>';

echo $display;
2 changes: 1 addition & 1 deletion public_html/admin/install/help.php
Expand Up @@ -60,7 +60,7 @@
$label = preg_replace('/[^a-z0-9_]/', '', $_GET['label']);
}

$content = '<h1 class="heading">' . $LANG_HELP[0] . '</h1>' . PHP_EOL;
$content = '<h1>' . $LANG_HELP[0] . '</h1>' . PHP_EOL;

foreach ($LANG_LABEL as $key => $labeltext) {
$content .= '
Expand Down

0 comments on commit 8f702ea

Please sign in to comment.