<?php
/*$optres['css'][] = $path . "assets/css/custombox/custombox.min.css";
$optres['js'][] = $path . "assets/js/custombox/custombox.min.js";
$optres['css'][] = $path . "amodules/popup_banner/css/popup_banner.css";
$optres['js'][] = $path . "amodules/popup_banner/js/popup_banner.v3.js";*/

// Get All popups array
$popb_pool = $pfcache->get('popup_banner_pool');

$popb_key = 'popup_banner_' . $module_params['banner']['module_id'];
$popup_banner = $pfcache->get($popb_key);
if($popup_banner == null) {
    ob_start();
    if (!isset($cached_actions ['update_banner_views']['popup'])) {
        $cached_actions ['update_banner_views']['popup'] = array();
    }
    $cached_actions ['update_banner_views']['popup'] = array_merge($cached_actions ['update_banner_views']['popup'], array($module_params['banner']['module_id']));
    $cached_actions ['update_banner_views']['popup_catdom_id'] = (isset($catdom_id) && intval($catdom_id) > 0) ? $catdom_id : $domain_id;


    $banner_image = $path . "images/banners/" . $module_params['banner']['banner'];
    $banner_url = $module_params['banner']['url'];
    $banner_title = isset($module_params['popb_title']) ? $module_params['popb_title'] : stripslashes($module_params['banner']['title_en']);
    $banner_alt = isset($module_params['popb_alt']) ? $module_params['popb_alt'] : stripslashes($module_params['banner']['alt_en']);

    $banner_width = $module_params['banner']['width'];
    $banner_effect = (isset($module_params['popb_effect']) && trim($module_params['popb_effect']) != "") ? $module_params['popb_effect'] : 'newspaper';
    $banner_target = (isset($module_params['popb_target']) && trim($module_params['popb_target']) != "") ? $module_params['popb_target'] : '_blank';
    $banner_follow = (isset($module_params['popb_follow']) && trim($module_params['popb_follow']) != "") ? $module_params['popb_follow'] : 'follow';

    $banner_link = 'click_count.php?type=banner&amp;id=' . $module_params['banner']['module_id'] . '&amp;domain_id=' . $domain_id . '&amp;location=popup';

    ?>

    <div id="popup-banner" class="popb" data-width="<?= $banner_width; ?>" data-effect="<?= $banner_effect; ?>">
        <a href="#" class="popb-close">
            <span class="popb-sr-only">Close</span>
        </a>
        <?php
        if($banner_title != "") {
            ?>
            <h4 class="popb-header"><?= $banner_title; ?></h4>
            <?php
        }
        ?>

        <div class="popb-content">
            <a href="<?= $banner_link; ?>" title="<?= $banner_alt; ?>"
               target="<?= $banner_target ?>" <?php echo ($banner_follow != "follow") ? 'rel="nofollow"' : ''; ?>
               onclick="Custombox.close();">
                <img src="<?= $banner_image; ?>" class="popb-banner">
            </a>
        </div>
    </div>

    <?php

    $popup_banner_code = ob_get_contents();
    $popup_banner = array(
        'params' => $module_params,
        'code'   => $popup_banner_code
    );
    $pfcache->set($popb_key, $popup_banner, $pfcache_ttl);
    if($popb_pool == null) {
        $popb_pool = array(
            'sitewide' => null
        );
    }
    if($module_params['popb_sitewide'] == 1) {
        // Set this one as sitewide
        $popb_pool['sitewide'] = $popb_key;
    }
    $popb_pool [$cached_key_page] = $popb_key;
    $pfcache->set('popup_banner_pool', $popb_pool, $pfcache_ttl);

    ob_end_clean();
}
unset($module_params);
