Exemple #1
0
/**
 * We should form twigmo links for internal pages
 * @param string $url
 * @param string $target
 * @param string $type
 * @param int $banner_id
 */
function fn_twg_get_banner_onclick($url, $target, $type, $banner_id)
{
    $onclick = array();
    if ($target == 'T' and !empty($url) and $type == 'G') {
        $url = fn_twg_get_banner_url($banner_id, $url);
        $onclick = fn_twg_get_twigmo_onclick($url);
    }
    return $onclick;
}
Exemple #2
0
/**
 * We should form twigmo links for internal pages
 * @param string $url
 * @param string $target
 * @param string $type
 * @param int $banner_id
 */
function fn_twg_get_banner_onclick($url, $target, $type, $banner_id)
{
    $onclick = array();
    if ($target == 'T' and !empty($url) and $type == 'G') {
        $url = fn_twg_get_banner_url($banner_id, $url);
        // Process SEO links
        if (Registry::get('addons.seo.status') == 'A') {
            $_SERVER['REQUEST_URI'] = $url;
            $request = array('sef_rewrite' => 1);
            $result = '';
            $area = AREA;
            $is_allowed_url = false;
            fn_seo_get_route($request, $result, $area, $is_allowed_url);
            if (!empty($request['dispatch'])) {
                $ids = array('product_id', 'page_id', 'category_id');
                foreach ($ids as $id) {
                    if (isset($request[$id])) {
                        $url = $id . '=' . $request[$id];
                        break;
                    }
                }
            }
        }
        // Only for internal links
        $twigmo_links = array(array('pattern' => '/product_id=([0-9]+)/', 'actionType' => 'product'), array('pattern' => '/page_id=([0-9]+)/', 'actionType' => 'cmsPage'), array('pattern' => '/category_id=([0-9]+)/', 'actionType' => 'category'));
        foreach ($twigmo_links as $link) {
            if (preg_match($link['pattern'], $url, $matches)) {
                $onclick = $link;
                $onclick['actionId'] = $matches[1];
                unset($onclick['pattern']);
                break;
            }
        }
    }
    return $onclick;
}