mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-04-22 10:52:09 +00:00
j
This commit is contained in:
commit
dc83309519
@ -469,12 +469,7 @@ input {
|
||||
}
|
||||
|
||||
.container-post {
|
||||
background-color: white;
|
||||
padding: 45px;
|
||||
}
|
||||
|
||||
.container-search {
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 30px;
|
||||
background-color: white;
|
||||
padding: 45px;
|
||||
}
|
||||
@ -583,10 +578,11 @@ input {
|
||||
.filtre {
|
||||
width: 100%;
|
||||
padding: 6px 10px 6px 10px;
|
||||
color: white;
|
||||
color: #fff;
|
||||
text-transform: uppercase;
|
||||
font-size: 14px;
|
||||
margin-top: 15px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.dev-color {
|
||||
@ -618,7 +614,7 @@ input {
|
||||
}
|
||||
|
||||
.tag {
|
||||
color: white;
|
||||
color: #fff;
|
||||
background-color: #cccccc;
|
||||
text-transform: uppercase;
|
||||
display: inline-block;
|
||||
@ -636,7 +632,7 @@ input {
|
||||
.phraseFooter {
|
||||
font-size: 17px;
|
||||
padding-top: 10px;
|
||||
color: white;
|
||||
color: #fff;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
@ -655,7 +651,7 @@ input {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
width: 180px;
|
||||
color: white;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#glass {
|
||||
@ -669,7 +665,7 @@ input {
|
||||
}
|
||||
|
||||
#titre-home {
|
||||
color: white;
|
||||
color: #fff;
|
||||
padding-bottom: 20px;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
@ -684,6 +680,27 @@ input {
|
||||
}
|
||||
|
||||
@media screen and (max-width: 640px) {
|
||||
.contact-footer{
|
||||
display: none;
|
||||
}
|
||||
.connexion-footer{
|
||||
display: none;
|
||||
}
|
||||
.bloc-post{
|
||||
width: 100%;
|
||||
}
|
||||
.bloc-recent{
|
||||
padding-top: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
.cover-text {
|
||||
padding: 0px 40px;
|
||||
}
|
||||
|
||||
.bloc-filter{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.nav_imie {
|
||||
height: 0;
|
||||
}
|
||||
@ -759,6 +776,10 @@ input {
|
||||
.bloc_principal {
|
||||
height: 650px;
|
||||
}
|
||||
|
||||
.cover-text {
|
||||
padding: 0px 40px;
|
||||
}
|
||||
}
|
||||
|
||||
form.login > input {
|
||||
@ -767,8 +788,31 @@ form.login > input {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
form.login >input[type="submit"] {
|
||||
left: -46%;
|
||||
form.login >input[type="submit"], form.login > a {
|
||||
left: -44%;
|
||||
position: relative;
|
||||
margin-top: 10px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
form.login > a {
|
||||
left: -28%;
|
||||
margin-top: 65px;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
||||
td, th {
|
||||
border: 1px solid #dddddd;
|
||||
text-align: left;
|
||||
padding: 8px;
|
||||
background:#fff;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -15,8 +15,8 @@
|
||||
<ul>
|
||||
<li class="lowFooterItem">Politique et confidentialité</li>
|
||||
<li class="lowFooterItem">Mentions légales</li>
|
||||
<li class="lowFooterItem">Contact</li>
|
||||
<li class="lowFooterItem">Connexion</li>
|
||||
<li class="lowFooterItem contact-footer">Contact</li>
|
||||
<li class="lowFooterItem connexion-footer">Connexion</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>Page Title</title>
|
||||
<title></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style.css"/>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<div>
|
||||
<div class="nav_imie">
|
||||
<tag type="element" />
|
||||
<div class="container-fluid">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<ul>
|
||||
<li class="item_nav_imie link"><a>Connexion</a></li>
|
||||
<li class="item_nav_imie link"><a href="https://imie44.ymag.cloud">Accès Net-Yparéo</a></li>
|
||||
<li class="item_nav_imie link"><a href="https://www.imie.fr">IMIE Numérique</a></li>
|
||||
<li class="item_nav_imie social"><a href="https://twitter.com/EcoleIMIE">
|
||||
@ -13,7 +13,21 @@
|
||||
<li class="item_nav_imie social"><a href="https://www.facebook.com/EcolesIMIE/">
|
||||
<tag type="svg" file="facebook" style="color: white; width: 18px; height: 18px" /></a></li>
|
||||
<li class="item_nav_imie link" style="float: left">
|
||||
<tag type="user" />
|
||||
<tag type="isLoggedIn">
|
||||
<if true>
|
||||
<tag type="user" column="username" />
|
||||
</if>
|
||||
<if false>
|
||||
<a href="/login">Connection</a>
|
||||
</if>
|
||||
</tag>
|
||||
</li>
|
||||
<li class="item_nav_imie link" style="float: left">
|
||||
<tag type="isLoggedIn" role="ROLE_ADMIN">
|
||||
<if true>
|
||||
<a href="/users">Utilisateurs</a>
|
||||
</if>
|
||||
</tag>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -29,8 +43,14 @@
|
||||
<ul>
|
||||
<li class="item_nav_blog_logo"><a href="/">
|
||||
<tag type="svg" file="logo-imie-blog" style="color: white; width: 200px; height: 64px; margin-top: 6px;" /></a></li>
|
||||
<li class="item_nav_blog_droite_icon"><input id="search" type="text" placeholder="Recherche"><a>
|
||||
<tag type="svg" file="mignify" style="color: rgba(0, 0, 0, .5); width: 18px; height: 18px cursor: pointer" /></a></li>
|
||||
<li class="item_nav_blog_droite_icon">
|
||||
<form method="dialog" action="/search">
|
||||
<input name="term" id="search" class="el-search" type="text" placeholder="Recherche">
|
||||
<button type="submit">
|
||||
<tag type="svg" file="mignify" style="color: rgba(0, 0, 0, .5); width: 18px; height: 18px" />
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
<li class="item_nav_blog_droite devops"><a>DEVOPS</a></li>
|
||||
<li class="item_nav_blog_droite ops"><a>OPS</a></li>
|
||||
<li class="item_nav_blog_droite digi"><a>DIGI</a></li>
|
||||
|
@ -22,6 +22,7 @@
|
||||
<input name="password" id="password" type="password" placeholder="password" />
|
||||
|
||||
<input type="submit" class="bloc-plus" value="Login"/>
|
||||
<a href="/register" class="bloc-plus">Register</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,13 +11,17 @@
|
||||
<main class="test container">
|
||||
<div class="bloc-post">
|
||||
<div class="container-post post article-cat">
|
||||
<h2 class="title"><tag type="article" column="title" /></h2>
|
||||
<h2 class="title">
|
||||
<tag type="article" column="title" />
|
||||
</h2>
|
||||
<div class="etiquettes">
|
||||
<span class="cat"><tag type="article" column="category"/></span>
|
||||
<span class="date"><tag type="article" column="datetime"/></span>
|
||||
<span class="cat">
|
||||
<tag type="article" column="category" /></span>
|
||||
<span class="date">
|
||||
<tag type="article" column="datetime" /></span>
|
||||
</div>
|
||||
<p class="post text">
|
||||
<tag type="article" column="content"/>
|
||||
<tag type="article" column="content" />
|
||||
</p>
|
||||
</div>
|
||||
<div class="credit">
|
||||
@ -26,8 +30,12 @@
|
||||
<a>
|
||||
<tag type="svg" file="avatar" style="color: white; height: 64px" /></a>
|
||||
<div class="by">
|
||||
<h3 class="name"><tag type="authorTag" column="username" /></h3>
|
||||
<h3 class="job"><tag type="authorTag" column="job" /></h3>
|
||||
<h3 class="name">
|
||||
<tag type="authorTag" column="username" />
|
||||
</h3>
|
||||
<h3 class="job">
|
||||
<tag type="authorTag" column="job" />
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -35,18 +43,21 @@
|
||||
|
||||
<div class="bloc-filter">
|
||||
<h3>Plus d'articles</h3>
|
||||
<p class="title-small">Catégories</p>
|
||||
<div class="filtre dev-color">dev</div>
|
||||
<div class="filtre digi-color">digi</div>
|
||||
<div class="filtre ops-color">ops</div>
|
||||
<div class="filtre devops-color">devops</div>
|
||||
<p class="title-small">Tags</p>
|
||||
<tag type="tags" />
|
||||
<p class="title-small">Catégories</p>
|
||||
<div class="filtre dev-color">dev</div>
|
||||
<div class="filtre digi-color">digi</div>
|
||||
<div class="filtre ops-color">ops</div>
|
||||
<div class="filtre devops-color">devops</div>
|
||||
<p class="title-small">Tags</p>
|
||||
<tag type="tags" />
|
||||
</div>
|
||||
|
||||
<div class="bloc-recent">
|
||||
<div class="contenue-recent">Article précédent</div>
|
||||
<div class="contenue-recent next">Article suivant</div>
|
||||
<tag type="isLoggedIn" reol="ROLE_EDITOR">
|
||||
<if true>
|
||||
<a href="./edit" class="contenue-recent next">Editer l'article</a>
|
||||
</if>
|
||||
</tag>
|
||||
</div>
|
||||
|
||||
<h3 id="titre-between">Dans le même thème</h3>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<input name="username" id="username" type="text" placeholder="username" />
|
||||
<input name="password" id="password" type="password" placeholder="password" />
|
||||
|
||||
<input type="submit" class="bloc-plus" value="Login"/>
|
||||
<input type="submit" class="bloc-plus" value="Register"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -43,9 +43,16 @@
|
||||
</tag>
|
||||
</div>
|
||||
|
||||
<div class="bloc-filter">
|
||||
<div class="bloc-filter int-search">
|
||||
<p class="title-small">Catégories</p>
|
||||
<a data-category="3" class="filtre dev-color">dev</a>
|
||||
<a data-category="4" class="filtre digi-color">digi</a>
|
||||
<a data-category="2" class="filtre ops-color">ops</a>
|
||||
<a data-category="1" class="filtre devops-color">devops</a>
|
||||
<p class="title-small">Tags</p>
|
||||
<tag type="tags" />
|
||||
</div>
|
||||
|
||||
|
||||
</main>
|
||||
<footer>
|
||||
<tag type="includes" file="footer" />
|
||||
|
40
assets/html/user_add.html
Normal file
40
assets/html/user_add.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<tag type="includes" file="header" />
|
||||
</header>
|
||||
<main class="test container">
|
||||
<div class="bloc_principal">
|
||||
<div class="cover-black">
|
||||
<div class="bloc_principal_titre">
|
||||
<h1>LE BLOG DES APPRENANTS</h1>
|
||||
</div>
|
||||
<div class="cover-text">
|
||||
<h2 id="titre-home">Voilà les informations que vous devez entrer pour créer un utilisateur</h2>
|
||||
<div class="p-home">
|
||||
<form name="login" id="name" method="POST" class="login" action="/users/new/">
|
||||
<input name="username" id="username" type="text" placeholder="Nom d'utilisateur" />
|
||||
<input name="password" id="password" type="password" placeholder="Mot de passe" />
|
||||
<select name="role" id="role">
|
||||
<option default value="ROLE_USER">Utilisateur</option>
|
||||
<option value="ROLE_EDITOR">Editeur</option>
|
||||
<option value="ROLE_ADMIN">Administrateur</option>
|
||||
</select>
|
||||
<input type="submit" class="bloc-plus" value="Créer"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<tag type="includes" file="footer" />
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
40
assets/html/user_edit.html
Normal file
40
assets/html/user_edit.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<tag type="includes" file="header" />
|
||||
</header>
|
||||
<main class="test container">
|
||||
<div class="bloc_principal">
|
||||
<div class="cover-black">
|
||||
<div class="bloc_principal_titre">
|
||||
<h1>LE BLOG DES APPRENANTS</h1>
|
||||
</div>
|
||||
<div class="cover-text">
|
||||
<h2 id="titre-home">Voilà les informations que vous devez entrer pour créer un utilisateur</h2>
|
||||
<div class="p-home">
|
||||
<form name="login" id="name" method="POST" class="login" action="./edit">
|
||||
<input name="username" id="username" type="text" placeholder="Nom d'utilisateur" />
|
||||
<input name="password" id="password" type="password" placeholder="Mot de passe" />
|
||||
<select>
|
||||
<option value="ROLE_USER">Utilisateur</option>
|
||||
<option value="ROLE_EDITOR">Editeur</option>
|
||||
<option value="ROLE_ADMIN">Administrateur</option>
|
||||
</select>
|
||||
<input type="submit" class="bloc-plus" value="Créer"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<tag type="includes" file="footer" />
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
49
assets/html/user_list.html
Normal file
49
assets/html/user_list.html
Normal file
@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<tag type="includes" file="header" />
|
||||
</header>
|
||||
<main class="test container">
|
||||
<div class="bloc_principal">
|
||||
<div class="cover-black">
|
||||
<div class="bloc_principal_titre">
|
||||
<h1>LE BLOG DES APPRENANTS</h1>
|
||||
</div>
|
||||
<div class="cover-text">
|
||||
<h2 id="titre-home">cliquez sur un utilisateur pour le modifier</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nom d'utilisateur</th>
|
||||
<th>Role</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tag type="users">
|
||||
<tr>
|
||||
<td>
|
||||
<loop column="username" />
|
||||
</td>
|
||||
<td>
|
||||
<loop column="role" />
|
||||
</td>
|
||||
</tr>
|
||||
</tag>
|
||||
</tbody>
|
||||
</table>
|
||||
<a href="/users/new" class="bloc-plus">Nouvel utilisateur</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<tag type="includes" file="footer" />
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -95,3 +95,17 @@ if(document.querySelector(".addTag") != null) {
|
||||
document.querySelector(".addTag").addEventListener("click", addTag);
|
||||
document.querySelector(".submitPost").addEventListener("click", submit);
|
||||
}
|
||||
|
||||
document.querySelector("#search + a").addEventListener("click", function() {
|
||||
window.location = window.location.pathname + "?term=" + document.querySelector("#search").value;
|
||||
});
|
||||
|
||||
document.querySelectorAll(".int-search .filtre").forEach(function(el) {
|
||||
el.addEventListener("click", function() {
|
||||
var tagW = new URL(window.location).searchParams.get("tag");
|
||||
var tag = (tagW != null ? "&tag=" + tagW : "");
|
||||
var termW = new URL(window.location).searchParams.get("term");
|
||||
var term = (termW != null ? "&term=" + termW : "");
|
||||
window.location = window.location.pathname + "?category=" + this.getAttribute("data-category") + tag + term;
|
||||
})
|
||||
})
|
||||
|
@ -43,6 +43,9 @@ class Controller {
|
||||
if(!isset($_SESSION["author"]) || (isset($_SESSION["author"]) && ($_SESSION["author"]->getRole() != "ROLE_EDITOR" && $_SESSION["author"]->getRole() != "ROLE_ADMIN"))) header("Location: /login/?redirect=".$_SERVER["REQUEST_URI"]);
|
||||
} elseif($arr[0] === "admin" && isset($cl) && $cl ==$class) {
|
||||
if(!isset($_SESSION["author"]) || (isset($_SESSION["author"]) && $_SESSION["author"]->getRole() != "ROLE_ADMIN")) header("Location: /login/?redirect=".$_SERVER["REQUEST_URI"]);
|
||||
} elseif($arr[0] === "title" && isset($cl) && $cl == $class) {
|
||||
array_shift($arr);
|
||||
$_GET['page_title'] = join(" ", $arr);
|
||||
}
|
||||
}
|
||||
if(isset($instance)) {
|
||||
@ -51,6 +54,7 @@ class Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
$_GET["page_title"] = "404 error";
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
return file_get_contents(DIR."/html/404.html");
|
||||
|
||||
|
@ -11,20 +11,16 @@ class HomeController extends Controller {
|
||||
|
||||
/**
|
||||
* @route /^\/$/
|
||||
* @title Accueil
|
||||
*/
|
||||
public function home() {
|
||||
return file_get_contents(DIR."/html/index.html");
|
||||
}
|
||||
|
||||
/**
|
||||
* @route /^\/post\/[0-9]+\/$/
|
||||
*/
|
||||
public function post() {
|
||||
return file_get_contents(DIR."/html/post.html");
|
||||
}
|
||||
|
||||
/**
|
||||
* @route /^\/search\//
|
||||
* @title Rechercher
|
||||
*/
|
||||
public function search() {
|
||||
return file_get_contents(DIR."/html/search.html");
|
||||
|
@ -11,6 +11,7 @@ class LoginController extends Controller {
|
||||
|
||||
/**
|
||||
* @route /^\/login\/$/
|
||||
* @title Login
|
||||
*/
|
||||
public function login() {
|
||||
|
||||
@ -38,6 +39,7 @@ class LoginController extends Controller {
|
||||
|
||||
/**
|
||||
* @route /^\/register\/$/
|
||||
* @title Register
|
||||
*/
|
||||
public function register() {
|
||||
if(isset($_POST["password"]) && isset($_POST["username"]) && Author::getByUsername($_POST["username"]) === null) {
|
||||
|
@ -7,10 +7,11 @@ use App\DB\Post;
|
||||
use App\DB\Tag;
|
||||
|
||||
|
||||
class AddEditController extends Controller {
|
||||
class PostController extends Controller {
|
||||
/**
|
||||
* @route /^\/post\/[0-9]+\/edit\/$/
|
||||
* @editor
|
||||
* @title Modification d'article
|
||||
*/
|
||||
public function postEdit() {
|
||||
if(isset($_GET["post"]) && isset($_GET["title"]) && isset($_GET["category"]) && isset($_GET["content"]) && isset($_GET["tags"])) {
|
||||
@ -42,6 +43,7 @@ class AddEditController extends Controller {
|
||||
/**
|
||||
* @route /^\/post\/new\/*$/
|
||||
* @editor
|
||||
* @title Ajout d'Article
|
||||
*/
|
||||
public function postAdd() {
|
||||
|
||||
@ -75,4 +77,13 @@ class AddEditController extends Controller {
|
||||
|
||||
return file_get_contents(DIR."/html/post_new.html");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @route /^\/post\/[0-9]+\/$/
|
||||
* @title Article
|
||||
*/
|
||||
public function post() {
|
||||
return file_get_contents(DIR."/html/post.html");
|
||||
}
|
||||
}
|
48
assets/php/Controller/UserController.php
Normal file
48
assets/php/Controller/UserController.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
use App\Controller;
|
||||
use App\DB\Author;
|
||||
|
||||
class UserController extends Controller {
|
||||
|
||||
|
||||
/**
|
||||
* @route /^\/users\/new\/$/
|
||||
* @admin
|
||||
* @title Ajouter un utilisateur
|
||||
*/
|
||||
public function addUser() {
|
||||
|
||||
if(isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["role"])) {
|
||||
$user = new Author();
|
||||
$user->setUsername($_POST["username"]);
|
||||
$user->setPassword($_POST["password"]);
|
||||
Author::add($user);
|
||||
header("Location: /users/");
|
||||
}
|
||||
|
||||
return \file_get_contents(DIR . "/html/user_add.html");
|
||||
}
|
||||
|
||||
/**
|
||||
* @route /^\/users\/$/
|
||||
* @admin
|
||||
* @title liste des utilisateurs
|
||||
*/
|
||||
public function listUser() {
|
||||
return \file_get_contents(DIR."/html/user_list.html");
|
||||
}
|
||||
|
||||
/**
|
||||
* @route /^\/user\/edit\/$/
|
||||
* @admin
|
||||
* @title Modifier un utilisateur
|
||||
*/
|
||||
public function editUser() {
|
||||
return \file_get_contents(DIR."/html/user_edit.html");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
18
assets/php/Tags/Element.php
Normal file
18
assets/php/Tags/Element.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tags;
|
||||
|
||||
use DomXPath;
|
||||
|
||||
class Element extends Tag {
|
||||
public function render() {
|
||||
$el = $this->getElement();
|
||||
$term = isset($_GET["term"]) ? $_GET["term"] : "";
|
||||
if($el->hasAttribute("el")) $el->parentNode->insertBefore($this->getDoc()->createTextNode($term), $el);
|
||||
else {
|
||||
$finder = new DomXPath($this->getDoc());
|
||||
$nodes = $finder->query("//*[contains(@class, 'el-search')]");
|
||||
if(count($nodes) >= 1) $nodes[0]->setAttribute("value", $term);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,15 +20,24 @@ class IsLoggedIn extends Tag {
|
||||
|
||||
$el = $this->getElement();
|
||||
|
||||
|
||||
if(isset($_SESSION["author"])) {
|
||||
if($el->hasAttribute("role") || !$_SESSION["author"]->getRole() == "ROLE_ADMIN") {
|
||||
$loggedin = $el->getAttribute("role") == $_SESSION["author"]->getRole();
|
||||
} else $loggedin = true;
|
||||
} else $loggedin = false;
|
||||
|
||||
|
||||
//debugging purpose
|
||||
$loggedin = false;
|
||||
// $loggedin = false;
|
||||
// var_dump($loggedin);
|
||||
|
||||
foreach ($el->getElementsByTagName("if") as $element) {
|
||||
if($element->hasAttribute("true") && $loggedin) {
|
||||
$r = $element->childNodes->item(1);
|
||||
$r = $element->childNodes->item(0);
|
||||
$el->parentNode->insertBefore($r, $el);
|
||||
} elseif ($element->hasAttribute("false")) {
|
||||
$r = $element->childNodes->item(1);
|
||||
} elseif ($element->hasAttribute("false") && !isset($_SESSION["author"])) {
|
||||
$r = $element->childNodes->item(0);
|
||||
$el->parentNode->insertBefore($r, $el);
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,10 @@ class Loop extends Tag {
|
||||
$category = $el->getAttribute("category") != '' ? Post::get($_GET["post"])->getCategory()->getId() : $category;
|
||||
$tag = isset($_GET["tag"]) && intval($_GET["tag"]) ? (int) $_GET["tag"] : -1;
|
||||
|
||||
$term = isset($_GET["term"]) ? $_GET["term"] : "";
|
||||
|
||||
if($category != -1) {
|
||||
$posts = Post::listByCategory($category, $isRecent, $limit);
|
||||
$posts = Post::listByCategory($category, $isRecent, $limit, $term);
|
||||
if(isset($_GET["post"])) {
|
||||
$postsList = array();
|
||||
foreach ($posts as $post) {
|
||||
@ -38,7 +40,7 @@ class Loop extends Tag {
|
||||
$posts = $postsList;
|
||||
}
|
||||
} else {
|
||||
$posts = Post::list($isRecent, $limit);
|
||||
$posts = Post::list($isRecent, $limit, $term);
|
||||
}
|
||||
|
||||
if($tag != -1) {
|
||||
|
@ -81,6 +81,11 @@ class Tag {
|
||||
$head->item(0)->appendChild($t);
|
||||
}
|
||||
|
||||
$title = $dom->getElementsByTagName("title");
|
||||
if($title->count() >= 1) {
|
||||
$title->item(0)->appendChild($dom->createTextnode($_GET["page_title"]));
|
||||
}
|
||||
|
||||
|
||||
$list = $dom->getElementsByTagName("tag");
|
||||
|
||||
|
@ -4,6 +4,7 @@ namespace App\Tags;
|
||||
|
||||
use App\Tags\Tag;
|
||||
use App\DB\Post;
|
||||
use App\DB\Tag as AppTag;
|
||||
|
||||
class Tags extends Tag {
|
||||
public function render() {
|
||||
@ -12,12 +13,17 @@ class Tags extends Tag {
|
||||
|
||||
$doc = $this->getDoc();
|
||||
|
||||
$post = Post::get($_GET["post"]);
|
||||
$tags = isset($_GET["post"]) ? Post::get($_GET["post"])->getTags() : AppTag::list();
|
||||
/** @var \App\DB\Tag $tag */
|
||||
foreach ($post->getTags() as $tag) {
|
||||
foreach ($tags as $tag) {
|
||||
$res = $doc->createElement("a");
|
||||
$res->setAttribute("href", "/search/?tag=" . $tag->getId());
|
||||
$res->setAttribute("class", "tag");
|
||||
$url = "?tag=" . $tag->getId();
|
||||
if(isset($_GET["term"])) $url .= "&term=" . $_GET["term"];
|
||||
if(isset($_GET["category"])) $url .= "&category=" . $_GET["category"];
|
||||
$res->setAttribute("href", "/search/" . $url);
|
||||
$classes = "tag";
|
||||
if(isset($_GET["tag"]) && $tag->getId() == $_GET["tag"]) $classes .= " active";
|
||||
$res->setAttribute("class", $classes);
|
||||
$text = $doc->createTextNode($tag->getName());
|
||||
$res->appendChild($text);
|
||||
$pok->parentNode->insertBefore($res, $pok);
|
||||
|
@ -5,6 +5,10 @@ namespace App\Tags;
|
||||
class User extends Tag {
|
||||
public function render() {
|
||||
$el = $this->getElement();
|
||||
if(isset($_SESSION["author"])) $el->parentNode->insertBefore($this->getDoc()->createTextNode($_SESSION["author"]->getId()), $el);
|
||||
if(isset($_SESSION["author"])) {
|
||||
$col = $el->getAttribute("column");
|
||||
$func = "get" . ucfirst($col);
|
||||
$el->parentNode->insertBefore($this->getDoc()->createTextNode($_SESSION["author"]->$func()), $el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
15
assets/php/Tags/UserEditor.php
Normal file
15
assets/php/Tags/UserEditor.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tags;
|
||||
|
||||
use App\DB\Category;
|
||||
use DateTime;
|
||||
use App\DB\Tag;
|
||||
use App\DB\Post;
|
||||
|
||||
|
||||
class UserEditor extends \App\Tags\Tag {
|
||||
public function render() {
|
||||
|
||||
}
|
||||
}
|
36
assets/php/Tags/Users.php
Normal file
36
assets/php/Tags/Users.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tags;
|
||||
|
||||
use App\DB\Author;
|
||||
|
||||
|
||||
class Users extends Tag {
|
||||
public function render() {
|
||||
$el = $this->getElement();
|
||||
$doc = $this->getDoc();
|
||||
$parent = $el->parentNode;
|
||||
foreach (Author::list(true, 1000) as $user) {
|
||||
$pok = $el->childNodes->item(0)->cloneNode(true);
|
||||
|
||||
$parent->insertBefore($pok, $el);
|
||||
|
||||
$elements = $pok->getElementsByTagName("loop");
|
||||
|
||||
foreach ($elements as $ele) {
|
||||
$col = 'get' . ucfirst($ele->getAttribute("column"));
|
||||
$txt = $doc->createTextNode($user->$col());
|
||||
$ele->parentNode->insertBefore($txt, $ele);
|
||||
}
|
||||
|
||||
$loop = $pok->getElementsByTagName("loop");
|
||||
|
||||
while ($loop->count() >= 1) {
|
||||
$loop->item(0)->parentNode->removeChild($loop->item(0));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -137,12 +137,17 @@ class Post {
|
||||
* @return Post[]
|
||||
*/
|
||||
|
||||
public static function list($recent = true, $limit = 100) {
|
||||
public static function list($recent = true, $limit = 100, $term = "") {
|
||||
$sort = $recent ? "DESC" : "ASC";
|
||||
$query = "SELECT * FROM posts ORDER BY dt " . $sort . " LIMIT " . $limit;
|
||||
$query = "SELECT * FROM posts WHERE title LIKE :el OR content LIKE :el ORDER BY dt " . $sort . " LIMIT " . $limit;
|
||||
|
||||
$pdo = Functions::connect();
|
||||
$posts = $pdo->query($query)->fetchAll();
|
||||
|
||||
$prp = $pdo->prepare($query);
|
||||
$term = "%" . $term . "%";
|
||||
$prp->bindValue(":el", $term);
|
||||
$prp->execute();
|
||||
$posts = $prp->fetchAll();
|
||||
|
||||
$res = array();
|
||||
|
||||
@ -163,13 +168,22 @@ class Post {
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function listByCategory($categoryId = null, $recent = true, $limit = 100) {
|
||||
public static function listByCategory($categoryId = null, $recent = true, $limit = 100, $el = "") {
|
||||
$sort = $recent ? "DESC" : "ASC";
|
||||
$cat = $categoryId !== null ? "WHERE category=" . $categoryId : "";
|
||||
$query = "SELECT * FROM posts " . $cat . " ORDER BY dt " . $sort . " LIMIT " . $limit;
|
||||
$cat = $categoryId !== null ? "AND category=" . $categoryId : "";
|
||||
$query = "SELECT * FROM posts WHERE (title LIKE :el OR content LIKE :el ) " . $cat . " ORDER BY dt " . $sort . " LIMIT " . $limit;
|
||||
|
||||
$pdo = Functions::connect();
|
||||
$posts = $pdo->query($query)->fetchAll();
|
||||
|
||||
$prp = $pdo->prepare($query);
|
||||
|
||||
$el = "%" . $el . "%";
|
||||
|
||||
$prp->bindValue(":el", $el);
|
||||
$prp->execute();
|
||||
// var_dump($prp->errorInfo());
|
||||
// die;
|
||||
$posts = $prp->fetchAll();
|
||||
|
||||
$res = array();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user