feat: implement global settings management with database defaults and admin UI configuration
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
function languages() {
|
||||
$diller = explode(",","en,tr,ru");
|
||||
$languages = setting("languages");
|
||||
$diller = j($languages);
|
||||
if(!is_array($diller)) {
|
||||
$diller = explode(",","en,tr");
|
||||
}
|
||||
return $diller;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ return new class extends Migration {
|
||||
{
|
||||
$settings = [
|
||||
'project_name' => 'Citrus CMS',
|
||||
'project_name_ru' => '',
|
||||
'project_number' => '',
|
||||
'company_code' => '',
|
||||
'row_count' => '20',
|
||||
@@ -24,6 +23,7 @@ return new class extends Migration {
|
||||
'header_color' => 'bg-primary-dark',
|
||||
'DevExpress_Theme' => 'dx.material.orange.light.compact.css',
|
||||
'pdf_template_path' => 'default',
|
||||
'languages' => json_encode(['en', 'tr']),
|
||||
];
|
||||
|
||||
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',
|
||||
'pdf_template_path',
|
||||
'handover_control_count',
|
||||
'languages',
|
||||
];
|
||||
|
||||
DB::table('settings')->whereIn('title', $keys)->delete();
|
||||
|
||||
@@ -31,8 +31,6 @@ if (getisset("update")) {
|
||||
@csrf
|
||||
{{e2("Project Name")}}:
|
||||
<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")}}:
|
||||
<input type="text" name="project_number" value="{{setting('project_number')}}" class="form-control" id="">
|
||||
{{e2("Company Code")}}:
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
|
||||
<?php
|
||||
if(getisset("update")) {
|
||||
foreach($_POST AS $key => $value) {
|
||||
if (getisset("update")) {
|
||||
foreach ($_POST as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$value = json_encode($value, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
firstOrUpdate([
|
||||
'title' => $key,
|
||||
'html' => $value
|
||||
],"settings",[
|
||||
], "settings", [
|
||||
'title' => $key
|
||||
]);
|
||||
}
|
||||
@@ -13,26 +15,20 @@ if(getisset("update")) {
|
||||
}
|
||||
|
||||
$variables = [
|
||||
'Document Procedure Type' => 'document_procedure_type',
|
||||
'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',
|
||||
'Languages' => 'languages',
|
||||
|
||||
];
|
||||
|
||||
?>
|
||||
<form action="?t={{get("t")}}&update" method="post">
|
||||
@csrf
|
||||
@foreach($variables AS $name => $key)
|
||||
@foreach($variables as $name => $key)
|
||||
{{e2($name)}}:
|
||||
<?php $selectedValues = j(setting($key)); ?>
|
||||
<select name="{{$key}}[]" multiple id="" class="form-control select2">
|
||||
<?php
|
||||
if(is_array($selectedValues)) {
|
||||
foreach($selectedValues AS $d) {
|
||||
if (is_array($selectedValues)) {
|
||||
foreach ($selectedValues as $d) {
|
||||
?>
|
||||
<option value="{{$d}}" selected>{{$d}}</option>
|
||||
<?php
|
||||
|
||||
@@ -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