consolidate all repos to one for archive
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<h2>Dodaj sliko</h2>
|
||||
<form action="?controller=ads&action=addImg&id=<?php echo $ad->id; ?>" method="POST" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Slika</label>
|
||||
<input class="form-control" type="file" name="image" required>
|
||||
</div>
|
||||
<input type="submit" name="submit" value="Dodaj sliko" class="btn btn-primary"/>
|
||||
</form>
|
@@ -0,0 +1,29 @@
|
||||
<h2>Objavi oglas</h2>
|
||||
<form action="?controller=ads&action=store" method="POST" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Naslov</label>
|
||||
<input type="text" class="form-control" name="title" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Vsebina</label>
|
||||
<textarea name="description" class="form-control" rows="3" required></textarea>
|
||||
</div>
|
||||
|
||||
<?php foreach($categorys as $category) : ?>
|
||||
<div class="form-check">
|
||||
|
||||
<input name="categorys[]" value="<?php echo $category->id; ?>" class="form-check-input" type="checkbox">
|
||||
<label class="form-check-label">
|
||||
<?php echo $category->title; ?>
|
||||
</label>
|
||||
|
||||
</div>
|
||||
<?php endforeach?>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Slika</label>
|
||||
<input class="form-control" type="file" name="image" required>
|
||||
</div>
|
||||
|
||||
<input class="btn btn-primary" type="submit" name="submit" value="Objavi" /> <br />
|
||||
</form>
|
@@ -0,0 +1,65 @@
|
||||
<h2>Uredi oglas</h2>
|
||||
<form action="?controller=ads&action=update" method="POST" enctype="multipart/form-data">
|
||||
<!-- ID od oglasa, ki ga želimo urediti, pošljemo v POST s pomočjo avtomatsko izpolnjenega skritega vnosnega polja <input type='hidden'>-->
|
||||
<input type="hidden" name="id" value="<?php echo $ad->id; ?>" />
|
||||
|
||||
<label>Naslov</label>
|
||||
<input class="form-control" type="text" name="title" value="<?php echo $ad->title; ?>" /> <br />
|
||||
|
||||
<label>Vsebina</label>
|
||||
<textarea class="form-control" name="description" rows="10" cols="50"><?php echo $ad->description; ?></textarea>
|
||||
<br/>
|
||||
<input class="btn btn-primary" type="submit" name="submit" value="Shrani" /> <br />
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Content</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="comments">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
$(document).ready(async function() {
|
||||
await loadComments();
|
||||
$(".delete_comment_btn").click(deleteClickHandler);
|
||||
});
|
||||
|
||||
function deleteClickHandler()
|
||||
{
|
||||
var row = $(this).closest("tr");
|
||||
deleteComment(row);
|
||||
row.remove();
|
||||
}
|
||||
|
||||
function deleteComment(row) {
|
||||
var id = row.attr("id");
|
||||
$.ajax({
|
||||
url: '/api/index.php/comments/' + id,
|
||||
method: 'DELETE'
|
||||
});
|
||||
}
|
||||
|
||||
async function loadComments() {
|
||||
await $.get("/api/index.php/comments/<?php echo $ad->id ?>", renderComments);
|
||||
}
|
||||
|
||||
function renderComments(comments) {
|
||||
comments.forEach(function(comment) {
|
||||
var row = document.createElement("tr");
|
||||
row.id = comment.id;
|
||||
row.innerHTML = "<td>" + comment.user +
|
||||
"</td><td>" + comment.content +
|
||||
"</td><td><button class='btn btn-danger delete_comment_btn'>Izbriši</button></td>";
|
||||
|
||||
$("#comments").append(row);
|
||||
});
|
||||
}
|
||||
</script>
|
@@ -0,0 +1,50 @@
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Content</th>
|
||||
<th>Country</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="comments">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<hr/>
|
||||
<?php foreach ($ads as $ad): ?>
|
||||
<h2><?php echo $ad->title;?></h2>
|
||||
<p>
|
||||
<?php foreach ($ad->ads_categorys as $category): ?>
|
||||
<?php echo "$category->title ";?>
|
||||
<?php endforeach; ?>
|
||||
</p>
|
||||
<p><img width="200" src="<?php echo $ad->ad_img[0]->image?>"/></p>
|
||||
<a href='?controller=ads&action=show&id=<?php echo $ad->id; ?>'><button class="btn btn-primary">Prikaži</button></a>
|
||||
<hr/>
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(async function() {
|
||||
await loadComments();
|
||||
|
||||
});
|
||||
|
||||
async function loadComments() {
|
||||
await $.get("/api/index.php/comments", renderComments);
|
||||
}
|
||||
|
||||
function renderComments(comments) {
|
||||
comments.forEach(function(comment) {
|
||||
var row = document.createElement("tr");
|
||||
row.id = comment.id;
|
||||
row.innerHTML = "<td>" + comment.user +
|
||||
"</td><td>" + comment.content +
|
||||
"</td><td>" + comment.country +
|
||||
"</td><td><a href='?controller=ads&action=show&id=" + comment.id +"'><button class='btn btn-primary'>Poglej</button></a></td>";
|
||||
$("#comments").append(row);
|
||||
});
|
||||
}
|
||||
</script>
|
@@ -0,0 +1,14 @@
|
||||
<?php foreach($ads as $ad): ?>
|
||||
|
||||
<h2><?php echo $ad->title;?></h2>
|
||||
|
||||
<?php foreach ($ad->ad_img as $img):?>
|
||||
<p><img src="<?php echo $img->image;?>" width="200"/></p>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<a href="?controller=ads&action=edit&id=<?php echo $ad->id;?>"><button class="btn btn-primary">Uredi</button></a>
|
||||
<a href="?controller=ads&action=addImg&id=<?php echo $ad->id;?>"><button class="btn btn-primary">Dodaj sliko</button></a>
|
||||
<a href="?controller=ads&action=delete&id=<?php echo $ad->id;?>"><button class="btn btn-danger">Odstrani</button></a>
|
||||
|
||||
<hr/>
|
||||
<?php endforeach; ?>
|
@@ -0,0 +1,74 @@
|
||||
<h4><?php echo $ad->title; ?></h4>
|
||||
<p><?php echo $ad->description; ?></p>
|
||||
|
||||
<p>
|
||||
<?php foreach ($ad->ads_categorys as $cat):?>
|
||||
<?php echo "$cat->title "; ?>
|
||||
<?php endforeach; ?>
|
||||
</p>
|
||||
|
||||
<?php foreach ($ad->ad_img as $img):?>
|
||||
<p><img src="<?php echo $img->image;?>" width="400"/></p>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<p>Objavil: <?php echo $ad->user; ?></p>
|
||||
<a href="/admin/index.php"><button class="btn btn-primary">Nazaj</button></a>
|
||||
|
||||
<?php if(isset($_SESSION['USER_ID'])):?>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h4>Komentarji</h4>
|
||||
<div class="form-group">
|
||||
<label>Vsebina</label>
|
||||
<textarea class="form-control" id="comment_content" rows="3"></textarea>
|
||||
</div>
|
||||
<button id="submit_comment_btn" class="btn btn-primary">Dodaj</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<hr/>
|
||||
|
||||
<div id="comments">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(async function() {
|
||||
await loadComments();
|
||||
$("#submit_comment_btn").click(submitComment);
|
||||
});
|
||||
|
||||
function submitComment() {
|
||||
var data = {
|
||||
content: $("#comment_content").val(),
|
||||
ad_id: <?php echo "'$ad->id'"; ?>,
|
||||
};
|
||||
|
||||
$("#comment_content").val("");
|
||||
|
||||
$.post('/api/index.php/comments/', data, function(data) {
|
||||
var row = document.createElement("div");
|
||||
row.id = data.id;
|
||||
row.innerHTML = "<div class='row'><h4>" + data.user +
|
||||
"</h4><p>" + data.content +
|
||||
"</p></div>";
|
||||
$("#comments").append(row);
|
||||
});
|
||||
}
|
||||
|
||||
async function loadComments() {
|
||||
await $.get("/api/index.php/comments/<?php echo $ad->id ?>", renderComments);
|
||||
}
|
||||
|
||||
function renderComments(comments) {
|
||||
comments.forEach(function(comment) {
|
||||
var row = document.createElement("div");
|
||||
row.id = comment.id;
|
||||
row.innerHTML = "<div class='row'><h4>" + comment.user +
|
||||
"</h4><p>" + comment.content +
|
||||
"</p></div>";
|
||||
|
||||
$("#comments").append(row);
|
||||
});
|
||||
}
|
||||
</script>
|
@@ -0,0 +1,39 @@
|
||||
<html class="bg-dark-subtle">
|
||||
<head>
|
||||
<title>PHP</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body class="bg-dark-subtle">
|
||||
<div class="container">
|
||||
<h1 class="display-1" >Oglasnik</h1>
|
||||
<br/>
|
||||
<nav class="navbar bg-light-subtle">
|
||||
<div class="container-fluid navbar-expand-lg">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link" aria-current="page" href="/admin/index.php">Domov</a>
|
||||
|
||||
<?php if(isset($_SESSION["USER_ID"])): ?>
|
||||
<a class="nav-link" href="/admin/index.php?controller=ads&action=create">Objavi oglas</a>
|
||||
<a class="nav-link" href="/admin/index.php?controller=ads&action=show">Moji Oglasi</a>
|
||||
<a class="nav-link" href="/admin/index.php?controller=pages&action=logout">Odjava</a>
|
||||
<?php else: ?>
|
||||
<a class="nav-link" href="/admin/index.php?controller=pages&action=login">Prijava</a>
|
||||
<a class="nav-link" href="/admin/index.php?controller=pages&action=register">Registracija</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(isset($_SESSION["ADM"]) && $_SESSION["ADM"] > 0): ?>
|
||||
<a class="nav-link" href="/admin/index.php?controller=pages&action=api">Uporabniki</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<br/>
|
||||
|
||||
<!-- tukaj se bo vključevala koda pogledov, ki jih bodo nalagali kontrolerji -->
|
||||
<!-- klic akcije iz routes bo na tem mestu zgeneriral html kodo, ki bo zalepnjena v našo predlogo -->
|
||||
<?php require_once('routes.php'); ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,147 @@
|
||||
<!-- pogled za pregeld vseh oglasov-->
|
||||
<!-- na vrhu damu uporabniku gumb, s katerim proži akcijo create, da lahko dodaja nove uporabnike -->
|
||||
<h3>Ustvari oglas:</h3>
|
||||
Uporabnisko ime: <input type="text" name="username" id="create_ad_username" />
|
||||
Geslo: <input type="text" name="password" id="create_ad_password" />
|
||||
<button id="create_user_btn">Dodaj</button>
|
||||
<hr />
|
||||
<h3>Seznam vseh oglasov</h3>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Ime</th>
|
||||
<th>Priimek</th>
|
||||
<th>Email</th>
|
||||
<th>Naslov</th>
|
||||
<th>Posta</th>
|
||||
<th>Telefon</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ads_tbody">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<button hidden id="confrm_user_btn" class="btn btn-primary">Potrdi</button>
|
||||
<button hidden id="cancel_user_btn" class="btn btn-primary">Preklici</button>
|
||||
|
||||
<script>
|
||||
$(document).ready(async function() {
|
||||
await loadAds();
|
||||
$("#create_user_btn").click(createAd);
|
||||
$(".edit_user_btn").click(editClickHandler);
|
||||
$(".delete_user_btn").click(deleteClickHandler);
|
||||
$("#confrm_user_btn").click(confrmClickHandler);
|
||||
$("#cancel_user_btn").click(cancelClickHandler);
|
||||
});
|
||||
|
||||
async function loadAds() {
|
||||
await $.get("/api/index.php/users", renderAds);
|
||||
}
|
||||
|
||||
function renderAds(ads) {
|
||||
ads.forEach(function(ad) {
|
||||
var row = document.createElement("tr");
|
||||
row.id = ad.id;
|
||||
row.innerHTML = "<td>" + ad.username +
|
||||
"</td><td>" + ad.ime +
|
||||
"</td><td>" + ad.priimek +
|
||||
"</td><td>" + ad.email +
|
||||
"</td><td>" + ad.naslov +
|
||||
"</td><td>" + ad.posta +
|
||||
"</td><td>" + ad.telefon +
|
||||
"</td>";
|
||||
row.innerHTML += "<td><button class='btn btn-primary edit_user_btn'>Uredi</button>" +
|
||||
"<button class='btn btn-primary delete_user_btn'>Izbriši</button></td>";
|
||||
$("#ads_tbody").append(row);
|
||||
});
|
||||
}
|
||||
|
||||
function createAd() {
|
||||
var data = {
|
||||
username: $("#create_ad_username").val(),
|
||||
password: $("#create_ad_password").val()
|
||||
};
|
||||
|
||||
$("#create_ad_username").val("");
|
||||
$("#create_ad_password").val("");
|
||||
|
||||
$.post('/api/index.php/users/', data, function(data) {
|
||||
var row = document.createElement("tr");
|
||||
row.id = data.id;
|
||||
row.innerHTML = "<td>" + data.username +
|
||||
"</td><td>" + data.ime +
|
||||
"</td><td>" + data.priimek +
|
||||
"</td><td>" + data.email +
|
||||
"</td><td>" + data.naslov +
|
||||
"</td><td>" + data.posta +
|
||||
"</td><td>" + data.telefon +
|
||||
"</td>";
|
||||
row.innerHTML += "<td><button class='btn btn-primary edit_user_btn'>Uredi</button>" +
|
||||
"<button class='btn btn-primary delete_user_btn'>Izbriši</button></td>";
|
||||
$(".edit_user_btn", row).click(editClickHandler);
|
||||
$(".delete_user_btn", row).click(deleteClickHandler);
|
||||
$("#ads_tbody").append(row);
|
||||
});
|
||||
}
|
||||
|
||||
function editClickHandler() {
|
||||
var row = $(this).closest("tr");
|
||||
if ($(this).text() == "Uredi") {
|
||||
$(this).text("Shrani");
|
||||
row.find('td:not(:nth-last-child(-n+1)').attr('contenteditable', true);
|
||||
} else {
|
||||
$(this).text("Uredi");
|
||||
row.find('td:not(:nth-last-child(-n+1))').attr('contenteditable', false);
|
||||
updateAd(row);
|
||||
}
|
||||
}
|
||||
|
||||
function updateAd(row) {
|
||||
var id = row.attr("id");
|
||||
var data = {
|
||||
username: row.find('td:nth-child(1)').text(),
|
||||
ime: row.find('td:nth-child(2)').text(),
|
||||
priimek: row.find('td:nth-child(3)').text(),
|
||||
email: row.find('td:nth-child(4)').text(),
|
||||
naslov: row.find('td:nth-child(5)').text(),
|
||||
posta: row.find('td:nth-child(6)').text(),
|
||||
telefon: row.find('td:nth-child(7)').text()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '/api/index.php/users/' + id,
|
||||
method: 'PUT',
|
||||
data: JSON.stringify(data),
|
||||
contentType: 'application/json'
|
||||
});
|
||||
}
|
||||
|
||||
var rowToBeDeleted;
|
||||
function deleteClickHandler() {
|
||||
rowToBeDeleted = $(this).closest("tr");
|
||||
$("#confrm_user_btn").attr("hidden", false);
|
||||
$("#cancel_user_btn").attr("hidden", false);
|
||||
}
|
||||
|
||||
function cancelClickHandler() {
|
||||
$("#confrm_user_btn").attr("hidden", true);
|
||||
$("#cancel_user_btn").attr("hidden", true);
|
||||
}
|
||||
|
||||
function confrmClickHandler() {
|
||||
deleteAd(rowToBeDeleted);
|
||||
rowToBeDeleted.remove();
|
||||
$("#confrm_user_btn").attr("hidden", true);
|
||||
$("#cancel_user_btn").attr("hidden", true);
|
||||
}
|
||||
|
||||
function deleteAd(row) {
|
||||
var id = row.attr("id");
|
||||
$.ajax({
|
||||
url: '/api/index.php/users/' + id,
|
||||
method: 'DELETE'
|
||||
});
|
||||
}
|
||||
</script>
|
@@ -0,0 +1 @@
|
||||
<p>Prišlo je do napake.</p>
|
@@ -0,0 +1,11 @@
|
||||
<h2>Prijava</h2>
|
||||
<form action="?controller=pages&action=login" method="POST">
|
||||
|
||||
<label class="form-label" >Uporabniško ime</label>
|
||||
<input class="form-control w-25" type="text" name="username" />
|
||||
<label class="form-label" >Geslo</label>
|
||||
<input class="form-control w-25" type="password" name="password" />
|
||||
<br/>
|
||||
<input class="btn btn-primary" type="submit" name="submit" value="Pošlji" />
|
||||
<br/>
|
||||
</form>
|
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
session_unset(); //Odstrani sejne spremenljivke
|
||||
session_destroy(); //Uniči sejo
|
||||
header("Location: /admin/index.php"); //Preusmeri na index.php
|
||||
die();
|
@@ -0,0 +1,35 @@
|
||||
<h2>Registracija</h2>
|
||||
<form action="?controller=pages&action=register" method="POST">
|
||||
|
||||
<label class="form-label">Uporabniško ime</label>
|
||||
<input class="form-control w-25" type="text" name="username" required/>
|
||||
|
||||
<label class="form-label">Geslo</label>
|
||||
<input class="form-control w-25" type="password" name="password" required/>
|
||||
|
||||
<label class="form-label">Ponovi geslo</label>
|
||||
<input class="form-control w-25" type="password" name="repeat_password" required/>
|
||||
|
||||
<label class="form-label">Email</label>
|
||||
<input class="form-control w-25" type="email" name="email" required/>
|
||||
|
||||
<label class="form-label">Ime</label>
|
||||
<input class="form-control w-25" type="text" name="ime" required/>
|
||||
|
||||
<label class="form-label">Priimek</label>
|
||||
<input class="form-control w-25" type="text" name="priimek" required/>
|
||||
|
||||
<label class="form-label">Naslov</label>
|
||||
<input class="form-control w-25" type="text" name="naslov" />
|
||||
|
||||
<label class="form-label">Posta</label>
|
||||
<input class="form-control w-25" type="text" name="posta" />
|
||||
|
||||
<label class="form-label">Telefon</label>
|
||||
<input class="form-control w-25" type="text" name="telefon" />
|
||||
|
||||
<br/>
|
||||
<input class="btn btn-primary" type="submit" name="submit" value="Pošlji" />
|
||||
<br/>
|
||||
<?php echo $error; ?>
|
||||
</form>
|
Reference in New Issue
Block a user