From a4d60d2f76db1fe5317481c8caab414581438fe6 Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 7 Mar 2019 16:32:27 +0100 Subject: [PATCH] linkedin + some css --- assets/css/style.css | 19 +++++++++++++------ assets/html/includes/header.html | 22 +++++++++++++++------- assets/html/post.html | 1 + assets/html/user_edit.html | 1 + assets/php/Controller/UserController.php | 23 +++++++++++++++++++++++ assets/php/Tags/AuthorTag.php | 13 +++++++++++-- assets/php/Tags/UserEditor.php | 7 +++++++ assets/php/db/Author.php | 20 +++++++++++++++++--- sql/data.sql | 1 + 9 files changed, 89 insertions(+), 18 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 7128970..aac1885 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -164,13 +164,14 @@ a{ padding-right: 2%; } -@media only screen and (min-width: 992px) { +@media (min-width: 992px) { .articleHome { padding-right: 10%; padding-left: 10%; } } + .bloc_principal_titre .nav_imie { @@ -178,7 +179,7 @@ a{ background-color: #1c1c1c; } -.nav_blog { +.nav_blog .container-fluid { height: 80px; background-color: #110230; margin-bottom: 70px; @@ -853,6 +854,9 @@ label{ } @media screen and (max-width: 640px) { + .item_nav_imie.right { + display: none; + } .contact-footer{ display: none; } @@ -874,10 +878,6 @@ label{ display:none; } - .nav_imie { - height: 0; - } - #twi { height: 0; width: 0; @@ -1031,3 +1031,10 @@ table { color: inherit; text-decoration: inherit; } + + +@media (max-width: 992px) { + .item_nav_imie.right, .item_nav_blog_droite { + display: none; + } +} diff --git a/assets/html/includes/header.html b/assets/html/includes/header.html index f575b40..db1b8b1 100644 --- a/assets/html/includes/header.html +++ b/assets/html/includes/header.html @@ -6,11 +6,11 @@
diff --git a/assets/html/user_edit.html b/assets/html/user_edit.html index 2caa235..49d5f8b 100644 --- a/assets/html/user_edit.html +++ b/assets/html/user_edit.html @@ -21,6 +21,7 @@ + diff --git a/assets/php/Controller/UserController.php b/assets/php/Controller/UserController.php index 381847a..5134bbe 100644 --- a/assets/php/Controller/UserController.php +++ b/assets/php/Controller/UserController.php @@ -19,6 +19,7 @@ class UserController extends Controller { $user->setUsername($_POST["username"]); $user->setPassword($_POST["password"]); $user->setRole($_POST["role"]); + $user->setLinkedin($_POST["linkedin"]); Author::add($user); header("Location: /users/"); } @@ -49,12 +50,34 @@ class UserController extends Controller { if($_POST["password"] != '') $user->setPassword($_POST["password"]); $user->setRole($_POST["role"]); $user->setJob($_POST["job"]); + $user->setLinkedin($_POST["linkedin"]); Author::update($user); header("Location: /users/"); } return file_get_contents(DIR."/html/user_edit.html"); } + /** + * @route /\/user\/edit\/$/ + * @editor + * @title Modifier un utilisateur + */ + public function userEdit() { + $_GET['edit_user'] = $_SESSION["author"]->getId(); + + if(isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["job"]) && isset($_POST["role"])) { + $user = Author::get($_GET["edit_user"]); + $user->setUsername($_POST["username"]); + if($_POST["password"] != '') $user->setPassword($_POST["password"]); + $user->setRole($_POST["role"]); + $user->setJob($_POST["job"]); + $user->setLinkedin($_POST["linkedin"]); + Author::update($user); + header("Location: /"); + } + return file_get_contents(DIR."/html/user_edit.html"); + } + /** * @route /\/users\/[0-9]+\/delete\/$/ * @admin diff --git a/assets/php/Tags/AuthorTag.php b/assets/php/Tags/AuthorTag.php index b537e51..4d98a34 100644 --- a/assets/php/Tags/AuthorTag.php +++ b/assets/php/Tags/AuthorTag.php @@ -21,9 +21,18 @@ class AuthorTag extends Tag { $doc = $this->getDoc(); - $col = "get" . ucfirst($attr); + if($attr == "username") { + $txt = $doc->createElement("a"); + $txt->setAttribute("href", "https://www.linkedin.com/in/".$author->getLinkedin() . "/"); + $txt->setAttribute("target", "_blank"); + $txt->appendChild($doc->createTextNode($author->getUsername())); + } else { + $col = "get" . ucfirst($attr); + + $txt = $doc->createTextNode($author->$col()); + + } - $txt = $doc->createTextNode($author->$col()); $pok->parentNode->insertBefore($txt, $pok); } diff --git a/assets/php/Tags/UserEditor.php b/assets/php/Tags/UserEditor.php index fcea113..b3db32f 100644 --- a/assets/php/Tags/UserEditor.php +++ b/assets/php/Tags/UserEditor.php @@ -36,6 +36,13 @@ class UserEditor extends \App\Tags\Tag { $input->setAttribute("placeholder", "Nom d'utilisateur"); $el->parentNode->insertBefore($input, $el); break; + case 'linkedin': + $input = $doc->createElement("input"); + $input->setAttribute("value", $user->getLinkedin()); + $input->setAttribute("name", "linkedin"); + $input->setAttribute("placeholder", "https://www.linkedin.com/in/ton_nom_dutilisateur/"); + $el->parentNode->insertBefore($input, $el); + break; case 'job': $input = $doc->createElement("input"); $input->setAttribute("value", $user->getJob()); diff --git a/assets/php/db/Author.php b/assets/php/db/Author.php index a8b90b4..0067e32 100644 --- a/assets/php/db/Author.php +++ b/assets/php/db/Author.php @@ -16,6 +16,8 @@ class Author { private $role = "ROLE_USER"; + private $linkedin; + public function __construct(){} public function getId() { @@ -42,6 +44,10 @@ class Author { return $this->role; } + public function getLinkedin() { + return $this->linkedin; + } + public function setId($id) { $this->id = $id; } @@ -66,6 +72,10 @@ class Author { $this->role = $role; } + public function setLinkedin($linkedin) { + $this->linkedin = $linkedin; + } + @@ -80,6 +90,7 @@ class Author { $au->setUsername($array["username"]); $au->setHashedPassword($array["password"]); $au->setJob($array["job"]); + $au->setLinkedin($array["linkedin"]); $au->setRole($array["role"]); return $au; } @@ -113,13 +124,14 @@ class Author { } public static function add(Author $author) { - $query = "INSERT INTO users (id, username, password, job, role) - VALUES (NULL, :username, :password, :job, :role);"; + $query = "INSERT INTO users (id, username, password, job, role, linkedin) + VALUES (NULL, :username, :password, :job, :role, :linkedin);"; $username = $author->getUsername(); $password = $author->getPassword(); $job = $author->getJob(); $role = $author->getRole(); + $linkedin = $author->getLinkedin(); $pdo = Functions::connect(); $prepared = $pdo->prepare($query); @@ -127,6 +139,7 @@ class Author { $prepared->bindParam(":password", $password); $prepared->bindParam(":job", $job); $prepared->bindParam(":role", $role); + $prepared->bindParam(":linkedin", $linkedin); $prepared->execute(); // var_dump($prepared->errorInfo()); // die; @@ -139,11 +152,12 @@ class Author { } public static function update(Author $author) { - Functions::connect()->prepare("UPDATE users SET username=:username, password=:password, job=:job, role=:role WHERE id=:id")->execute(array( + Functions::connect()->prepare("UPDATE users SET username=:username, password=:password, job=:job, role=:role, linkedin=:linkedin WHERE id=:id")->execute(array( ":username" => $author->getUsername(), ":password" => $author->getPassword(), ":job" => $author->getJob(), ":role" => $author->getRole(), + ":linkedin" => $author->getLinkedin(), ":id" => $author->getId() )); } diff --git a/sql/data.sql b/sql/data.sql index 45b2e76..85398c7 100644 --- a/sql/data.sql +++ b/sql/data.sql @@ -131,6 +131,7 @@ CREATE TABLE `users` ( `username` varchar(128) DEFAULT NULL, `job` varchar(560) DEFAULT NULL, `password` varchar(60) DEFAULT NULL, + `linkedin` varchar(100) DEFAULT NULL, `role` varchar(100) NOT NULL DEFAULT 'ROLE_USER' ) ENGINE=InnoDB DEFAULT CHARSET=latin1;