Skip to content

Commit

Permalink
Merge pull request #18 from Smaragda2/Articles
Browse files Browse the repository at this point in the history
Articles
  • Loading branch information
Smaragda2 authored Aug 30, 2023
2 parents 56053a1 + 1589e57 commit 18bec26
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 57 deletions.
12 changes: 6 additions & 6 deletions admin/articles/allArticles.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container">
<div class="container" style="width:100%;">
<h2><b>Όλα τα Άρθρα</b></h2>

<?php
Expand All @@ -16,20 +16,20 @@
print<<<END
<div class="row" style="width:95%">
<div class="col">
<label for="title">*Τίτλος</label>
<label for="title">Τίτλος</label>
<input type="text" id="title" name="title" value="$articleTitle" readonly/>
</div>
</div>
<div class="row" style="width:95%">
<div class="col">
<label for="smallDescription">*Περιγραφή Άρθρου</label>
<textarea type="smallDescription" id="smallDescription" name="smallDescription" value="$smallDescription" rows="3" readonly"> </textarea>
<label for="smallDescription">Περιγραφή Άρθρου</label>
<textarea type="smallDescription" id="smallDescription" name="smallDescription" rows="3" readonly">$smallDescription</textarea>
</div>
</div>
<div class="row" style="width:95%">
<div class="col">
<label for="body">*Κείμενο Άρθρου</label>
<textarea type="body" id="body" name="body" value="$body" rows="7" readonly> </textarea>
<label for="body">Κείμενο Άρθρου</label>
<textarea type="body" id="body" name="body" rows="7" readonly>$body</textarea>
</div>
</div>
<br>
Expand Down
6 changes: 3 additions & 3 deletions admin/articles/deleteArticle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container">
<div class="container" style="width:100%;">
<h2><b>Διαγραφή Άρθρων</b></h2>

