Commit c8aa8f53 authored by Julie gauthier's avatar Julie gauthier

Merge branch '19-implementer-liste-des-adherents-dans-le-projet-vagrant' into 'master'

Resolve "Implémenter liste des adhérents dans le projet Vagrant"

Closes #19

See merge request !13
parents 8cddb1cb 2f4e01f9
<?php
//nombre max d'adhérents par page
$maxMembersPerPage = 20;
//nombre de membres à afficher par ligne
$maxMembersPerLine = 3;
$page = 1;
$order = "asc";
$link = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER["REDIRECT_URL"];
$pagination = true;
get_header();
//on vérifie bien le numéro de la page
if (isset($_GET["page"])) {
if (is_numeric($_GET["page"])) {
if (($_GET["page"] > 0) && ($_GET["page"] < 100)) {
$page = $_GET["page"];
}
}
}
//on vérifie bien l'ordre donné
if (isset($_GET["order"])) {
if ($_GET["order"] == "desc") {
$order = "desc";
}
}
get_header();
$min_member_numero = 1 + ($page * $maxMembersPerPage) - $maxMembersPerPage;
$max_member_numero = ($page * $maxMembersPerPage);
?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<ul>
<?php
global $post; //variable wp
$order = "asc";
<main id="main" class="site-main" role="main">
<div id="adullact-sort-buttons">
<div id="adullact-sort-by-type-buttons">
<ul class="adullact-member-list">
<?php
global $post; //variable wp
$url = explode("/", $_SERVER["REDIRECT_URL"]);
//on récup le nom de la catégorie de l'url
$category = explode("/", $_SERVER['REQUEST_URI'])[2];
//nombre de mots dans l'url, sert à déterminer la catégorie recherchée
$number_of_words = count($url);
if ($url[$number_of_words - 1] == "") {
unset($url[$number_of_words - 1]);
$url = array_values($url);
$number_of_words -= 1;
}
$category = $url[$number_of_words - 1];
childrens_of_member_category($category);
?>
</ul>
</div>
<div id="adullact-sort-by-name">
<ul class="adullact-member-list">
<?php sort_page($order, $page, $link) ?>
</ul>
</div>
</div>
<?php echo "<div class='adullact-members-list'>";
$args = array('posts_per_page' => -1, 'offset' => "0", 'category_name' => $category, 'orderby' => 'title', 'order' => $order);
$myposts = get_posts($args);
//on récup le tri croissant / décroissant
if (isset($_GET["order"])) {
$order = $_GET["order"];
$number_of_total_posts = count($myposts); //pour les pages
if (($number_of_total_posts == 0) || ($number_of_total_posts < $min_member_numero)) {
echo "<h3>Aucun résultat.</h3>";
$pagination = false;
} else {
$counter = 1;
foreach ($myposts as $post) : setup_postdata($post);
if ($counter >= $min_member_numero) {
if ($counter <= $max_member_numero) {
$id = get_the_id();
$url = get_metadata("post", $id, "project_url")[0];
if ($order != "asc" && $order != "desc") {
$order = "asc";
?>
<div class="adullact-member">
<div>
<a href="<?php echo $url; ?>" target="_blank">
<?php the_post_thumbnail(array("200", "200")); ?> <br>
</a>
</div>
<p><?php the_title(); ?></p><br>
</div>
<?php
} else {
//on a dépassé le nombre max d'adhérents à afficher, on peut donc stopper la boucle car elle n'affichera plus rien.
break;
}
}
$args = array('posts_per_page' => 10, 'offset' => 0, 'category_name' => $category, 'orderby' => 'title', 'order' => $order);
$counter += 1;
endforeach;
echo "</div></div>";
wp_reset_postdata();
}
$myposts = get_posts($args);
echo "<br>";
if ($pagination) {
?>
<div class="pagination">
<?php
$count = 0; //va servir pour les retour à la ligne lorsqu'on a affiché le max d'éléments par ligne
childrens_of_member_category("$category");
$number_of_pages_to_generate = intdiv($number_of_total_posts, $maxMembersPerPage);
$reste = $number_of_total_posts % $maxMembersPerPage;
echo "<div class='adullact-members-list'>";
if ($reste > 0) {
$number_of_pages_to_generate += 1;
}
echo "<div class='adullact-line'>";
foreach ($myposts as $post) : setup_postdata($post);
$id = get_the_id();
$url = get_metadata("post", $id, "project_url")[0];
$count += 1;
for ($i = 1; $i <= $number_of_pages_to_generate; $i++) {
$page_link = $link . "?page=" . $i . "&order=" . $order;
$link_class = "adullact-page-link";
if ($page == $i) {
$link_class .= " adullact-page-link-selected";
}
?>
<a href="<?php echo $url; ?>" target="_blank" class="adullact-member">
<?php the_post_thumbnail(array("200", "200")); ?> <br>
<?php the_title(); ?> <br>
<?php the_tags($before = ''); ?>
</a>
<a href="<?php echo $page_link ?>" class="<?php echo $link_class ?>"><?php echo $i ?></a>
<?php
if ($count >= $maxMembersPerLine) {
$count = 0;
echo "</div>";
echo "<div class='adullact-line'>";
}
endforeach;
echo "</div></div>";
wp_reset_postdata(); ?>
</ul>
</main>
</div>
}
?>
</div>
<?php } ?>
</main>
</div>
<?php get_footer(); ?>
\ No newline at end of file
<?php
$themes_path = get_theme_root();
$theme_name = "/theme-wordpress-adullact-org";
$file_path = $themes_path . $theme_name . "/category-adherent.php";
//nombre de membres à afficher par ligne
$maxMembersPerLine = 3;
include $file_path;
get_header();
?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<ul>
<?php
global $post; //variable wp
$order = "asc";
//on récup le nom de la catégorie de l'url
$category = explode("/", $_SERVER['REQUEST_URI'])[2];
//on récup le tri croissant / décroissant
if (isset($_GET["order"])) {
$order = $_GET["order"];
if ($order != "asc" && $order != "desc") {
$order = "asc";
}
}
$args = array('posts_per_page' => 10, 'offset' => 0, 'category_name' => $category, 'orderby' => 'title', 'order' => $order);
$myposts = get_posts($args);
echo "<br>";
$count = 0; //va servir pour les retour à la ligne lorsqu'on a affiché le max d'éléments par ligne
childrens_of_member_category("$category");
echo "<div class='adullact-members-list'>";
echo "<div class='adullact-line'>";
foreach ($myposts as $post) : setup_postdata($post);
$id = get_the_id();
$url = get_metadata("post", $id, "project_url")[0];
$count += 1;
?>
<a href="<?php echo $url; ?>" target="_blank" class="adullact-member">
<?php the_post_thumbnail(array("200", "200")); ?> <br>
<?php the_title(); ?> <br>
<?php the_tags($before = ''); ?>
</a>
<?php
if ($count >= $maxMembersPerLine) {
$count = 0;
echo "</div>";
echo "<div class='adullact-line'>";
}
endforeach;
echo "</div></div>";
wp_reset_postdata(); ?>
</ul>
</main>
</div>
</div>
<?php get_footer(); ?>
\ No newline at end of file
<?php
$themes_path = get_theme_root();
$theme_name = "/theme-wordpress-adullact-org";
$file_path = $themes_path . $theme_name . "/category-adherent.php";
include $file_path;
<?php
$themes_path = get_theme_root();
$theme_name = "/theme-wordpress-adullact-org";
$file_path = $themes_path . $theme_name . "/category-adherent.php";
include $file_path;
<?php
$themes_path = get_theme_root();
$theme_name = "/theme-wordpress-adullact-org";
$file_path = $themes_path . $theme_name . "/category-adherent.php";
include $file_path;
<?php
$themes_path = get_theme_root();
$theme_name = "/theme-wordpress-adullact-org";
$file_path = $themes_path . $theme_name . "/category-adherent.php";
include $file_path;
<?php
$themes_path = get_theme_root();
$theme_name = "/theme-wordpress-adullact-org";
$file_path = $themes_path . $theme_name . "/category-adherent.php";
include $file_path;
<?php
$themes_path = get_theme_root();
$theme_name = "/theme-wordpress-adullact-org";
$file_path = $themes_path . $theme_name . "/category-adherent.php";
//nombre de membres à afficher par ligne
$maxMembersPerLine = 3;
include $file_path;
get_header();
?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<ul>
<?php
global $post; //variable wp
$order = "asc";
//on récup le nom de la catégorie de l'url
$category = explode("/", $_SERVER['REQUEST_URI'])[2];
//on récup le tri croissant / décroissant
if (isset($_GET["order"])) {
$order = $_GET["order"];
if ($order != "asc" && $order != "desc") {
$order = "asc";
}
}
$args = array('posts_per_page' => 10, 'offset' => 0, 'category_name' => $category, 'orderby' => 'title', 'order' => $order);
$myposts = get_posts($args);
echo "<br>";
$count = 0; //va servir pour les retour à la ligne lorsqu'on a affiché le max d'éléments par ligne
childrens_of_member_category("$category");
echo "<div class='adullact-members-list'>";
echo "<div class='adullact-line'>";
foreach ($myposts as $post) : setup_postdata($post);
$id = get_the_id();
$url = get_metadata("post", $id, "project_url")[0];
$count += 1;
?>
<a href="<?php echo $url; ?>" target="_blank" class="adullact-member">
<?php the_post_thumbnail(array("200", "200")); ?> <br>
<?php the_title(); ?> <br>
<?php the_tags($before = ''); ?>
</a>
<?php
if ($count >= $maxMembersPerLine) {
$count = 0;
echo "</div>";
echo "<div class='adullact-line'>";
}
endforeach;
echo "</div></div>";
wp_reset_postdata(); ?>
</ul>
</main>
</div>
</div>
<?php get_footer(); ?>
\ No newline at end of file
......@@ -4,66 +4,106 @@ add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
function my_theme_enqueue_styles()
{
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
}
$debug_functions = false;
function echo_debug($words)
{
//si mode debug activé, on affiche les informations demandées
global $debug_functions;
if ($debug_functions) {
echo $words;
}
}
function dump_debug($list)
{
//si mode debug activé, on affiche le var dump demandé
global $debug_functions;
if ($debug_functions) {
var_dump($list);
}
}
function childrens_of_member_category($category)
function childrens_of_member_category($category_to_select)
{
//cette fonction affiche la liste des catégories enfants de la catégorie mère Adhérent
$childrens = get_term_children(21, "category"); //contiendra les id de tous les enfants de adhérent
$member_category_object = get_category_by_slug("adherent");
if ($category == "Adhérent" || $category == "") {
echo " <a href='?cat=21' class='adullact-sort-button adullact-selected'>Tout</a>";
$id = $member_category_object->cat_ID;
$server_link = $_SERVER["SERVER_NAME"];
$link_Category = "http://" . $server_link . "/category/";
$current_category = $category_to_select;
dump_debug($_SERVER);
echo_debug("\n----------------------\n");
dump_debug($member_category_object);
//SERVER_NAME
$childrens = get_term_children($id, "category"); //contiendra les id de tous les enfants de adhérent
if ($current_category == "adherent" || $current_category == "") {
echo " <li class='adullact-sort-button adullact-selected'><a href='" . $link_Category . "adherent/'>Tout</a></li>";
} else {
echo " <a href='?cat=21' class='adullact-sort-button'>Tout</a>";
echo " <li class='adullact-sort-button'><a href='" . $link_Category . "adherent/'>Tout</a></li>";
}
foreach ($childrens as $c) {
$temp_category = get_category($c); //objet contenant les infos de la catégorie enfant
$my_link = "<a href=\"?cat=";
$my_link .= $c;
$my_link .= "\" class=\"adullact-sort-button";
$my_link = "<li class='adullact-sort-button";
if ($temp_category->name == $category) {
if ($temp_category->slug == $category_to_select) {
//si on est en train d'afficher la catégorie sélectionnée
$my_link .= " adullact-selected";
} else {
echo_debug($temp_category->slug . "=/=" . $category_to_select);
}
$my_link .= "'><a href = \"http://" . $server_link . "/category/";
$my_link .= $temp_category->slug;
$my_link .= "\"";
$my_link .= "\">";
$my_link .= $temp_category->name;
$my_link .= "</a>";
$my_link .= "</a></li>";
echo $my_link;
}
sort_page();
}
function sort_page()
function sort_page($order, $page,$link)
{
$link = $_SERVER['REQUEST_URI'];
$cleanLink = explode("&order", $link)[0];
if (strpos($link, "order=desc")) {
$for_asc_link = $link . "?page=" . $page . "&order=asc";
$for_desc_link = $link . "?page=" . $page . "&order=desc";
if ($order == "desc") {
?>
<a href="<?php echo $cleanLink; ?>&order=asc" class="adullact-sort-button">
Croissant
</a>
<a href="<?php echo $cleanLink; ?>&order=desc" class="adullact-sort-button adullact-selected">
Décroissant
</a>
<li class="adullact-sort-button">
<a href="<?php echo $for_asc_link; ?>">
Croissant
</a>
</li>
<li class="adullact-sort-button adullact-selected">
<a href="<?php echo $for_desc_link; ?>">
Décroissant
</a>
</li>
<?php
} else {
?>
<a href="<?php echo $cleanLink; ?>&order=asc" class="adullact-sort-button adullact-selected">
Croissant
</a>
<a href="<?php echo $cleanLink; ?>&order=desc" class="adullact-sort-button">
Décroissant
</a>
<li class="adullact-sort-button adullact-selected">
<a href="<?php echo $for_asc_link; ?>">
Croissant
</a>
</li>
<li class="adullact-sort-button">
<a href="<?php echo $for_desc_link; ?>">
Décroissant
</a>
</li>
<?php
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -8,10 +8,36 @@
Version: 0.8
*/
/*************************************************************/
/*classes wordpress*/
/*************************************************************/
@media screen and ( min-width: 67em ) {
.wrap {
max-width: 1200px;
padding: 28px;
}
.navigation-top .wrap {
max-width: 1200px;
}
}
/*************************************************************/
/*Liste des adhérents*/
/*************************************************************/
#adullact-sort-buttons {
display: flex;
flex-direction: row;
}
.adullact-members-list {
display: flex;
flex-direction: column;
flex-direction: row;
margin-top: 30px;
flex-wrap: wrap;
justify-content: flex-start;
}
.adullact-line {
......@@ -21,29 +47,114 @@
}
.adullact-member {
max-width: 200px;
word-wrap: break-spaces;
text-align: center;
margin: 10px;
padding: 0;
text-align: center
}
.adullact-sort-button {
padding: 5px;
.adullact-member a {
width: 190px;
height: 190px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 2px solid aliceblue;
transition: border 0.2s ease;
}
.adullact-member a:hover {
border: 2px solid #4891bf;
}
.adullact-member img {
max-height: 180px;
max-width: 180px;
margin: 5px;
}
.adullact-member p {
padding: 10px;
border-bottom: 1px solid aliceblue;
margin: 0;
max-width: 190px;
}
.adullact-sort-button {
border-radius: 3px;
border: 1px solid grey;
color: grey;
margin: 7px;
transition: background-color 0.2s ease;
}
.adullact-sort-button:hover {
background-color: lightgrey;
color: red;
}
.adullact-sort-button a {
transition: color 0.2s ease;
color: grey;
padding: 5px;
display: block;
border-radius: 2px;
}
.adullact-sort-button a:hover {
color: dimgrey;
}
.adullact-selected {
color: black;
border: 1px solid black;
color: white;
border: 1px solid #4891bf;
background-color: #4891bf;
}
.adullact-required {
color: red;
.adullact-selected:hover {
background-color: #3f7ca2;
border: 1px solid #3f7ca2;
}
.adullact-selected a:hover {
color: white;
}
.adullact-selected a {
color: white;
}
.adullact-member-list {
list-style: none;
}
.adullact-member-list li {
display: inline-block;
margin: 7px;
}
#adullact-sort-by-type-buttons {
width: 70%;
}
#adullact-sort-by-name {
padding-left: 2%;
}
.adullact-page-link {
padding: 8px 12px;
background-color: aliceblue;
margin: 3px;
}
.adullact-page-link-selected {
background-color: #4891bf;
}
/*************************************************************/
/*Formulaire d'adhésion*/
/*************************************************************/
#adullact-membership-form h3 {
margin-top: 20px;
margin-bottom: 20px;
......@@ -61,4 +172,8 @@
#periodeAdhesionCollectivite {
width: 220px;
margin-bottom: 20px;
}
.adullact-required {
color: red;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment