]> gitweb.morketsmerke.org Git - bugtrack.git/commitdiff
Dodano do ustawień opcję pozwalającą na wybór domyślnego motywy serwisu - BT #98
authorxf0r3m <jakubstasinski@protonmail.com>
Fri, 11 Aug 2023 08:27:02 +0000 (10:27 +0200)
committerxf0r3m <jakubstasinski@protonmail.com>
Fri, 11 Aug 2023 08:27:02 +0000 (10:27 +0200)
forms/theme.php [new file with mode: 0644]
index.php
modules/savetheme.php [new file with mode: 0644]
settings.php

diff --git a/forms/theme.php b/forms/theme.php
new file mode 100644 (file)
index 0000000..e4c0192
--- /dev/null
@@ -0,0 +1,32 @@
+<div class="card card-spacer">
+  <div class="card-body">
+   <h5 class="card-title">Motyw serwisu:</h5>
+<form action="?p=settings" method="post">
+  <input type="hidden" value="1" name="siteId">
+    <div class="mb-3">
+      <select class="form-select" name="siteTheme">
+        <?php
+        $themeTbl = array("dark" => "Ciemny", "light" => "Jasny");
+        $tableName = 'site';
+        $columnScheme = "theme";
+        $whereValue = "id = 1";
+        $result4 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        if ( mysqli_num_rows($result4) > 0 ) {
+          $row1 = mysqli_fetch_row($result4);
+          $siteTheme =  $row1[0];
+          foreach ($themeTbl as $key => $value) {
+            if ( $key == $siteTheme ) {
+              echo "<option value=\"" . $siteTheme . "\" selected>" . $value . "</option>";
+              continue;
+            } else {
+              echo "<option value=\"" . $key . "\">" . $value . "</option>";
+            }
+          }
+        }
+        ?>
+      </select>
+    </div>
+      <button type="submit" class="btn btn-primary">Zmień motyw</button>
+</form>
+</div>
+</div>
index ac1ff68cf339116ba899944239dc3ef5e626e3fd..2c889bc9db4eb8fd0503258ec311b7ffebaac799 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -2,14 +2,14 @@
 <?php include('db_conf.php'); ?>
 <?php
   $tableName = 'site';
-  $columnScheme = 'slogan';
+  $columnScheme = 'slogan,theme';
   $whereValue = "id = 1";
   $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
   $row = mysqli_fetch_row($result);
 ?>
 
 <!doctype html>
-<html lang="pl" data-bs-theme="dark">
+<html lang="pl" <?php echo "data-bs-theme=\"" . $row[1] . "\"" ?>>
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
diff --git a/modules/savetheme.php b/modules/savetheme.php
new file mode 100644 (file)
index 0000000..0963db4
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+  $tableName = 'site';
+  $setValues = "theme ='" . mysqli_real_escape_string($connection, $_POST["siteTheme"]) . "'";
+  $whereValue = "id = 1";
+  $result = dbUpdate($connection, $tableName, $setValues, $whereValue);
+  if ( $result == 'true ' ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Domyślny motyw serwisu został zmieniony</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Domyślny motyw nie został zmieniony</div>";
+  }
+?>
index 4053fde2f371f6038acf4c4bbb85bab2d3dc2d19..909242cffbf90b4ae214bbdb676fb7a2264b992b 100644 (file)
@@ -20,6 +20,7 @@
       if ( isset($_POST["editCLFormCode"]) ) { include('modules/editclform.php'); }
       if ( isset($_POST["dictionary"]) ) { include('modules/newdictionary.php'); }
       if ( isset($_POST["editDictionary"]) ) { include('modules/editdictionary.php'); }
+      if ( isset($_POST["siteTheme"]) ) { include('modules/savetheme.php'); }
 
     }
     $whereValue="username = '" . $_SESSION["username"] . "';";
@@ -46,8 +47,9 @@
       echo "<div class=\"card card-spacer\"><div class=\"card-header\"><h4>Formularz listy zmian:</h4></div><div class=\"card-body\">";
       include('modules/listclforms.php');
       echo "</div></div>";
-      echo "<div class=\"card card-spacer\"><div class=\"card-header\"><h4>Strona główna:</h4></div><div class=\"card-body\">";
+      echo "<div class=\"card card-spacer\"><div class=\"card-header\"><h4>Wygląd serwisu:</h4></div><div class=\"card-body\">";
       include('forms/slogan.php');
+      include('forms/theme.php');
       echo "</div></div>";
 
     }