more language cleanup and adding mysql-servers to customer add/delete in UI
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -46,7 +46,6 @@ class Ajax
|
||||
protected string $action;
|
||||
protected string $theme;
|
||||
protected array $userinfo;
|
||||
protected array $lng;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
@@ -67,8 +66,6 @@ class Ajax
|
||||
{
|
||||
$this->userinfo = $this->getValidatedSession();
|
||||
|
||||
$this->initLang();
|
||||
|
||||
switch ($this->action) {
|
||||
case 'newsfeed':
|
||||
return $this->getNewsfeed();
|
||||
@@ -100,55 +97,6 @@ class Ajax
|
||||
return CurrentUser::getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize global $lng variable to have
|
||||
* localized strings available for the ApiCommands
|
||||
*/
|
||||
private function initLang()
|
||||
{
|
||||
global $lng;
|
||||
|
||||
// query the whole table
|
||||
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "`");
|
||||
|
||||
$langs = [];
|
||||
// presort languages
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$langs[$row['language']][] = $row;
|
||||
}
|
||||
|
||||
// set default language before anything else to
|
||||
// ensure that we can display messages
|
||||
$language = Settings::Get('panel.standardlanguage');
|
||||
|
||||
if (isset($this->userinfo['language']) && isset($langs[$this->userinfo['language']])) {
|
||||
// default: use language from session, #277
|
||||
$language = $this->userinfo['language'];
|
||||
} elseif (isset($this->userinfo['def_language'])) {
|
||||
$language = $this->userinfo['def_language'];
|
||||
}
|
||||
|
||||
// include every english language file we can get
|
||||
foreach ($langs['English'] as $value) {
|
||||
include_once FileDir::makeSecurePath(Froxlor::getInstallDir() . '/' . $value['file']);
|
||||
}
|
||||
|
||||
// now include the selected language if its not english
|
||||
if ($language != 'English') {
|
||||
if (isset($langs[$language])) {
|
||||
foreach ($langs[$language] as $value) {
|
||||
include_once FileDir::makeSecurePath(Froxlor::getInstallDir() . '/' . $value['file']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// last but not least include language references file
|
||||
include_once FileDir::makeSecurePath(Froxlor::getInstallDir() . '/lng/lng_references.php');
|
||||
|
||||
// set array
|
||||
$this->lng = $lng;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
@@ -225,15 +225,13 @@ class Cronjob
|
||||
*/
|
||||
public static function getCronjobsLastRun()
|
||||
{
|
||||
global $lng;
|
||||
|
||||
$query = "SELECT `lastrun`, `desc_lng_key` FROM `" . TABLE_PANEL_CRONRUNS . "` WHERE `isactive` = '1' ORDER BY `cronfile` ASC";
|
||||
$result = Database::query($query);
|
||||
|
||||
$cronjobs_last_run = [];
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
$cronjobs_last_run[] = [
|
||||
'title' => $lng['crondesc'][$row['desc_lng_key']],
|
||||
'title' => lng('crondesc.' . $row['desc_lng_key']),
|
||||
'lastrun' => $row['lastrun']
|
||||
];
|
||||
}
|
||||
@@ -261,8 +259,6 @@ class Cronjob
|
||||
*/
|
||||
public static function getOutstandingTasks()
|
||||
{
|
||||
global $lng;
|
||||
|
||||
$query = "SELECT * FROM `" . TABLE_PANEL_TASKS . "` ORDER BY `type` ASC";
|
||||
$result = Database::query($query);
|
||||
|
||||
@@ -275,21 +271,20 @@ class Cronjob
|
||||
$task_id = $row['type'];
|
||||
if (TaskId::isValid($task_id)) {
|
||||
$task_constname = TaskId::convertToConstant($task_id);
|
||||
$task = [
|
||||
'desc' => isset($lng['tasks'][$task_constname]) ? $lng['tasks'][$task_constname] : $task_constname
|
||||
];
|
||||
$lngParams = [];
|
||||
if (is_array($row['data'])) {
|
||||
// task includes loginname
|
||||
if (isset($row['data']['loginname'])) {
|
||||
$loginname = $row['data']['loginname'];
|
||||
$task['desc'] = str_replace('%loginname%', $loginname, $task['desc']);
|
||||
$lngParams = [$row['data']['loginname']];
|
||||
}
|
||||
// task includes domain data
|
||||
if (isset($row['data']['domain'])) {
|
||||
$domain = $row['data']['domain'];
|
||||
$task['desc'] = str_replace('%domain%', $domain, $task['desc']);
|
||||
$lngParams = [$row['data']['domain']];
|
||||
}
|
||||
}
|
||||
$task = [
|
||||
'desc' => lng('tasks.' . $task_constname, $lngParams)
|
||||
];
|
||||
} else {
|
||||
// unknown
|
||||
$task = ['desc' => "ERROR: Unknown task type '" . $row['type'] . "'"];
|
||||
@@ -299,10 +294,9 @@ class Cronjob
|
||||
}
|
||||
|
||||
if (empty($tasks)) {
|
||||
$tasks = [['desc' => $lng['tasks']['noneoutstanding']]];
|
||||
$tasks = [['desc' => lng('tasks.noneoutstanding')]];
|
||||
}
|
||||
|
||||
$text = $lng['tasks']['outstanding_tasks'];
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class Domain
|
||||
return $attributes['fields']['documentroot'];
|
||||
}
|
||||
}
|
||||
return UI::getLng('domains.aliasdomain') . ' ' . $attributes['fields']['aliasdomain'];
|
||||
return lng('domains.aliasdomain') . ' ' . $attributes['fields']['aliasdomain'];
|
||||
}
|
||||
|
||||
public static function domainExternalLinkInfo(array $attributes)
|
||||
@@ -79,13 +79,13 @@ class Domain
|
||||
if (Settings::Get('system.awstats_enabled') == '1') {
|
||||
$statsapp = 'awstats';
|
||||
}
|
||||
$result .= ' <a href="http://' . $attributes['data'] . '/' . $statsapp . '" rel="external" title="' . UI::getLng('domains.statstics') . '"><i class="fa-solid fa-chart-line text-secondary"></i></a>';
|
||||
$result .= ' <a href="http://' . $attributes['data'] . '/' . $statsapp . '" rel="external" title="' . lng('domains.statstics') . '"><i class="fa-solid fa-chart-line text-secondary"></i></a>';
|
||||
}
|
||||
if ($attributes['fields']['registration_date'] != '') {
|
||||
$result .= '<br><small>' . UI::getLng('domains.registration_date') . ': ' . $attributes['fields']['registration_date'] . '</small>';
|
||||
$result .= '<br><small>' . lng('domains.registration_date') . ': ' . $attributes['fields']['registration_date'] . '</small>';
|
||||
}
|
||||
if ($attributes['fields']['termination_date'] != '') {
|
||||
$result .= '<br><small>' . UI::getLng('domains.termination_date_overview') . ': ' . $attributes['fields']['termination_date'] . '</small>';
|
||||
$result .= '<br><small>' . lng('domains.termination_date_overview') . ': ' . $attributes['fields']['termination_date'] . '</small>';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ class PHPConf
|
||||
$domains .= $idna->decode($configdomain) . "<br>";
|
||||
}
|
||||
if ($subdomains_count == 0 && empty($domains)) {
|
||||
$domains = UI::getLng('admin.phpsettings.notused');
|
||||
$domains = lng('admin.phpsettings.notused');
|
||||
} else {
|
||||
$domains .= !empty($subdomains_count) ? ((!empty($domains) ? '+ ' : '') . $subdomains_count . ' ' . UI::getLng('customer.subdomains')) : '';
|
||||
$domains .= !empty($subdomains_count) ? ((!empty($domains) ? '+ ' : '') . $subdomains_count . ' ' . lng('customer.subdomains')) : '';
|
||||
}
|
||||
|
||||
return $domains;
|
||||
@@ -75,8 +75,8 @@ class PHPConf
|
||||
'href' => $linker->getLink([
|
||||
'section' => 'phpsettings',
|
||||
'page' => 'fpmdaemons',
|
||||
'action' => 'edit',
|
||||
'id' => $attributes['fields']['fpmsettingid'],
|
||||
'searchfield' => 'id',
|
||||
'searchtext' => $attributes['fields']['fpmsettingid'],
|
||||
]),
|
||||
]
|
||||
];
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Froxlor\UI\Callbacks;
|
||||
|
||||
use Froxlor\PhpHelper;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
|
||||
class ProgressBar
|
||||
{
|
||||
@@ -41,7 +40,7 @@ class ProgressBar
|
||||
{
|
||||
$infotext = null;
|
||||
if (isset($attributes['fields']['webspace_used']) && isset($attributes['fields']['mailspace_used']) && isset($attributes['fields']['dbspace_used'])) {
|
||||
$infotext = UI::getLng('panel.used') . ':' . PHP_EOL;
|
||||
$infotext = lng('panel.used') . ':' . PHP_EOL;
|
||||
$infotext .= 'web: ' . PhpHelper::sizeReadable($attributes['fields']['webspace_used'] * 1024, null, 'bi') . PHP_EOL;
|
||||
$infotext .= 'mail: ' . PhpHelper::sizeReadable($attributes['fields']['mailspace_used'] * 1024, null, 'bi') . PHP_EOL;
|
||||
$infotext .= 'mysql: ' . PhpHelper::sizeReadable($attributes['fields']['dbspace_used'] * 1024, null, 'bi');
|
||||
@@ -57,7 +56,7 @@ class ProgressBar
|
||||
{
|
||||
$percent = 0;
|
||||
$style = 'bg-primary';
|
||||
$text = PhpHelper::sizeReadable($attributes[$field . '_used'] * $size_factor, null, 'bi') . ' / ' . UI::getLng('panel.unlimited');
|
||||
$text = PhpHelper::sizeReadable($attributes[$field . '_used'] * $size_factor, null, 'bi') . ' / ' . lng('panel.unlimited');
|
||||
if ((int)$attributes[$field] >= 0) {
|
||||
if (($attributes[$field] / 100) * $report_max < $attributes[$field . '_used']) {
|
||||
$style = 'bg-danger';
|
||||
|
||||
@@ -52,17 +52,17 @@ class Text
|
||||
|
||||
public static function timestamp(array $attributes): string
|
||||
{
|
||||
return (int)$attributes['data'] > 0 ? date('d.m.Y H:i', (int)$attributes['data']) : UI::getLng('panel.never');
|
||||
return (int)$attributes['data'] > 0 ? date('d.m.Y H:i', (int)$attributes['data']) : lng('panel.never');
|
||||
}
|
||||
|
||||
public static function timestampUntil(array $attributes): string
|
||||
{
|
||||
return (int)$attributes['data'] > 0 ? date('d.m.Y H:i', (int)$attributes['data']) : UI::getLng('panel.unlimited');
|
||||
return (int)$attributes['data'] > 0 ? date('d.m.Y H:i', (int)$attributes['data']) : lng('panel.unlimited');
|
||||
}
|
||||
|
||||
public static function crondesc(array $attributes): string
|
||||
{
|
||||
return UI::getLng('crondesc.' . $attributes['data']);
|
||||
return lng('crondesc.' . $attributes['data']);
|
||||
}
|
||||
|
||||
public static function shorten(array $attributes): string
|
||||
|
||||
@@ -74,7 +74,7 @@ class Listing
|
||||
// Table headings for actions
|
||||
if (isset($tabellisting['actions'])) {
|
||||
$heading['actions'] = [
|
||||
'text' => UI::getLng('panel.options'),
|
||||
'text' => lng('panel.options'),
|
||||
'class' => 'text-end',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -125,9 +125,9 @@ class FroxlorTwig extends AbstractExtension
|
||||
return Settings::Get($setting);
|
||||
}
|
||||
|
||||
public function getLang($identifier = null)
|
||||
public function getLang($identifier = null, array $arguments = [])
|
||||
{
|
||||
return UI::getLng($identifier);
|
||||
return lng($identifier, $arguments);
|
||||
}
|
||||
|
||||
public function getLink($linkopts)
|
||||
|
||||
@@ -56,13 +56,6 @@ class UI
|
||||
*/
|
||||
private static $twigbuf = [];
|
||||
|
||||
/**
|
||||
* language strigs array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $lng = [];
|
||||
|
||||
/**
|
||||
* linker class object
|
||||
*/
|
||||
@@ -212,34 +205,6 @@ class UI
|
||||
return self::$userinfo;
|
||||
}
|
||||
|
||||
public static function getLng($identifier, $context = null)
|
||||
{
|
||||
$id = explode(".", $identifier);
|
||||
if (is_null($context)) {
|
||||
$id_first = array_shift($id);
|
||||
if (!isset(self::$lng[$id_first])) {
|
||||
return null;
|
||||
}
|
||||
if (empty($id)) {
|
||||
return self::$lng[$id_first];
|
||||
} else {
|
||||
return self::getLng(implode(".", $id), self::$lng[$id_first]);
|
||||
}
|
||||
} else {
|
||||
$id_first = array_shift($id);
|
||||
if (empty($id)) {
|
||||
return isset($context[$id_first]) ? $context[$id_first] : null;
|
||||
} else {
|
||||
return self::getLng(implode(".", $id), $context[$id_first]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function setLng($lng = [])
|
||||
{
|
||||
self::$lng = $lng;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array of available themes
|
||||
*
|
||||
|
||||
@@ -256,6 +256,14 @@ return [
|
||||
'maxlength' => 9,
|
||||
'mandatory' => true
|
||||
],
|
||||
'allowed_mysqlserver' => [
|
||||
'visible' => count($mysql_servers) > 1,
|
||||
'label' => lng('customer.mysqlserver'),
|
||||
'type' => 'checkbox',
|
||||
'values' => $mysql_servers,
|
||||
'value' => [0],
|
||||
'is_array' => 1
|
||||
],
|
||||
'phpenabled' => [
|
||||
'label' => lng('admin.phpenabled') . '?',
|
||||
'type' => 'checkbox',
|
||||
|
||||
@@ -268,6 +268,14 @@ return [
|
||||
'maxlength' => 9,
|
||||
'mandatory' => true
|
||||
],
|
||||
'allowed_mysqlserver' => [
|
||||
'visible' => count($mysql_servers) > 1,
|
||||
'label' => lng('customer.mysqlserver'),
|
||||
'type' => 'checkbox',
|
||||
'values' => $mysql_servers,
|
||||
'value' => isset($result['allowed_mysqlserver']) && !empty($result['allowed_mysqlserver']) ? json_decode($result['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY) : [],
|
||||
'is_array' => 1
|
||||
],
|
||||
'phpenabled' => [
|
||||
'label' => lng('admin.phpenabled') . '?',
|
||||
'type' => 'checkbox',
|
||||
|
||||
Reference in New Issue
Block a user