/**  
 * 广告位显示
 * @param array $args 广告位信息
 * @return string
 */
function advLayout($args)
{
    list($id, $count, $target) = explode(',', $args);
    unset($args);
    $ap = getAdvPosition($id, $count, $target);
    if (empty($ap)) {
        return '';
    }
    $style = $ap['style'];
    unset($ap['style']);
    $cache_key = 'adv_position/' . $ap['id'];
    if ($ap['is_flash'] == 1 && !empty($ap['flash_style'])) {
        $args['adv_path'] = "./public/adflash/" . $ap['flash_style'] . ".swf";
        $args['adv_pics'] = "";
        $args['adv_texts'] = "";
        $args['adv_links'] = "";
        $jg = '';
        foreach ($ap['adv_list'] as $adv) {
            $args['adv_pics'] .= $jg . $adv['code'];
            $args['adv_texts'] .= $jg . $adv['desc'];
            $args['adv_links'] .= $jg . $adv['url'];
            $jg = "|";
        }
        unset($ap['adv_list']);
        $args['adv_position'] = $ap;
    } else {
        $args['adv_list'] = $ap['adv_list'];
    }
    unset($ap);
    return tplString($style, $cache_key, $args);
}
/**
 * 显示指定名称的广告位布局
 * @param string $id 布局编号
 * @param int $count 显示数量
 * @param string $target 关键字
 * @return array
 */
function getAdvLayout($id, $count = '', $target = '')
{
    global $_FANWE;
    $layout = FDB::fetchFirst('SELECT rec_id AS pid,item_limit AS acount,target_id AS target FROM ' . FDB::table('layout') . " WHERE layout_id ='{$id}' AND tmpl = '" . $_FANWE['setting']['site_tmpl'] . "' AND rec_module = 'AdvPosition'");
    if (!$layout) {
        return '';
    }
    if ($count != '') {
        $layout['acount'] = intval($count);
    }
    if ($target != '') {
        $layout['target'] = explode(',', $target);
    }
    return getAdvPosition($layout['pid'], $layout['acount'], $layout['target']);
}
Exemplo n.º 3
0
function advLayoutName($args)
{
    list($name, $tmpl, $target) = explode(',', $args);
    unset($args);
    $sql = "SELECT `id`,`rec_id`,`item_limit`,`target_id` FROM " . FDB::table("adv_layout") . " where `layout_id`='{$name}' and `tmpl` ='" . TMPL . "' ";
    $rs = FDB::fetchFirst($sql);
    if (!$rs) {
        return "";
    }
    if ($target) {
        $rs['target_id'] = $target;
    }
    $ap = getAdvPosition($rs['rec_id'], $rs['item_limit'], $rs['target_id']);
    if (empty($ap)) {
        return '';
    }
    if ($tmpl) {
        $tmpl_path = FANWE_ROOT . './tpl/' . TMPL . "/" . $tmpl . ".htm";
        $style = @file_get_contents($tmpl_path);
    } else {
        $style = $ap['style'];
    }
    unset($ap['style']);
    $cache_key = 'adv_position/' . $ap['id'];
    if ($ap['is_flash'] == 1 && !empty($ap['flash_style'])) {
        $args['adv_path'] = "./public/adflash/" . $ap['flash_style'] . ".swf";
        $args['adv_pics'] = "";
        $args['adv_texts'] = "";
        $args['adv_links'] = "";
        $jg = '';
        foreach ($ap['adv_list'] as $adv) {
            $args['adv_pics'] .= $jg . $adv['code'];
            $args['adv_texts'] .= $jg . $adv['desc'];
            $args['adv_links'] .= $jg . $adv['url'];
            $jg = "|";
        }
        unset($ap['adv_list']);
        $args['adv_position'] = $ap;
    } else {
        $args['adv_list'] = $ap['adv_list'];
    }
    unset($ap);
    return tplString($style, $cache_key, $args);
}