<?php
Expand Down Expand Up @@ -29,13 +29,13 @@
<div class="row" style="width:95%">
<div class="col">
<label for="smallDescription">*Περιγραφή Άρθρου</label>
<textarea type="smallDescription" id="smallDescription" name="smallDescription" value="$smallDescription" rows="3" readonly"> </textarea>
<textarea type="smallDescription" id="smallDescription" name="smallDescription" value="$smallDescription" rows="3" readonly">$smallDescription</textarea>
</div>
</div>
<div class="row" style="width:95%">
<div class="col">
<label for="body">*Κείμενο Άρθρου</label>
<textarea type="body" id="body" name="body" value="$body" rows="7" readonly> </textarea>
<textarea type="body" id="body" name="body" value="$body" rows="7" readonly>$body</textarea>
</div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions admin/articles/handleArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
if(isset($_POST['deleteSubmit'])){
$id = $_POST['id'];

$deleteArticle = "Update Product set isDeleted=true where id = ?";
$stmt = $mysqli->prepare($deleteArticle );
$stmt->bind_param('i', $id);
$deleteArticle = "Update Article set isDeleted=true where id = ".$id;
$stmt = $mysqli->prepare($deleteArticle);
$status = $stmt->execute();

if($status === false) {
Expand Down
26 changes: 15 additions & 11 deletions admin/articles/newArticle.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>

function CheckRequired(){
var allEmpty = false;
var allFilled = false;
var fieldExceedsMaxValue = false;

var title = $("#title").val();
Expand All @@ -14,24 +14,27 @@ function CheckRequired(){

var errorsMsg = "";

if(empty(title) && empty(description) && empty(body)){
allEmpty = true;
if(title?.length == 0 || description?.length == 0 || body?.length == 0){
allFilled = false;
}else{
allEmpty = false;
allFilled = true;
}


if (strlen(title) > titleMaxChars) {
if (title?.length > titleMaxChars) {
errorsMsg = "Ο Τίτλος δεν μπορεί να ξεπερνάει τους " + titleMaxChars + " χαρακτήρες!\n";
fieldExceedsMaxValue = true;
}
if (strlen(description) > descriptionMaxChars) {
if (description?.length > descriptionMaxChars) {
errorsMsg += "Η Περιγραφή δεν μπορεί να ξεπερνάει τους " + descriptionMaxChars + " χαρακτήρες!\n";
fieldExceedsMaxValue = true;
}
if (strlen(body) > bodyMaxChars) {
if (body?.length > bodyMaxChars) {
errorsMsg += "Ο Κείμενο του Άρθρου δεν μπορεί να ξεπερνάει τους " + bodyMaxChars + " χαρακτήρες!\n";
fieldExceedsMaxValue = true;
}

if(allEmpty){
if(!allFilled){
document.getElementById("errors").innerText = "Παρακαλώ συμπληρώστε όλα τα πεδία με αστερίσκο (*).";
$("#addSubmit").attr('disabled', true);
$("#addSubmit").attr('style','background-color:gray');
Expand All @@ -48,8 +51,9 @@ function CheckRequired(){

</script>

<div class="container">
<div class="container" style="width:100%;">
<h2><b>Προσθήκη Άρθρου</b></h2>
<h4 style="color: red;"><b>*Τα Emojis δεν υποστηρίζονται!</b></h4>
<?php
print<<<END
<form action="?p=handleArticles" method="POST" enctype="multipart/form-data" class="needs-validation" style="width:100%" onload="CheckRequired();" novalidate>
Expand All @@ -62,13 +66,13 @@ function CheckRequired(){
<div class="row" style="width:95%">
<div class="col">
<label for="smallDescription">*Περιγραφή Άρθρου</label>
<textarea type="smallDescription" id="smallDescription" name="smallDescription" value="Τι θα δει ο χρήστης πριν ανοίξει το Άρθρο" rows="3" onkeyup="CheckRequired();"> </textarea>
<textarea type="smallDescription" id="smallDescription" name="smallDescription" value="Τι θα δει ο χρήστης πριν ανοίξει το Άρθρο" rows="3" onkeyup="CheckRequired();"></textarea>
</div>
</div>
<div class="row" style="width:95%">
<div class="col">
<label for="body">*Κείμενο Άρθρου</label>
<textarea type="body" id="body" name="body" value="Το κείμενο του άρθρου" rows="7" onkeyup="CheckRequired();"> </textarea>
<textarea type="body" id="body" name="body" value="Το κείμενο του άρθρου" rows="7" onkeyup="CheckRequired();"></textarea>
</div>
</div>
Expand Down
13 changes: 7 additions & 6 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,21 @@
<li><a href="?p=createAppointment">Δημιουργία Ραντεβού</a></li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-gear"> Ρυθμίσεις</i></a>
<ul>
<li><a href="?p=TimeslotSettings">Ημέρες και Ώρες Ραντεβού</a></li>
</ul>
</li>
<li>
<a href="#">Άρθρα</a>
<ul>
<li><a href="?p=Articles">Όλα τα Άρθρα</a></li>
<li><a href="?p=newArticle">Προσθήκη Νέου Άρθρου</a></li>
<li><hr></li>
<li><a href="?p=deleteArticle">Διαγραφή Άρθρου</a></li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-gear"> Ρυθμίσεις</i></a>
<ul>
<li><a href="?p=TimeslotSettings">Ημέρες και Ώρες Ραντεβού</a></li>
</ul>
</li>
<li>
<?php
if($_SESSION['admin'] == 'ok'){
Expand Down
24 changes: 13 additions & 11 deletions articles/article.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?php
$mysqli = $_SESSION['dbconnect'];
$getArticles = "SELECT * FROM Article where id=?";
$getArticles = "SELECT id, title, body FROM Article where id=".$_POST['id'];
$stmt = $mysqli->prepare($getArticles);
$stmt->bind_param("i", $_POST['id']);
$stmt->execute();
$results = $stmt->get_result();

$row = $results->fetch_row();

$id = $row['id'];
$articleTitle = $row['title'];
$body = $row['body'];
?>
<div class="Container">
<div class="jumbotron row" style="width:100%;">
<p class="articlesTitle"><?php $articleTitle ?></p>
<p class="articleBody"><?php $body ?></p>
$id = $row[0];
$articleTitle = $row[1];
$body = $row[2];

print<<<END
<div class="Container" style="width:100%;">
<p style="width: 100%;"><b>Τίτλος Άρθρου:</b> $articleTitle</p>
<div class="jumbotron" style="width:100%;">
<p class="articleBody col">$body</p>
</div>
</div>
</div>
END;
?>
29 changes: 12 additions & 17 deletions articles/articles.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="Container">
<div class="Container" style="width:100%;">
<?php
$mysqli = $_SESSION['dbconnect'];
$getArticles = "SELECT * FROM Article where isDeleted=false";
Expand All @@ -11,24 +11,19 @@
$articleTitle = $row['title'];
$smallDescription = $row['smallDescription'];

print<<<END
<div class="jumbotron row" style="width:100%;">
<p class="articlesTitle">$articleTitle</p>
<p class="articleDescription">$smallDescription</p>
<form action="?p=Article" method="POST" enctype="multipart/form-data" class="needs-validation" style="width:100%" novalidate>
<input type="hidden" id="id" name="id" value="$id"/>
<input type="submit" name="Submit" value="Διάβασε το Άρθρο"/>
</form>
</div>
END;
}

if ($result->num_rows == 0) {
print<<<END
<div class="jumbotron row" style="width:100%;">
<p>Δεν βρέθηκε κάποιο Άρθρο.</p>
<p style="width: 100%;"><b>Τίτλος Άρθρου:</b> $articleTitle</p>
<div class="jumbotron " style="width:100%;">
<div class="col">$smallDescription</div>
<br>
<form action="?p=Article" method="POST" enctype="multipart/form-data" class="needs-validation" style="width:100%" novalidate>
<input type="hidden" id="id" name="id" value="$id"/>
<input type="submit" name="Submit" value="Διάβασε το Άρθρο"/>
</form>
</div>
END;
<hr>
<br>
END;
}
?>
</div>
6 changes: 6 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ select, textarea {
padding: 1em 0 1em 2em;
}

/* Articles */
.articleBody {
white-space: pre-wrap;
text-align: left;
}

/* Container */

.container {
Expand Down

0 comments on commit 18bec26

Please sign in to comment.