<?php /* Template Name: Page — Accueil */ ?>

<?php

    while ( have_posts() ) : the_post();
        $pageData['header_video'] = get_field('header_video');
        $pageData['header_mobile'] = get_field('header_mobile');
        $pageData['header_popin'] = get_field('header_popin');
        $pageData['header_title'] = get_field('header_title');
        $pageData['header_content'] = get_field('header_content');
        $pageData['header_button'] = get_field('header_button');

        $pageData['news_surtitle'] = get_field('news_surtitle');
        $pageData['news_title'] = get_field('news_title');
        $pageData['news_link'] = get_field('news_link');
        $pageData['news_gallery'] = get_field('news_gallery');
        if ($pageData['news_gallery']) {
            shuffle($pageData['news_gallery']);
        }
        $pageData['news_max'] = get_field('news_max');
        $pageData['news_count'] = pll_count_posts(pll_current_language(), ['post_type' => 'post']);
        $articlesQuery = new WP_Query(array(
            'post_type' => 'post',
            'posts_per_page' => $pageData['news_max'] ? $pageData['news_max'] : 4,
            'orderby' => 'publishDate',
            'meta_key' => 'publishDate',
            'order' => 'desc',
            'post_status' => 'publish'
        ));
        $pageData['news_list'] = $articlesQuery->posts;

        $pageData['webi_visible'] = get_field('webi_visible');
        $pageData['webi_intro'] = get_field('webi_intro');
        $pageData['webi_content'] = get_field('webi_content');

        $pageData['cabinet_surtitle'] = get_field('cabinet_surtitle');
        $pageData['cabinet_title'] = get_field('cabinet_title');
        $pageData['cabinet_link'] = get_field('cabinet_link');
        $pageData['cabinet_offices'] = get_field('cabinet_offices');
        $pageData['cabinet_quote'] = get_field('cabinet_quote');
        $pageData['cabinet_quoteSource'] = get_field('cabinet_quoteSource');
        $pageData['cabinet_content_title'] = get_field('cabinet_content_title');
        $pageData['cabinet_content_intro'] = get_field('cabinet_content_intro');
        $pageData['cabinet_content_text'] = get_field('cabinet_content_text');
        $pageData['cabinet_anchors'] = get_field('cabinet_anchors');

        $pageData['expertises_surtitle'] = get_field('expertises_surtitle');
        $pageData['expertises_titles'] = get_field('expertises_titles');
        $pageData['expertises_link'] = get_field('expertises_link');
        $pageData['expertises_intro'] = get_field('expertises_intro');
        $pageData['expertises_content'] = get_field('expertises_content');
        $pageData['expertises_list'] = get_field('expertises_list');

        $pageData['webinar_surtitle'] = get_field('webinar_surtitle');
        $pageData['webinar_title'] = get_field('webinar_title');
        $pageData['webinar_content_1'] = get_field('webinar_content_1');
        $pageData['webinar_content_2'] = get_field('webinar_content_2');
        $pageData['webinar_link'] = get_field('webinar_link');
        $pageData['webinarData'] = $pageData['webinar_surtitle'] || $pageData['webinar_title'] || $pageData['webinar_content_1'] || $pageData['webinar_content_2'] || $pageData['webinar_link'];

    endwhile;

    get_header();
    include('layouts/homepage.php');
    get_footer();

?>