Skip to content

Commit

Permalink
Merge pull request #12842 from jdalsem/various-stuff
Browse files Browse the repository at this point in the history
redis and installer changes
  • Loading branch information
jeabakker committed Sep 30, 2019
2 parents 90839bb + 5f23eff commit 90777f3
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 62 deletions.
5 changes: 5 additions & 0 deletions elgg-config/settings.example.php
Expand Up @@ -165,6 +165,11 @@
*/
//$CONFIG->redis = true;
//
//$CONFIG->redis_options = array (
// 'database' => '', // The "database" option lets developers specific which specific database to use.
// 'password' => '', // The "password" option is used for clusters which required authentication.
//);
//
//$CONFIG->redis_servers = array (
// array('server1', 6379),
// array('server2', 6379)
Expand Down
9 changes: 5 additions & 4 deletions engine/classes/Elgg/Cache/CompositeCache.php
Expand Up @@ -262,10 +262,11 @@ protected function buildRedisDriver() {
if (!$this->config->redis || empty($this->config->redis_servers)) {
return null;
}

return new Redis([
'servers' => $this->config->redis_servers,
]);

$options = $this->config->redis_options ?: [];
$options['servers'] = $this->config->redis_servers;

return new Redis($options);
}

/**
Expand Down
1 change: 1 addition & 0 deletions engine/classes/Elgg/Config.php
Expand Up @@ -80,6 +80,7 @@
* @property bool $profiling_sql
* @property array $processed_upgrades
* @property bool $redis
* @property array $redis_options
* @property array $redis_servers
* @property string[] $registered_entities
* @property bool $remove_branding Is Elgg branding disabled
Expand Down
14 changes: 13 additions & 1 deletion engine/classes/Elgg/I18n/Translator.php
Expand Up @@ -235,12 +235,24 @@ public function setCurrentLanguage($language = null) {
public function detectLanguage() {
// detect from URL
$url_lang = _elgg_services()->request->getParam('hl');
$user = _elgg_services()->session->getLoggedInUser();

if (!empty($url_lang)) {
// store language for logged out users
if (empty($user)) {
$cookie = new \ElggCookie('language');
$cookie->value = $url_lang;
elgg_set_cookie($cookie);
}
return $url_lang;
}

$cookie = _elgg_services()->request->cookies->get('language');
if (!empty($cookie)) {
return $cookie;
}

// check logged in user
$user = _elgg_services()->session->getLoggedInUser();
if (!empty($user) && !empty($user->language)) {
return $user->language;
}
Expand Down
6 changes: 6 additions & 0 deletions install/languages/en.php
Expand Up @@ -10,12 +10,18 @@

'install:next' => 'Next',
'install:refresh' => 'Refresh',
'install:change_language' => 'Change language',

'install:welcome:instructions' => "Installing Elgg has 6 simple steps and reading this welcome is the first one!
If you haven't already, read through the installation instructions included with Elgg (or click the instructions link at the bottom of the page).
If you are ready to proceed, click the Next button.",

'install:footer:instructions' => "Installation instructions",
'install:footer:troubleshooting' => "Installation troubleshooting",
'install:footer:community' => "Elgg community forums",

'install:requirements:instructions:success' => "Your server passed the requirement checks.",
'install:requirements:instructions:failure' => "Your server failed the requirements check. After you have fixed the below issues, refresh this page. Check the troubleshooting links at the bottom of this page if you need further assistance.",
'install:requirements:instructions:warning' => "Your server passed the requirements check, but there is at least one warning. We recommend that you check the install troubleshooting page for more details.",
Expand Down
3 changes: 2 additions & 1 deletion views/default/admin/server/redis.php
Expand Up @@ -9,7 +9,8 @@
return;
}

$redis = new Redis();
$options = elgg_get_config('redis_options') ?: [];
$redis = new Redis($options);

foreach ($servers as $server) {
$redis->connect($server[0], $server[1]);
Expand Down
6 changes: 6 additions & 0 deletions views/installation/install.css.php
Expand Up @@ -37,6 +37,7 @@

.elgg-layout-columns > .elgg-sidebar-alt {
padding: 2rem;
max-width: 20rem;
}

.elgg-layout-columns > .elgg-body {
Expand All @@ -48,9 +49,14 @@
text-align: center;
}

.elgg-sidebar-alt .elgg-field {
padding-left: 2rem;
}

.elgg-sidebar-alt ol {
list-style: decimal;
padding-left: 2rem;
padding-bottom: 2rem;
font-size: 1rem;
}

Expand Down
4 changes: 4 additions & 0 deletions views/installation/install.js
Expand Up @@ -18,6 +18,10 @@ $(function() {
$(this).prev().attr('disabled', false);
}
});

$('.elgg-install-language').change(function(index, elem) {
location.href = $(this).val();
});
});

elgg = {
Expand Down
61 changes: 5 additions & 56 deletions views/installation/page/default.php
@@ -1,62 +1,11 @@
<?php
/**
* Elgg install pageshell
*
* @uses $vars['title'] The page title
* @uses $vars['body'] The main content of the page
* @uses $vars['sysmessages'] Array of system status messages
*/

use Elgg\Filesystem\Directory as ElggDirectory;
$params = [
'head' => elgg_view('page/elements/head', $vars),
'body' => elgg_view('page/elements/body', $vars),
];

$title = elgg_echo('install:title');
$title .= " : " . elgg_extract('title', $vars);

