feat: implement global settings management with database defaults and admin UI configuration
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
function languages() {
|
function languages() {
|
||||||
$diller = explode(",","en,tr,ru");
|
$languages = setting("languages");
|
||||||
|
$diller = j($languages);
|
||||||
|
if(!is_array($diller)) {
|
||||||
|
$diller = explode(",","en,tr");
|
||||||
|
}
|
||||||
return $diller;
|
return $diller;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ return new class extends Migration {
|
|||||||
{
|
{
|
||||||
$settings = [
|
$settings = [
|
||||||
'project_name' => 'Citrus CMS',
|
'project_name' => 'Citrus CMS',
|
||||||
'project_name_ru' => '',
|
|
||||||
'project_number' => '',
|
'project_number' => '',
|
||||||
'company_code' => '',
|
'company_code' => '',
|
||||||
'row_count' => '20',
|
'row_count' => '20',
|
||||||
@@ -24,6 +23,7 @@ return new class extends Migration {
|
|||||||
'header_color' => 'bg-primary-dark',
|
'header_color' => 'bg-primary-dark',
|
||||||
'DevExpress_Theme' => 'dx.material.orange.light.compact.css',
|
'DevExpress_Theme' => 'dx.material.orange.light.compact.css',
|
||||||
'pdf_template_path' => 'default',
|
'pdf_template_path' => 'default',
|
||||||
|
'languages' => json_encode(['en', 'tr']),
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($settings as $key => $value) {
|
foreach ($settings as $key => $value) {
|
||||||
@@ -39,6 +39,27 @@ return new class extends Migration {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$translations = [
|
||||||
|
['icerik' => 'en', 'ceviri' => 'English', 'dil' => 'en'],
|
||||||
|
['icerik' => 'tr', 'ceviri' => 'Türkçe', 'dil' => 'en'],
|
||||||
|
['icerik' => 'en', 'ceviri' => 'English', 'dil' => 'tr'],
|
||||||
|
['icerik' => 'tr', 'ceviri' => 'Türkçe', 'dil' => 'tr'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($translations as $trans) {
|
||||||
|
$exists = DB::table('translate')
|
||||||
|
->where('icerik', $trans['icerik'])
|
||||||
|
->where('dil', $trans['dil'])
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if (!$exists) {
|
||||||
|
DB::table('translate')->insert(array_merge($trans, [
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,6 +81,7 @@ return new class extends Migration {
|
|||||||
'DevExpress_Theme',
|
'DevExpress_Theme',
|
||||||
'pdf_template_path',
|
'pdf_template_path',
|
||||||
'handover_control_count',
|
'handover_control_count',
|
||||||
|
'languages',
|
||||||
];
|
];
|
||||||
|
|
||||||
DB::table('settings')->whereIn('title', $keys)->delete();
|
DB::table('settings')->whereIn('title', $keys)->delete();
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ if (getisset("update")) {
|
|||||||
@csrf
|
@csrf
|
||||||
{{e2("Project Name")}}:
|
{{e2("Project Name")}}:
|
||||||
<input type="text" name="project_name" value="{{setting('project_name')}}" class="form-control" id="">
|
<input type="text" name="project_name" value="{{setting('project_name')}}" class="form-control" id="">
|
||||||
{{e2("Project Russian Name ")}}:
|
|
||||||
<input type="text" name="project_name_ru" value="{{setting('project_name_ru')}}" class="form-control" id="">
|
|
||||||
{{e2("Project Number")}}:
|
{{e2("Project Number")}}:
|
||||||
<input type="text" name="project_number" value="{{setting('project_number')}}" class="form-control" id="">
|
<input type="text" name="project_number" value="{{setting('project_number')}}" class="form-control" id="">
|
||||||
{{e2("Company Code")}}:
|
{{e2("Company Code")}}:
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
if(getisset("update")) {
|
if (getisset("update")) {
|
||||||
foreach($_POST AS $key => $value) {
|
foreach ($_POST as $key => $value) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
$value = json_encode($value, JSON_UNESCAPED_UNICODE);
|
||||||
|
}
|
||||||
firstOrUpdate([
|
firstOrUpdate([
|
||||||
'title' => $key,
|
'title' => $key,
|
||||||
'html' => $value
|
'html' => $value
|
||||||
],"settings",[
|
], "settings", [
|
||||||
'title' => $key
|
'title' => $key
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -13,33 +15,27 @@ if(getisset("update")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$variables = [
|
$variables = [
|
||||||
'Document Procedure Type' => 'document_procedure_type',
|
'Languages' => 'languages',
|
||||||
'Publisher' => 'publisher',
|
|
||||||
'RFI Status' => 'rfi-status',
|
|
||||||
'Erection Type' => 'erection_type',
|
|
||||||
'Erection Materials Name' => 'erection_materials_name',
|
|
||||||
'NCR Current Types' => 'ncr_types',
|
|
||||||
'NCR Current Status' => 'ncr_current_status',
|
|
||||||
'Unit (KG-MM)' => 'unit_kgmetc',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<form action="?t={{get("t")}}&update" method="post">
|
<form action="?t={{get("t")}}&update" method="post">
|
||||||
@csrf
|
@csrf
|
||||||
@foreach($variables AS $name => $key)
|
@foreach($variables as $name => $key)
|
||||||
{{e2($name)}}:
|
{{e2($name)}}:
|
||||||
<?php $selectedValues = j(setting($key)); ?>
|
<?php $selectedValues = j(setting($key)); ?>
|
||||||
<select name="{{$key}}[]" multiple id="" class="form-control select2">
|
<select name="{{$key}}[]" multiple id="" class="form-control select2">
|
||||||
<?php
|
<?php
|
||||||
if(is_array($selectedValues)) {
|
if (is_array($selectedValues)) {
|
||||||
foreach($selectedValues AS $d) {
|
foreach ($selectedValues as $d) {
|
||||||
?>
|
?>
|
||||||
<option value="{{$d}}" selected>{{$d}}</option>
|
<option value="{{$d}}" selected>{{$d}}</option>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
$app = require_once 'bootstrap/app.php';
|
||||||
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||||
|
$kernel->bootstrap();
|
||||||
|
|
||||||
|
print_r(languages());
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
$app = require_once 'bootstrap/app.php';
|
||||||
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||||
|
$kernel->bootstrap();
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
$langs = ['en', 'tr'];
|
||||||
|
foreach ($langs as $lang) {
|
||||||
|
echo "Translations for $lang:\n";
|
||||||
|
$trans = DB::table('translate')->where('dil', $lang)->get();
|
||||||
|
foreach ($trans as $t) {
|
||||||
|
echo " - {$t->icerik} => {$t->ceviri}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user