From e0fcbabacf6cacf6c2dc6f0f379d05355640bee4 Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Sat, 17 May 2025 23:54:47 +0200 Subject: [PATCH] feat: Add 'wygeneruj_temat' parameter to topic_save method and update related templates for enhanced topic management --- .vscode/ftp-kr.sync.cache.json | 8 ++++---- autoload/controls/class.BackendSites.php | 2 +- autoload/factory/class.BackendSites.php | 4 +++- templates/backend_sites/topic_edit.php | 9 ++++++++- templates/backend_sites/topics.php | 9 ++++++++- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index ec9e6f9..2d8b3b2 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -65,8 +65,8 @@ "controls": { "class.BackendSites.php": { "type": "-", - "size": 2508, - "lmtime": 1746373999381, + "size": 2912, + "lmtime": 1747161357796, "modified": false }, "class.Crm.php": { @@ -121,8 +121,8 @@ "factory": { "class.BackendSites.php": { "type": "-", - "size": 2566, - "lmtime": 1746374004947, + "size": 2816, + "lmtime": 1747161382015, "modified": false }, "class.Crm.php": { diff --git a/autoload/controls/class.BackendSites.php b/autoload/controls/class.BackendSites.php index 0c89e6f..696c8c1 100644 --- a/autoload/controls/class.BackendSites.php +++ b/autoload/controls/class.BackendSites.php @@ -45,7 +45,7 @@ class BackendSites $values = \S::json_to_array( \S::get( 'values' ) ); $id = \factory\BackendSites::topic_save( - (int)$values[ 'id' ], $values[ 'strona' ], $values[ 'kategoria' ], $values[ 'kategoria_id' ], $values['link'], $values[ 'temat' ], $values[ 'data_publikacji' ], $values[ 'opublikowany' ], $values[ 'zaakceptowany' ] + (int)$values[ 'id' ], $values[ 'strona' ], $values[ 'kategoria' ], $values[ 'kategoria_id' ], $values['link'], $values[ 'temat' ], $values['wygeneruj_temat'], $values[ 'data_publikacji' ], $values[ 'opublikowany' ], $values[ 'zaakceptowany' ] ); if ( $id ) diff --git a/autoload/factory/class.BackendSites.php b/autoload/factory/class.BackendSites.php index b30704b..5875b5d 100644 --- a/autoload/factory/class.BackendSites.php +++ b/autoload/factory/class.BackendSites.php @@ -21,7 +21,7 @@ class BackendSites return $mdb -> update( 'zaplecze_tematy', [ 'zaakceptowany' => 1 ], [ 'id' => $id ] ); } - static public function topic_save( $id, $strona, $kategoria, $kategoria_id, $link, $temat, $data_publikacji, $opublikowany, $zaakceptowany ) + static public function topic_save( $id, $strona, $kategoria, $kategoria_id, $link, $temat, $wygeneruj_temat, $data_publikacji, $opublikowany, $zaakceptowany ) { global $mdb; if ( !$id ) @@ -32,6 +32,7 @@ class BackendSites 'kategoria_id' => $kategoria_id, 'link' => $link ? $link : null, 'temat' => $temat, + 'wygeneruj_temat' => $wygeneruj_temat == 'on' ? 1 : 0, 'data_publikacji' => $data_publikacji, 'opublikowany' => $opublikowany == 'on' ? 1 : 0, 'zaakceptowany' => $zaakceptowany == 'on' ? 1 : 0, @@ -45,6 +46,7 @@ class BackendSites 'kategoria_id' => $kategoria_id, 'link' => $link ? $link : null, 'temat' => $temat, + 'wygeneruj_temat' => $wygeneruj_temat == 'on' ? 1 : 0, 'data_publikacji' => $data_publikacji, 'opublikowany' => $opublikowany == 'on' ? 1 : 0, 'zaakceptowany' => $zaakceptowany == 'on' ? 1 : 0, diff --git a/templates/backend_sites/topic_edit.php b/templates/backend_sites/topic_edit.php index 9a1b6ef..b220ca6 100644 --- a/templates/backend_sites/topic_edit.php +++ b/templates/backend_sites/topic_edit.php @@ -37,6 +37,13 @@ ob_start(); 'value' => $this -> topic['temat'], 'inline' => true ] );?> + 'Wygeneruj temat', + 'name' => 'wygeneruj_temat', + 'id' => 'wygeneruj_temat', + 'checked' => $this -> topic['wygeneruj_temat'] == 1 ? true : false, + 'inline' => true +] );?> 'Data publikacji', 'name' => 'data_publikacji', @@ -65,7 +72,7 @@ $grid = new \gridEdit; $grid -> id = 'client-edit'; $grid -> gdb_opt = $gdb; $grid -> include_plugins = true; -$grid -> title = 'Edycja tematu zbiorowego'; +$grid -> title = 'Edycja tematu'; $grid -> fields = [ [ 'db' => 'id', diff --git a/templates/backend_sites/topics.php b/templates/backend_sites/topics.php index 3a27b4c..0fcb563 100644 --- a/templates/backend_sites/topics.php +++ b/templates/backend_sites/topics.php @@ -28,9 +28,16 @@ $grid -> columns_view = [ ], [ 'name' => 'Link', 'db' => 'link', + 'cut' => 50, ], [ 'name' => 'Temat', 'db' => 'temat', + ], [ + 'name' => 'Wygeneruj temat', + 'db' => 'wygeneruj_temat', + 'td' => [ 'class' => 'g-center' ], + 'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ], + 'php' => 'echo ( (int)[wygeneruj_temat] == 1 ) ? "tak" : "nie";', ], [ 'name' => 'Data publikacji', 'db' => 'data_publikacji', @@ -60,7 +67,7 @@ $grid -> columns_view = [ ]; $grid -> buttons = [ [ - 'label' => 'Dodaj temat ogólny', + 'label' => 'Dodaj temat', 'url' => '/backend_sites/topic_edit/', 'icon' => 'fa-plus-circle', 'class' => 'btn-success'