function fn_settings_actions_addons_banners_banner_multilang($new_value, $old_value)
{
    if ($new_value == 'N') {
        $lang_codes = Languages::getAll();
        unset($lang_codes[DEFAULT_LANGUAGE]);
        $banners_multilang = array();
        foreach ($lang_codes as $lang_code => $lang_data) {
            list($banners) = fn_get_banners(array(), $lang_code);
            foreach ($banners as $banner) {
                $banners_multilang[$lang_code][$banner['banner_id']] = $banner;
            }
        }
        list($banners) = fn_get_banners(array(), DEFAULT_LANGUAGE);
        foreach ($banners as $banner) {
            if ($banner['type'] != 'G') {
                continue;
            }
            $main_image_id = !empty($banner['main_pair']['image_id']) ? $banner['main_pair']['image_id'] : 0;
            foreach ($lang_codes as $lang_code => $lang_data) {
                $banner_lang = $banners_multilang[$lang_code][$banner['banner_id']];
                $lang_image_id = !empty($banner_lang['main_pair']['image_id']) ? $banner_lang['main_pair']['image_id'] : 0;
                if ($lang_image_id != 0 && ($main_image_id == 0 || $main_image_id != $lang_image_id)) {
                    fn_delete_image($lang_image_id, $banner_lang['main_pair']['pair_id'], 'promo');
                    $lang_image_id = 0;
                }
                if ($lang_image_id == 0 && $main_image_id != 0) {
                    $data_banner_image = array('banner_id' => $banner['banner_id'], 'lang_code' => $lang_code);
                    $banner_image_id = db_query("INSERT INTO ?:banner_images ?e", $data_banner_image);
                    fn_add_image_link($banner_image_id, $banner['main_pair']['pair_id']);
                    $data_desc = array('description' => empty($banner['main_pair']['icon']['alt']) ? '' : $banner['main_pair']['icon']['alt'], 'object_holder' => 'images');
                    fn_create_description('common_descriptions', 'object_id', $main_image_id, $data_desc);
                }
                db_query("UPDATE ?:banner_descriptions SET url = ?s WHERE banner_id = ?i", $banner['url'], $banner['banner_id']);
            }
        }
    }
    return true;
}
示例#2
0
function fn_banners_delete_languages_post($lang_ids, $lang_codes, $deleted_lang_codes)
{
    foreach ($deleted_lang_codes as $lang_code) {
        list($banners) = fn_get_banners(array(), $lang_code);
        foreach ($banners as $banner) {
            if (empty($banner['main_pair']['pair_id'])) {
                continue;
            }
            fn_delete_image($banner['main_pair']['image_id'], $banner['main_pair']['pair_id'], 'promo');
        }
    }
}
示例#3
0
    //
    if ($mode == 'update') {
        $banner_id = fn_banners_update_banner($_REQUEST['banner_data'], $_REQUEST['banner_id'], DESCR_SL);
        $suffix = ".update?banner_id={$banner_id}";
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['banner_id'])) {
            fn_delete_banner_by_id($_REQUEST['banner_id']);
        }
        $suffix = '.manage';
    }
    return array(CONTROLLER_STATUS_OK, 'banners' . $suffix);
}
if ($mode == 'update') {
    $banner = fn_get_banner_data($_REQUEST['banner_id'], DESCR_SL);
    if (empty($banner)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    Registry::set('navigation.tabs', array('general' => array('title' => __('general'), 'js' => true)));
    Registry::get('view')->assign('banner', $banner);
} elseif ($mode == 'manage' || $mode == 'picker') {
    list($banners, ) = fn_get_banners(array(), DESCR_SL);
    Registry::get('view')->assign('banners', $banners);
}
//
// Banners picker
//
if ($mode == 'picker') {
    Registry::get('view')->display('addons/banners/pickers/banners/picker_contents.tpl');
    exit;
}
示例#4
0
function fn_get_banners_statistics($params)
{
    $condition = '';
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
    } else {
        $params['period'] = 'A';
        $params['time_from'] = '';
        $params['time_to'] = '';
    }
    if (!empty($params['time_from'])) {
        $condition .= db_quote(" AND timestamp >= ?i", $params['time_from']);
    }
    if (!empty($params['time_to'])) {
        $condition .= db_quote(" AND timestamp <= ?i", $params['time_to']);
    }
    $log = db_get_hash_multi_array("SELECT type, COUNT(type) as number, banner_id FROM ?:stat_banners_log WHERE 1 ?p GROUP BY banner_id, type ORDER BY timestamp DESC", array('banner_id', 'type'), $condition);
    foreach ($log as $b_id => $v) {
        if (!empty($v['C']['number']) && !empty($v['V']['number'])) {
            $log[$b_id]['conversion'] = sprintf('%.2f', $v['C']['number'] / $v['V']['number'] * 100);
            if (floatval($log[$b_id]['conversion']) == intval($log[$b_id]['conversion'])) {
                $log[$b_id]['conversion'] = intval($log[$b_id]['conversion']);
            }
        }
    }
    $banner_ids = array_keys($log);
    if (!empty($banner_ids)) {
        $_params = array('item_ids' => implode(',', $banner_ids));
        list($banners) = fn_get_banners($_params);
    } else {
        $banners = array();
    }
    $data = array('log' => $log, 'banners' => $banners);
    return array($data, $params, count($banner_ids));
}