From 933841bc53be9c7554cf028fd0195bbe8f70b726 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 28 Jan 2016 09:44:27 +0100 Subject: [PATCH 1/3] typo --- lib/project.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/project.php b/lib/project.php index 5d6710a..c3d7eb1 100644 --- a/lib/project.php +++ b/lib/project.php @@ -4,7 +4,7 @@ * Retourne une liste de projets en fonction d'une pagination * * @param int $page La page courrante - * @param int $limit Nombre de projet par page + * @param int $limit Nombre de projets par page * @return array Les projets */ function getProjects($page = 1, $limit = 5) @@ -79,7 +79,7 @@ function getProjectNumberOfPages($maxPerPage) * Returne les commentaires d'un projet * * @param int $id L'id du projet - * @return array Les commentaire du projet + * @return array Les commentaires du projet */ function getCommentsByProject($id) { From cbdfeb6a6c55112af32f226c154a361be0950b36 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 28 Jan 2016 09:59:32 +0100 Subject: [PATCH 2/3] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 226d711..c6afced 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Un commentaire est composé de : La date est générée automatiquement. Tous les champs sont obligatoires à l'exception du site web. -Il faudra afficher l'avatar de l'auteur en utilisant le service [gravatar](https://fr.gravatar.com/site/implement/images/php/). *Ne pas réutiliser ce code source merci ne vous génez par pour vous en inspirer.* +Il faudra afficher l'avatar de l'auteur en utilisant le service [gravatar](https://fr.gravatar.com/site/implement/images/php/). *Ne pas réutiliser ce code source mais ne vous génez par pour vous en inspirer.* Flux ---- From a72c8a0376892967317bee74dbd5493389301915 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 28 Jan 2016 10:26:50 +0100 Subject: [PATCH 3/3] pager --- index.php | 31 ++++++++++++++++++++++------- lib/project.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ style.css | 13 ++++++++++++ 3 files changed, 90 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index d7b14a0..d0d420f 100644 --- a/index.php +++ b/index.php @@ -18,6 +18,7 @@ if ($page > $numberOfPages) { } $projects = getProjects($page, $limit); +$pager = getProjectsPager($page, $numberOfPages); ?> @@ -31,6 +32,18 @@ $projects = getProjects($page, $limit);

Mon super portfolio

+ + 1): ?> +
    + +
  • class="active"> + + + +
  • + +
+
@@ -60,12 +73,16 @@ $projects = getProjects($page, $limit);
- + 1): ?> +
    + +
  • class="active"> + + + +
  • + +
+ diff --git a/lib/project.php b/lib/project.php index c3d7eb1..e8ca80d 100644 --- a/lib/project.php +++ b/lib/project.php @@ -87,3 +87,56 @@ function getCommentsByProject($id) } // Prévoir une fonction pour enregistrer un commentaire + +function getProjectsPager($page, $numberOfPages) +{ + $pages = []; + + if ($numberOfPages > 1) { + $pages[] = array( + 'title' => 'Première page', + 'page' => 1, + 'current' => $page === 1, + ); + } + + if ($page > 1) { + $pages[] = array( + 'title' => 'Précédent', + 'page' => $page - 1, + 'current' => false, + ); + } + + if ($numberOfPages > 1) { + for ($i = 1; $i <= $numberOfPages; $i++) { + $pages[] = array( + 'title' => $i, + 'page' => $i, + 'current' => $page === $i, + ); + } + } + + if ($page < $numberOfPages) { + $pages[] = array( + 'title' => 'Suivant', + 'page' => $page + 1, + 'current' => false, + ); + } + + if ($numberOfPages > 1) { + $pages[] = array( + 'title' => 'Dernière page', + 'page' => $numberOfPages, + 'current' => $page === $numberOfPages, + ); + } + + return $pages; +} + + + + diff --git a/style.css b/style.css index 39e0bb1..61d4ff6 100644 --- a/style.css +++ b/style.css @@ -32,3 +32,16 @@ figure { .description { padding-left: 150px; } + +.pager li { + display: inline; +} + +.pager .active { + font-weight: bold; +} + +.pager a { + text-decoration: none; + color: #000; +}