$isElggAtRoot = Elgg\Application::elggDir()->getPath() === ElggDirectory\Local::projectRoot()->getPath();
$elggSubdir = $isElggAtRoot ? '' : 'vendor/elgg/elgg/';

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo $title; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="icon" href="<?php echo elgg_get_site_url() . $elggSubdir; ?>views/default/graphics/favicon.ico" />
<script src="<?php echo elgg_get_site_url(); ?>vendor/bower-asset/jquery/dist/jquery.min.js"></script>
</head>
<body>
<div class="elgg-page">
<div class="elgg-page-body">
<div class="elgg-layout">
<div class="elgg-layout-columns">
<aside class="elgg-sidebar-alt" role="complementary">
<header class="elgg-page-header" role="banner">
<img src="<?= elgg_get_site_url() . $elggSubdir; ?>views/default/graphics/elgg_logo.png" alt="Elgg" />
</header>
<?php echo elgg_view('page/elements/sidebar', $vars); ?>
</aside>
<main class="elgg-body" role="main">
<h1><?php echo elgg_extract('title', $vars); ?></h1>
<?php echo elgg_view('page/elements/messages', ['object' => elgg_extract('sysmessages', $vars)]); ?>
<?php echo elgg_extract('body', $vars); ?>
</main>
</div>
</div>
</div>
<footer class="elgg-page-footer" role="contentinfo">
<ul class="elgg-menu elgg-menu-footer">
<li><a href="http://learn.elgg.org/en/stable/intro/install.html" target="_blank">Install instructions</a></li>
<li><a href="http://learn.elgg.org/en/stable/intro/install.html#troubleshooting" target="_blank">Install troubleshooting</a></li>
<li><a href="https://elgg.org/discussion/all" target="_blank">Elgg community forums</a></li>
</ul>
</footer>
</div>
<style>
<?= elgg_view('install.css') ?>
</style>
<script>
<?= elgg_view('install.js') ?>
</script>
</body>
</html>
echo elgg_view('page/elements/html', $params);
61 changes: 61 additions & 0 deletions views/installation/page/elements/body.php
@@ -0,0 +1,61 @@
<?php
/**
* Elgg install body
*
* @uses $vars['body'] The main content of the page
* @uses $vars['sysmessages'] Array of system status messages
*/

use Elgg\Filesystem\Directory as ElggDirectory;

$isElggAtRoot = Elgg\Application::elggDir()->getPath() === ElggDirectory\Local::projectRoot()->getPath();
$elggSubdir = $isElggAtRoot ? '' : 'vendor/elgg/elgg/';

$footer_menu_items = elgg_format_element('li', [], elgg_view('output/url', [
'text' => elgg_echo('install:footer:instructions'),
'href' => 'http://learn.elgg.org/en/stable/intro/install.html',
'target' => '_blank',
]));
$footer_menu_items .= elgg_format_element('li', [], elgg_view('output/url', [
'text' => elgg_echo('install:footer:troubleshooting'),
'href' => 'http://learn.elgg.org/en/stable/intro/install.html#troubleshooting',
'target' => '_blank',
]));
$footer_menu_items .= elgg_format_element('li', [], elgg_view('output/url', [
'text' => elgg_echo('install:footer:community'),
'href' => 'https://elgg.org/discussion/all',
'target' => '_blank',
]));

$footer_menu = elgg_format_element('ul', ['class' => 'elgg-menu elgg-menu-footer'], $footer_menu_items);

?>

<div class="elgg-page">
<div class="elgg-page-body">
<div class="elgg-layout">
<div class="elgg-layout-columns">
<aside class="elgg-sidebar-alt" role="complementary">
<header class="elgg-page-header" role="banner">
<img src="<?= elgg_get_site_url() . $elggSubdir; ?>views/default/graphics/elgg_logo.png" alt="Elgg" />
</header>
<?php echo elgg_view('page/elements/sidebar', $vars); ?>
</aside>
<main class="elgg-body" role="main">
<h1><?php echo elgg_extract('title', $vars); ?></h1>
<?php echo elgg_view('page/elements/messages', ['object' => elgg_extract('sysmessages', $vars)]); ?>
<?php echo elgg_extract('body', $vars); ?>
</main>
</div>
</div>
</div>
<footer class="elgg-page-footer" role="contentinfo">
<?php echo $footer_menu; ?>
</footer>
</div>
<style>
<?= elgg_view('install.css') ?>
</style>
<script>
<?= elgg_view('install.js') ?>
</script>
22 changes: 22 additions & 0 deletions views/installation/page/elements/head.php
@@ -0,0 +1,22 @@
<?php
/**
* Elgg install head
*
* @uses $vars['title'] The page title
*/

use Elgg\Filesystem\Directory as ElggDirectory;

$isElggAtRoot = Elgg\Application::elggDir()->getPath() === ElggDirectory\Local::projectRoot()->getPath();
$elggSubdir = $isElggAtRoot ? '' : 'vendor/elgg/elgg/';

$title = elgg_echo('install:title');
$title .= " : " . elgg_extract('title', $vars);

?>

<title><?php echo $title; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="icon" href="<?php echo elgg_get_site_url() . $elggSubdir; ?>views/default/graphics/favicon.ico" />
<script src="<?php echo elgg_get_site_url(); ?>vendor/bower-asset/jquery/dist/jquery.min.js"></script>
14 changes: 14 additions & 0 deletions views/installation/page/elements/sidebar.php
Expand Up @@ -27,3 +27,17 @@
echo "<li class=\"$class\">$text</li>";
}
echo '</ol>';

$options_values = [];
foreach (get_installed_translations() as $key => $value) {
$options_values[elgg_http_add_url_query_elements(current_page_url(), ['hl' => $key])] = $value;
}

echo elgg_view_field([
'#type' => 'select',
'#label' => elgg_echo('install:change_language'),
'class' => 'elgg-install-language',
'name' => 'installer_language',
'value' => elgg_http_add_url_query_elements(current_page_url(), ['hl' => get_current_language()]),
'options_values' => $options_values,
]);

0 comments on commit 90777f3

Please sign in to comment.