]> gitweb.morketsmerke.org Git - libmm.git/commitdiff
Dalszy rozwój. Dodano stronę książki, zmioniono notatki na magazyny. Usunięto posty...
authorxf0r3m <jakubstasinski@protonmail.com>
Fri, 3 Nov 2023 13:16:49 +0000 (14:16 +0100)
committerxf0r3m <jakubstasinski@protonmail.com>
Fri, 3 Nov 2023 13:16:49 +0000 (14:16 +0100)
index.php
install.sql
modules/addcategory.php [moved from modules/addcategorie.php with 85% similarity]
modules/book.php [new file with mode: 0644]
modules/books.php
modules/delete.php
style.css

index fbc6acda4db88cc9e93c4243101c18e4a461c0b8..420057599dc3896bfcd194a382df57e72f2c89c5 100644 (file)
--- a/index.php
+++ b/index.php
@@ -21,7 +21,7 @@
           <li class="main-menu-element"><a href="?p=search">Szukaj</a></li>
           <li class="main-menu-element"><a href="?p=books&t=0">Książki</a></li>
           <li class="main-menu-element"><a href="?p=books&t=1">E-booki</a><li>
-          <li class="main-menu-element"><a href="?p=notes">Notatki</a></li>
+          <li class="main-menu-element"><a href="?p=magazines">Czasopisma</a></li>
           <?php
             if ( session_status() != 2 ) { session_start(); }
             if ( isset($_SESSION['username']) ) {
           <!--side-menu-->
           <label for="menu-generic"><strong>Ogólne:</strong></label>
           <ul id="menu-generic" class="ul-menu">
-            <li><a href="?p=posts">Aktualności</a><li>
             <li><a href="?p=lastadded">Ostatnio dodane</a></li>
           </ul>
-          <p>&nbsp;</p>
+          <br />
+          <?php 
+            if ( ( isset($_GET['p'])) && ( $_GET['p'] == "books" ) ) {
+          ?>
+            <label for="order-by"><strong>Uporządkuj: </strong></label>
+            <ul id="order-by" class="ul-menu">
+              <li><a href="?p=books&o=title">Tytułami</a></li>
+              <li><a href="?p=books&o=author">Autorami</a></li>
+              <li><a href="?p=books&o=category">Kategoriami</a></li>
+              <li><a href="?p=books&o=pubdate">Rokiem wydania</a></li>
+            </ul>
+            <br />
+            <label for="sort"><strong>Sortuj: </strong></label>
+            <ul id="sort" class="ul-menu">
+              <?php
+                if ( isset($_GET['o']) ) {
+              ?>
+                <li><a href="?p=books&o=<?php echo $_GET['o']; ?>&s=asc">Rosnąco</a>
+                <li><a href="?p=books&o=<?php echo $_GET['o']; ?>&s=desc">Malejąco</a>
+              <?php
+                } else {
+              ?>
+               <li><a href="?p=books&o=title&s=asc">Rosnąco</a>
+               <li><a href="?p=books&o=title&s=desc">Malejąco</a>
+            </ul>
           <?php
+              }
+            }
             if ( session_status() != 2 ) { session_start(); }
             if ( isset($_SESSION['username']) ) {
               echo "<label for=\"admin-panel\"><strong>Panel administracyjny:</strong></label>";
               echo "<ul class=\"ul-menu\" id=\"admin-panel\">";
               echo "<li class=\"main-menu-element\"><a href=\"?p=addbook\">Dodaj książkę</a></li>";
-              echo "<li class=\"main-menu-element\"><a href=\"?p=addnote\">Dodaj notatkę</a></li>";
-              echo "<li class=\"main-menu-element\"><a href=\"?p=addcategorie\">Dodaj kategorię</a></li>";
-              echo "<li class=\"main-menu-element\"><a href=\"?p=addpost\">Dodaj post</a></li>";
+              echo "<li class=\"main-menu-element\"><a href=\"?p=addmagazine\">Dodaj czasopismo</a></li>";
+              echo "<li class=\"main-menu-element\"><a href=\"?p=addcategory\">Dodaj kategorię</a></li>";
               echo "</ul>";
             }
           ?>
@@ -60,8 +84,8 @@
             switch ($_GET['p']) {
               case 'login':
                 include('modules/login.php'); break;
-              case 'addcategorie':
-                include('modules/addcategorie.php'); break;
+              case 'addcategory':
+                include('modules/addcategory.php'); break;
               case 'addbook':
                 include('modules/addbook.php'); break;
               case 'books':
@@ -70,6 +94,8 @@
                 include('modules/editbook.php'); break;
               case 'delete':
                 include('modules/delete.php'); break;
+              case 'book':
+                include('modules/book.php'); break;
               default:
                 include('modules/frontpage.php');
             }
index a966355744f4016480a8ec186fb406e7d56a09b1..231f4998eebdf3a5024ae905f62f3a68608ccb4e 100644 (file)
@@ -25,10 +25,10 @@ CREATE TABLE books (
   description text
 );
 
-CREATE TABLE notes (
+CREATE TABLE magazines (
   id int AUTO_INCREMENT PRIMARY KEY,
   title text,
-  author text,
+  pubnumber text,
   source text,
   adnotes text,
   description text
similarity index 85%
rename from modules/addcategorie.php
rename to modules/addcategory.php
index ede7a182e047aa2a53bbb74bf61cc4cbb7d45d33..0f9ffec54d30bda2f96a1730220ecf3c734b476f 100644 (file)
@@ -1,21 +1,21 @@
 <!-- PHP CODE -->
 <?php
-  if ( isset($_POST['categorie']) ) {
+  if ( isset($_POST['category']) ) {
     $tableName = 'categories';
     $columnScheme = 'name';
-    $setValues = "'" . mysqli_real_escape_string($connection, $_POST['categorie']) . "'";
+    $setValues = "'" . mysqli_real_escape_string($connection, $_POST['category']) . "'";
     $addCategorieResult = dbAdd($connection, $tableName, $columnScheme, $setValues);
     if ( mysqliResult($connection, $addCategorieResult) ) {
-      echo "<h3>Dodano kategorię: " . $_POST['categorie'] . "</h3>";
+      echo "<h3>Dodano kategorię: " . $_POST['category'] . "</h3>";
     } else {
       echo "<h3 style=\"color: red;\">Nie dodano kategorii.</h3>";
     }
   }
 ?>
 <!-- HTML FORM -->
-<form action="?p=addcategorie" method="post">
+<form action="?p=addcategory" method="post">
   <label for="catname">Nazwa kategorii:</label><br />
-  <input type="text" name="categorie" /><br /><br />
+  <input type="text" name="category" /><br /><br />
   <button type="submit">Dodaj kategorię</button>
 </form>
 <hr />
diff --git a/modules/book.php b/modules/book.php
new file mode 100644 (file)
index 0000000..5239b2e
--- /dev/null
@@ -0,0 +1,74 @@
+<!-- PHP CODE -->
+<?php
+  $tableName = 'books';
+  $columnScheme = "*";
+  $whereValue = 'id = ' . intval($_GET['id']);
+  $bookQueryResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqliResult($connection, $bookQueryResult) ) {
+    $row = mysqli_fetch_row($bookQueryResult);
+  } else {
+    echo "<h3>Nie można pobrać informacji o obiekcie</h3>";
+  }
+?>
+<!-- HTML FORM -->
+<h3><?php echo $row[3]; ?></h3>
+<h4 style="color: gray;"><em>
+<a href="?p=books&a=<?php echo urlencode($row[4]); ?>" style="color: inherit;"><?php echo $row[4]; ?></a>
+</em></h4>
+<div style="width: 340px; height:250px; float: left">
+<p><strong>Rodzaj:</strong>
+  <?php
+    if ( $row[1] == 1 ) {
+      echo "<a href=\"?p=books&t=" . $row[1] . "\">";
+      echo "E-book";
+      echo "</a>";
+    }
+    else { 
+      echo "<a href=\"?p=books&t=" . $row[1] . "\">";
+      echo "Książka papierowa";
+      echo "</a>";
+    }
+  ?>
+</p>
+<p><strong>Wydawnictwo:</strong>
+<a href="?p=books&pub=<?php echo urlencode($row[5]); ?>">
+<?php echo $row[5]; ?>
+</a>
+</p>
+<p><strong>Wydanie:</strong> <?php echo $row[6]; ?></p>
+<p><strong>Rok wydania:</strong>
+<a href="?p=books&d=<?php echo urlencode($row[7]); ?>">
+<?php echo $row[7]; ?>
+</a>
+</p>
+<?php
+  $tableName = 'categories';
+  $columnScheme = 'name';
+  $whereValue = 'id = ' . intval($row[8]);
+  $catQueryResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqliResult($connection, $catQueryResult) ) {
+    $category = getFieldValue($catQueryResult);
+  }
+?>
+<p><strong>Kategoria:</strong>
+<a href="?p=books&c=<?php echo urlencode($row[8]) ?>">
+<?php echo $category; ?>
+</a>
+</p>
+<p><strong>ISBN:</strong> <?php echo $row[9]; ?></p>
+</div>
+<div style="width: 340px; float: left;">
+<img class="book-cover" src="<?php echo $row[2]; ?>" hspace=10 vspace=10 alt="<?php basename($row[2]); ?>"/>
+</div>
+<p><strong>Adnotacje:</strong><br />
+<?php
+  if ( session_status() != 2 ) { session_start();}
+  if ( isset($_SESSION['username']) ) {
+         echo nl2br($row[10]);
+  } else {
+    echo "Brak.";
+  }
+?>
+</p>
+<p><strong>Opis:</strong><br /> <?php echo nl2br($row[11]); ?>
+</p>
index 25a20a9138a6c79b1886da0e0ab216ce5633370a..d946b5960154076ef1f5ea925750d009dba5ffde 100644 (file)
@@ -3,15 +3,38 @@
   if ( session_status() != 2 ) { session_start(); }
   $tableName = "books";
   $columnScheme = "id,title,author";
-  $whereValue = "type = " . intval($_GET['t']);
+  if ( isset($_GET['t']) ) {
+    $whereValue = "type = " . intval($_GET['t']);
+  } else if ( isset($_GET['pub']) ) {
+    $whereValue = "publisher = '" . $_GET['pub'] . "'";
+  } else if ( isset($_GET['d']) ) {
+    $whereValue = "pubdate = " . intval($_GET['d']);
+  } else if ( isset($_GET['c']) ) {
+    $whereValue = "category = " . intval($_GET['c']);
+  } else if ( isset($_GET['a']) ) {
+    $whereValue = "author = '" . urldecode($_GET['a']) . "'";
+  }
   $booksQueryResult = dbQuery($connection, $tableName, $columnScheme, $whereValue)
 ?>
 <!-- HTML FORM -->
 <?php
   if ( isset($_GET['t']) && ( $_GET['t'] == 1 ) ) {
     echo "<h3>E-Booki:</h3><br />";
-  } else {
+  } else if ( isset($_GET['t']) && ( $_GET['t'] == 0 ) ) {
     echo "<h3>Książki papierowe:</h3><br />";
+  } else if ( isset($_GET['pub']) ) {
+    echo "<h3>Wydawca: " . $_GET['pub'] . "</h3>";
+  } else if ( isset($_GET['d']) ) {
+    echo "<h3>Rok wydania: " . $_GET['d'] . "</h3>";
+  } else if ( isset($_GET['c']) ) {
+    $tableName = 'categories';
+    $columnScheme = 'name';
+    $whereValue = "id = " . intval($_GET['c']);
+    $booksCatResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $category = getFieldValue($booksCatResult);
+    echo "<h3>Kategoria: " . $category . "</h3>";
+  } else if ( isset($_GET['a']) ) {
+         echo "<h3>Autor: " . urldecode($_GET['a']) . "</h3>";
   }
   if ( mysqliResult($connection, $booksQueryResult) ) {
   echo "<table>";
index 41ee9fc945ceae67bb06d5a682661c3a329713ae..c8935d57a6da78486650ba950d262730b29e68fd 100644 (file)
     $tableName = $_GET['table'];
     if ( $tableName == "books" ) {
       $columnScheme = "title,type";
-    } else {
+    } else if ( $tableName == "magazines" ) {
       $columnScheme = 'title';
+    } else {
+      $columnScheme = 'name';
     }
     $id = intval($_GET['id']);
     $whereValue = 'id = ' . $id;
@@ -38,6 +40,8 @@
 <?php
       if ( $tableName == "books" ) {
         echo "<a href=\"?p=" . $tableName . "&t=" . $row[1] . "\" style=\"float: left; margin-left: 10px;\"><button>Nie</button></a>";
+      } else if ( $tableName == "categories" ) {
+        echo "<a href=\"?p=addcategory\" style=\"float: left; margin-left: 10px;\"><button>Nie</button></a>";
       } else {
         echo "<a href=\"?p=" . $tableName . "\" style=\"float: left; margin-left: 10px;\"><button>Nie</button></a>";
       }
index ffba53b6353d43ed39cb490aba9b66ed0767e91b..163e28c77b2dd1165328999e112e5e7dc9bedce1 100644 (file)
--- a/style.css
+++ b/style.css
@@ -56,3 +56,10 @@ button {
 .addbook-input {
   width: 400px;
 }
+
+.book-cover {
+  display: block;
+  width: 200px;
+  margin-left: auto;
+  margin-right: auto;
+}