<?php
    $eventsList = $events->getCollection();
?> 
<?php foreach($eventsList as $event): ?>
    <?php
        $areaClass = getAreaColorClass($event->area->title);
        $eventDates = $event->eventDates;
        try{
        $datesDescriptionAttribute = getDatesDescriptionAttribute($eventDates, $event->hide_month, $event->hide_day);
        }catch(Exception $e){
            print_r($event->id);
            die;
        }
        $datesDescriptionAttributeYear = $datesDescriptionAttribute['dateDescYear'];
        $datesDescriptionAttribute = $datesDescriptionAttribute['dateDesc'];
    ?>
    <?php if($event->event_type === 'text'): ?>
        <div class='js-modal element element-medium <?php echo $areaClass; ?> element-<?php echo $event->event_type; ?>' data-id ='<?php echo $event->id; ?>' data-groups='["<?php echo $event->event_type; ?>"]'>
            <div class='content'>
                <?php
                $areaSign = getAreaIcon($event->area->title);
                ?>
                <div class='theme-sign'>
                    <img class='inject-me' src='<?php echo Config::get('path.frontend.img'); ?>/icons/<?php echo $areaSign; ?>.svg'>
                </div>
                <div class='information'>
                    <?php
                        $engMonthName = $event->start_date->format('F');
                        $ptMonthName = getPortugueseMonthName($engMonthName);
                    ?>
                    <h4><?php echo $datesDescriptionAttribute; ?></h4>
                    <h3><?php echo $datesDescriptionAttributeYear; ?></h3>
                    <p><?php echo mb_substr($event->content, 0, 100); ?>...</p>
                    <div class='share'>
                        <img src='<?php echo Config::get('path.frontend.img'); ?>/icons/share-crop.svg'>
                    </div>
                </div>
            </div>
        </div>
    <?php elseif($event->event_type === 'video'): ?>
        <div class='js-modal element element-big <?php echo $areaClass; ?> element-<?php echo $event->event_type; ?>' data-id ='<?php echo $event->id; ?>' data-groups='["<?php echo $event->event_type; ?>"]'>
            <div class='media media-image'>
                    <img class='play' src='<?php echo Config::get('path.frontend.img'); ?>/timeline/arrow-play.png'>
                    <?php if(!empty($event->image->filename)): ?>
                    <img class='main-image' src='<?php echo getMediaUrl($event->image->filename, '620'); ?>'>
                    <?php endif; ?>
            </div>
            <div class='content'>
                <?php
                $areaSign = getAreaIcon($event->area->title);
                ?>
                <div class='theme-sign'>
                    <img class='inject-me' src='<?php echo Config::get('path.frontend.img'); ?>/icons/<?php echo $areaSign; ?>.svg'>
                </div>
                <div class='information'>
                    <?php
                        $engMonthName = $event->start_date->format('F');
                        $ptMonthName = getPortugueseMonthName($engMonthName);
                    ?>
                    <h4><?php echo $datesDescriptionAttribute; ?></h4>
                    <h3><?php echo $datesDescriptionAttributeYear; ?></h3>
                    <p><?php echo mb_substr($event->content, 0, 100); ?>...</p>
                    <div class='share'>
                        <img src='<?php echo Config::get('path.frontend.img'); ?>/icons/share-crop.svg'>
                    </div>
                </div>
            </div>
        </div>
    <?php elseif($event->event_type === 'audio'): ?>
        <div class='js-modal element element-medium <?php echo $areaClass; ?> element-<?php echo $event->event_type; ?>' data-id ='<?php echo $event->id; ?>' data-groups='["<?php echo $event->event_type; ?>"]'>
            <div class='media media-audio'>
                <img class='main-image' src='<?php echo Config::get('path.frontend.img'); ?>/icons/audio-bars.svg'>
                <img class='play' src='<?php echo Config::get('path.frontend.img'); ?>/icons/play-rounded.svg'>
            </div>
            <div class='content'>
                <?php
                $areaSign = getAreaIcon($event->area->title);
                ?>
                <div class='theme-sign'>
                    <img class='inject-me' src='<?php echo Config::get('path.frontend.img'); ?>/icons/<?php echo $areaSign; ?>.svg'>
                </div>
                <div class='information'>
                    <?php
                        $engMonthName = $event->start_date->format('F');
                        $ptMonthName = getPortugueseMonthName($engMonthName);
                    ?>
                    <h4><?php echo $datesDescriptionAttribute; ?></h4>
                    <h3><?php echo $datesDescriptionAttributeYear; ?></h3>
                    <p><?php echo mb_substr($event->content, 0, 100); ?>...</p>
                    <div class='share'>
                        <img src='<?php echo Config::get('path.frontend.img'); ?>/icons/share-crop.svg'>
                    </div>
                </div>
            </div>
        </div>
    <?php else: ?>
        <div class='js-modal element element-big <?php echo $areaClass; ?> element-<?php echo $event->event_type; ?>' data-id ='<?php echo $event->id; ?>' data-groups='["<?php echo $event->event_type; ?>"]'>
            <div class='media media-image'>
                <?php if(!empty($event->image->filename)): ?>
                <img class='main-image' src='<?php echo getMediaUrl($event->image->filename, '620'); ?>'>
                <?php elseif(!empty($event->eventMedias) && sizeof($event->eventMedias) > 0): ?>
                    <?php if(!empty(getMediaByID($event->eventMedias[0]))): ?>
                        <img class='main-image' src='<?php echo getMediaByID($event->eventMedias[0]->media_image_id); ?>'>
                    <?php endif; ?>
                <?php endif; ?>
            </div>
            <div class='content'>
                <?php
                $areaSign = getAreaIcon($event->area->title);
                ?>
                <div class='theme-sign'>
                    <img class='inject-me' src='<?php echo Config::get('path.frontend.img'); ?>/icons/<?php echo $areaSign; ?>.svg'>
                </div>
                <div class='information'>
                    <?php
                        $engMonthName = $event->start_date->format('F');
                        $ptMonthName = getPortugueseMonthName($engMonthName);
                    ?>
                    <h4><?php echo $datesDescriptionAttribute; ?></h4>
                    <h3><?php echo $datesDescriptionAttributeYear; ?></h3>
                    <p><?php echo mb_substr($event->content, 0, 100); ?>...</p>
                    <div class='share'>
                        <img src='<?php echo Config::get('path.frontend.img'); ?>/icons/share-crop.svg'>
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?>
<?php endforeach; ?>