Commit 72e337a3 authored by Corentin Bettiol's avatar Corentin Bettiol 💻
Browse files

add tag system

parent 2306c5b1
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line

/*
====
CSS
*/

*{
	color: #1f1f2e;
}
@@ -65,6 +59,10 @@ h2{
	font-size: 1.5em;
	font-weight: normal;
	display: inline-block;
	max-width: 280px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

h3 a{
@@ -86,6 +84,7 @@ h3 a:hover{
	flex-direction: row;
	list-style-type: none;
	justify-content: space-around;
	flex-wrap: wrap;
}

#listMenu a{
@@ -341,6 +340,16 @@ form .small{
	text-align: right;
}

.tag{
	padding: 2px 7px;
	background-color: #ddd;
	margin: 2px;
}

.tag a{
	text-decoration: none;
}

/*
====
Media Queries
@@ -349,6 +358,7 @@ Media Queries
@media all and (max-width: 1350px){
	#header{
		justify-content: space-around;
		font-size: 0.7em;
	}
}

@@ -359,6 +369,9 @@ Media Queries
	#page{
		font-size: 1.2em;
	}
	#header{
		font-size: 1em;
	}
	#header, #title{
		padding-top: 5px;
		flex-direction: column;
@@ -388,6 +401,11 @@ Media Queries
		flex-direction: column;
		justify-content: center;
	}
	#listMenu a{
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	#listMenu li, #listMenu h2, #listMenu a{
		display: block;
		width: 90%;
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
	RewriteEngine On
	RewriteRule ^/(about|changelog|rss|projects|contact|patate|eplucher)$ /index.php?action=$1
	RewriteRule ^/rss/(blog|projets)$ /rss/$1.xml
	RewriteRule ^/tag/([-a-z0-9]+)$ /index.php?action=tags&title=$1
	RewriteRule ^/page/([0-9]+)$ /index.php?action=blog&page=$1
	RewriteRule ^/article/([-a-z0-9]+)$ /index.php?action=blog&title=$1
	RewriteRule ^/project/([-a-z0-9]+)$ /index.php?action=project&title=$1
+44 −15
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Client :  localhost:3306
-- Généré le :  Mar 19 Mars 2019 à 21:55
-- Généré le :  Mer 20 Mars 2019 à 13:12
-- Version du serveur :  5.7.25-0ubuntu0.18.04.2
-- Version de PHP :  7.2.15-0ubuntu0.18.04.1

@@ -19,6 +19,7 @@ SET time_zone = "+00:00";
--
-- Base de données :  `l3m`
--
DROP DATABASE IF EXISTS `l3m`;
CREATE DATABASE IF NOT EXISTS `l3m` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `l3m`;

@@ -38,15 +39,6 @@ CREATE TABLE `l3m_blog` (
  `shortContent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Ce billet de blog ne dispose d''aucune description.'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Vider la table avant d'insérer `l3m_blog`
--

TRUNCATE TABLE `l3m_blog`;
--
-- Contenu de la table `l3m_blog`
--

-- --------------------------------------------------------

--
@@ -63,15 +55,30 @@ CREATE TABLE `l3m_projects` (
  `shortContent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Pas de description.'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Vider la table avant d'insérer `l3m_projects`
-- Structure de la table `l3m_tag`
--

TRUNCATE TABLE `l3m_projects`;
DROP TABLE IF EXISTS `l3m_tag`;
CREATE TABLE `l3m_tag` (
  `id` int(11) NOT NULL,
  `tag` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Contenu de la table `l3m_projects`
-- Structure de la table `l3m_tag_post`
--

DROP TABLE IF EXISTS `l3m_tag_post`;
CREATE TABLE `l3m_tag_post` (
  `id` int(11) NOT NULL,
  `tag` int(11) NOT NULL,
  `post` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Index pour les tables exportées
@@ -89,6 +96,18 @@ ALTER TABLE `l3m_blog`
ALTER TABLE `l3m_projects`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `l3m_tag`
--
ALTER TABLE `l3m_tag`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `l3m_tag_post`
--
ALTER TABLE `l3m_tag_post`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT pour les tables exportées
--
@@ -97,12 +116,22 @@ ALTER TABLE `l3m_projects`
-- AUTO_INCREMENT pour la table `l3m_blog`
--
ALTER TABLE `l3m_blog`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=0;
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `l3m_projects`
--
ALTER TABLE `l3m_projects`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=0;
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `l3m_tag`
--
ALTER TABLE `l3m_tag`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `l3m_tag_post`
--
ALTER TABLE `l3m_tag_post`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+26 −14
Original line number Diff line number Diff line
@@ -7,8 +7,10 @@ require_once('site/model/AdminManager.php');
require_once('site/model/RssManager.php');

// tente de connecter l'administrateur
function loginAdminPage($pageName){
	if(password_verify($_POST['pass'], pass) && $_POST['user'] == user){
function loginAdminPage($pageName)
{
	if(password_verify($_POST['pass'], pass) && $_POST['user'] == user)
	{
		$_SESSION['user'] = user;
		header('Location:/patate');
	}
@@ -17,15 +19,19 @@ function loginAdminPage($pageName){
}

// afficher le panneau d'administration & gère l'administration du site
function writeAdminPage($pageName){
function writeAdminPage($pageName)
{
	$admin = new AdminManager();

	if($admin->verifyAdminConnect()){
		if(isset($_GET['type'])){
			switch ($_GET['type']){

	if($admin->verifyAdminConnect())
	{
		if(isset($_GET['type']))
		{
			switch ($_GET['type'])
			{
				case 'blogedit':
					if(!isset($_POST['title'])){
					if(!isset($_POST['title']))
					{
						$title = htmlspecialchars($_GET['title']);
						if($blogpost = $admin->getBlogPost($title))
							require('site/view/private/editblogView.php');
@@ -39,7 +45,8 @@ function writeAdminPage($pageName){
					break;

				case 'blogsubmit':
					if(isset($_POST['title'])){
					if(isset($_POST['title']))
					{
						$admin->sendBlogPost();
						header('Location:/patate');
					}
@@ -48,14 +55,16 @@ function writeAdminPage($pageName){
					break;

				case 'blogdelete':
					if(isset($_GET['title'])){
					if(isset($_GET['title']))
					{
						$admin->deleteBlogPost($_GET['title']);
						header('Location:/patate');
					}
					break;

				case 'projectedit':
					if(!isset($_POST['name'])){
					if(!isset($_POST['name']))
					{
						$title = urldecode($_GET['title']);
						$project = $admin->getProject($title);
						require('site/view/private/editProjectView.php');
@@ -67,7 +76,8 @@ function writeAdminPage($pageName){
					break;

				case 'projectsubmit':
					if(isset($_POST['name'])){
					if(isset($_POST['name']))
					{
						$admin->sendProject();
						header('Location:/patate');
					}
@@ -76,7 +86,8 @@ function writeAdminPage($pageName){
					break;

				case 'projectdelete':
					if(isset($_GET['title'])){
					if(isset($_GET['title']))
					{
						$admin->deleteProject($_GET['title']);
						header('Location:/patate');
					}
@@ -99,7 +110,8 @@ function writeAdminPage($pageName){
}

// déconnexion de la partie administration
function decoAdminPage(){
function decoAdminPage()
{
	$_SESSION = array();
	header('Location:/');
}
 No newline at end of file
+100 −76
Original line number Diff line number Diff line
@@ -12,13 +12,19 @@ require_once('site/model/BlogManager.php');
// classe pour la gestion des projets
require_once('site/model/ProjectsManager.php');

// classe pour la gestion des tags
require_once('site/model/TagManager.php');

// récupérer le nom de la page en fonction de l'url
// premier texte = affiché dans l'onglet (title), second texte = voir le switch dans site/layout/layout.php :
// 	c'est LA valeur utilisée pour savoir quoi faire depuis le layout
function getPageName(){
function getPageName()
{
	// si on a une url personnalisée
	if(isset($_GET['action'])){
		switch ($_GET['action']) {
	if(isset($_GET['action']))
	{
		switch ($_GET['action'])
		{
			case 'blog' : // le blog
				if(isset($_GET['page']))
					return ['Blog – page '. $_GET['page'], 'blog'];
@@ -52,19 +58,22 @@ function getPageName(){
			case 'patate': // administration
				return ['Administration', 'administration'];
				break;
			case 'tags': // voir les posts de blog avec le tag
				return ['Tag', 'tag'];
				break;
			default: // si l'argument n'est pas compris et qu'il passe les rewriterules d'apache on affiche le blog (ne devrait jamais se produire)
				return ['Blog', 'blog'];
				break;
		}
	}
	// si on est sur l'accueil du site
	else{
	else
		return ['Blog', 'blog'];
}
}

// affiche le menu du site (avec le titre de la page)
function writeMenu($pageName){
function writeMenu($pageName)
{
?>
	<input id="toggle" type="checkbox" />
	<ul id='listMenu'>
@@ -77,6 +86,9 @@ function writeMenu($pageName){
		<?php }
			if($pageName == 'changelog'){ ?>
				<li><h2><a href="/changelog" class="selected">Changelog</a></h2></li>
		<?php }
			if($pageName == 'tag'){ ?>
				<li><h2><a href="/tag/<?php echo $_GET['title']; ?>" class="selected">Tag <?php echo $_GET['title']; ?></a></h2></li>
		<?php } ?>
		<li><h2><a href="/" title="Blog" <?php if($pageName == 'blog'){ ?>class="selected"<?php } ?>>Blog</a></h2></li>
		<li><h2><a href="/about" title="À propos" <?php if($pageName == 'about'){ ?>class="selected"<?php } ?>>À propos</a></h2></li>
@@ -87,29 +99,25 @@ function writeMenu($pageName){
<?php }

// affiche la page du blog (accueil par défaut)
function writeBlogPage($pageName){
	// si on n'accède pas au fichier mais bien au site (var définie)
	if($pageName[1] == 'blog'){
		
function writeBlogPage($pageName)
{
	$blog = new BlogManager(NULL, NULL, NULL, NULL, NULL, NULL); // on a un blogmanager
		
	// si on affiche un post en particulier
		if(isset($_GET['title'])){
	if(isset($_GET['title']))
	{
		$blogpost = $blog->get($_GET['title']);
			if($blogpost != false){

		if($blogpost != false)
		{
			// articles précédent/suivant
				//$paging = $blog->pagingSingle($_GET['title']);
				//require('site/view/publie/blogPostPagingView.php')

			require('site/view/public/blogPostView.php');
		}
		else
			header('Location:/404');
	}
	// si on affiche la liste des posts
		else{

	else
	{
		$page = 1;
		if(isset($_GET['page']))
			// normalement via le rewriterule on envoie forcément un int, mais un cast ça coûte pas grand chose donc bon
@@ -124,17 +132,19 @@ function writeBlogPage($pageName){
		require('site/view/public/blogView.php');
	}
}
}

// affiche la liste des projets
function writeProjectPage($pageName){
function writeProjectPage($pageName)
{

	$project = new ProjectManager(NULL, NULL, NULL, NULL, NULL); // on a un projectmanager

	// si on affiche un projet en particulier
	if(isset($_GET['title'])){
	if(isset($_GET['title']))
	{
		$project = $project->get($_GET['title']);
		if($project != false){
		if($project != false)
		{
			require('site/view/public/projectView.php');
		}
		else
@@ -146,3 +156,17 @@ function writeProjectPage($pageName){
		require('site/view/public/projectsView.php');
	}
}

// affiche la liste des posts de blog avec le tag correspondant
function writeTagPage($pageName){
	$blog = new BlogManager(NULL, NULL, NULL, NULL, NULL, NULL); // on a un blogmanager

	// liste des articles avec le tag
	if(isset($_GET['title']))
	{
		$blogposts = $blog->getTag($_GET['title']);
		require('site/view/public/blogView.php');
	}
	else
		header("Location:/");
}
 No newline at end of file
Loading