当前位置: 首页>>代码示例>>PHP>>正文


PHP fn_get_localizations_condition函数代码示例

本文整理汇总了PHP中fn_get_localizations_condition函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_get_localizations_condition函数的具体用法?PHP fn_get_localizations_condition怎么用?PHP fn_get_localizations_condition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fn_get_localizations_condition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fn_get_banners

function fn_get_banners($params = array(), $lang_code = CART_LANGUAGE)
{
    $default_params = array('items_per_page' => 0);
    $params = array_merge($default_params, $params);
    $sortings = array('position' => '?:banners.position', 'timestamp' => '?:banners.timestamp', 'name' => '?:banner_descriptions.banner');
    $condition = $limit = '';
    if (!empty($params['limit'])) {
        $limit = db_quote(' LIMIT 0, ?i', $params['limit']);
    }
    $sorting = db_sort($params, $sortings, 'name', 'asc');
    $condition = AREA == 'A' ? '' : " AND ?:banners.status = 'A' ";
    $condition .= fn_get_localizations_condition('?:banners.localization');
    $condition .= AREA == 'A' ? '' : " AND (?:banners.type != 'G' OR ?:banner_images.banner_image_id IS NOT NULL) ";
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(' AND ?:banners.banner_id IN (?n)', explode(',', $params['item_ids']));
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:banners.timestamp >= ?i AND ?:banners.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    fn_set_hook('get_banners', $params, $condition, $sorting, $limit, $lang_code);
    $fields = array('?:banners.banner_id', '?:banners.type', '?:banners.target', '?:banners.status', '?:banners.position', '?:banner_descriptions.banner', '?:banner_descriptions.description', '?:banner_descriptions.url', '?:banner_images.banner_image_id');
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = '?:banners.company_id';
    }
    $banners = db_get_array("SELECT ?p FROM ?:banners " . "LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s" . "LEFT JOIN ?:banner_images ON ?:banner_images.banner_id = ?:banners.banner_id AND ?:banner_images.lang_code = ?s" . "WHERE 1 ?p ?p ?p", implode(", ", $fields), $lang_code, $lang_code, $condition, $sorting, $limit);
    foreach ($banners as $k => $v) {
        $banners[$k]['main_pair'] = fn_get_image_pairs($v['banner_image_id'], 'promo', 'M', true, false, $lang_code);
    }
    fn_set_hook('get_banners_post', $banners, $params);
    return array($banners, $params);
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:32,代码来源:func.php

示例2: fn_get_postcode_location

function fn_get_postcode_location($postcode_location_id, $lang_code = CART_LANGUAGE)
{
    $fields = array('?:postcode_locations.*', '?:postcode_location_descriptions.*', '?:country_descriptions.country as country_title');
    $join = db_quote(" LEFT JOIN ?:postcode_location_descriptions ON ?:postcode_locations.postcode_location_id = ?:postcode_location_descriptions.postcode_location_id AND ?:postcode_location_descriptions.lang_code = ?s", $lang_code);
    $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:postcode_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s", $lang_code);
    $condition = db_quote(" ?:postcode_locations.postcode_location_id = ?i ", $postcode_location_id);
    $condition .= AREA == 'C' && defined('CART_LOCALIZATION') ? fn_get_localizations_condition('?:postcode_locations.localization') : '';
    $postcode_location = db_get_row('SELECT ?p FROM ?:postcode_locations ?p WHERE ?p', implode(', ', $fields), $join, $condition);
    return $postcode_location;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:10,代码来源:func.php

示例3: fn_get_store_location

function fn_get_store_location($store_location_id, $lang_code = CART_LANGUAGE)
{
    $fields = array('?:store_locations.*', '?:store_location_descriptions.*', '?:country_descriptions.country as country_title');
    $join = db_quote(" LEFT JOIN ?:store_location_descriptions ON ?:store_locations.store_location_id = ?:store_location_descriptions.store_location_id AND ?:store_location_descriptions.lang_code = ?s", $lang_code);
    $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:store_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s", $lang_code);
    $condition = db_quote(" ?:store_locations.store_location_id = ?i ", $store_location_id);
    $condition .= AREA == 'C' && defined('CART_LOCALIZATION') ? fn_get_localizations_condition('?:store_locations.localization') : '';
    $store_location = db_get_row('SELECT ?p FROM ?:store_locations ?p WHERE ?p', implode(', ', $fields), $join, $condition);
    $store_location["image_pairs"] = fn_get_image_pairs($store_location_id, 'store_locations', 'M', true, true, $lang_code);
    $store_location["additional_image_pairs"] = fn_get_image_pairs($store_location_id, 'store_locations', 'A', true, true, $lang_code);
    return $store_location;
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:12,代码来源:func.php

示例4: fn_get_store_locations

function fn_get_store_locations($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    $default_params = array('page' => 1, 'q' => '', 'match' => 'any');
    $params = array_merge($default_params, $params);
    $fields = array('?:store_locations.*', '?:store_location_descriptions.*', '?:country_descriptions.country as country_title');
    $join = db_quote(" LEFT JOIN ?:store_location_descriptions ON ?:store_locations.store_location_id = ?:store_location_descriptions.store_location_id AND ?:store_location_descriptions.lang_code = ?s", $lang_code);
    $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:store_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s", $lang_code);
    $condition = 1;
    if (AREA == 'C') {
        $condition .= " AND status = 'A'";
    }
    // Search string condition for SQL query
    if (!empty($params['q'])) {
        if ($params['match'] == 'any') {
            $pieces = explode(' ', $params['q']);
            $search_type = ' OR ';
        } elseif ($params['match'] == 'all') {
            $pieces = explode(' ', $params['q']);
            $search_type = ' AND ';
        } else {
            $pieces = array($params['q']);
            $search_type = '';
        }
        $_condition = array();
        foreach ($pieces as $piece) {
            $tmp = db_quote("?:store_location_descriptions.name LIKE ?l", "%{$piece}%");
            // check search words
            $tmp .= db_quote(" OR ?:store_location_descriptions.description LIKE ?l", "%{$piece}%");
            $tmp .= db_quote(" OR ?:store_location_descriptions.city LIKE ?l", "%{$piece}%");
            $tmp .= db_quote(" OR ?:country_descriptions.country LIKE ?l", "%{$piece}%");
            $_condition[] = '(' . $tmp . ')';
        }
        $_cond = implode($search_type, $_condition);
        if (!empty($_condition)) {
            $condition .= ' AND (' . $_cond . ') ';
        }
        unset($_condition);
    }
    $condition .= AREA == 'C' && defined('CART_LOCALIZATION') ? fn_get_localizations_condition('?:store_locations.localization') : '';
    $sorting = "?:store_locations.position, ?:store_location_descriptions.name";
    $limit = '';
    $total = 0;
    if (!empty($items_per_page)) {
        $total = db_get_field("SELECT COUNT(?:store_locations.store_location_id) FROM ?:store_locations ?p WHERE ?p", $join, $condition);
        $limit = fn_paginate($params['page'], $total, $items_per_page);
    }
    $data = db_get_array('SELECT ?p FROM ?:store_locations ?p WHERE ?p GROUP BY ?:store_locations.store_location_id ORDER BY ?p ?p', implode(', ', $fields), $join, $condition, $sorting, $limit);
    if (!$total) {
        $total = count($data);
    }
    return array($data, $params, $total);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:52,代码来源:func.php

示例5: fn_get_banners

function fn_get_banners($params, $lang_code = CART_LANGUAGE)
{
    $default_params = array('items_per_page' => 0, 'sort_by' => 'name');
    $params = array_merge($default_params, $params);
    $sortings = array('timestamp' => '?:banners.timestamp', 'name' => '?:banner_descriptions.banner');
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    $condition = $limit = '';
    if (!empty($params['limit'])) {
        $limit = db_quote(' LIMIT 0, ?i', $params['limit']);
    }
    if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
        $params['sort_order'] = 'asc';
    }
    if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
        $params['sort_by'] = 'name';
    }
    $sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
    $condition = AREA == 'A' ? '' : " AND ?:banners.status = 'A' ";
    $condition .= fn_get_localizations_condition('?:banners.localization');
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(' AND ?:banners.banner_id IN (?n)', explode(',', $params['item_ids']));
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:banners.timestamp >= ?i AND ?:banners.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    $banners = db_get_array("SELECT ?:banners.banner_id, ?:banners.type, ?:banners.target, ?:banners.status, ?:banners.url, ?:banner_descriptions.banner, ?:banner_descriptions.description FROM ?:banners LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s WHERE 1 ?p ORDER BY ?p ?p", $lang_code, $condition, $sorting, $limit);
    foreach ($banners as $k => $v) {
        $banners[$k]['main_pair'] = fn_get_image_pairs($v['banner_id'], 'banner', 'M', true, false, $lang_code);
    }
    if (!empty($params['item_ids'])) {
        $banners = fn_sort_by_ids($banners, explode(',', $params['item_ids']), 'banner_id');
    }
    fn_set_hook('get_banners', $banners);
    return array($banners, $params);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:36,代码来源:func.php

示例6: fn_get_pages


//.........这里部分代码省略.........
    if (empty($params['full_search'])) {
        $condition .= db_quote(" AND ?:pages.page_type IN (?a)", array_keys(fn_get_page_type_filter($params['page_type'])));
    }
    if (!empty($params['visible'])) {
        // for pages tree: show visible branch only
        $page_ids = array();
        if (!empty($params['current_page_id'])) {
            $cur_id_path = db_get_field("SELECT id_path FROM ?:pages WHERE page_id = ?i", $params['current_page_id']);
            if (!empty($cur_id_path)) {
                $page_ids = explode('/', $cur_id_path);
            }
        }
        if (!empty($from_id_path)) {
            $_page_ids = explode('/', $from_id_path);
            $page_ids = array_merge($page_ids, $_page_ids);
            $page_ids = array_unique($page_ids);
        }
        $page_ids[] = $params['page_id'];
        $condition .= db_quote(" AND ?:pages.parent_id IN (?n)", $page_ids);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:pages.timestamp >= ?i AND ?:pages.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['item_ids'])) {
        // get only defined pages
        $condition .= db_quote(" AND ?:pages.page_id IN (?n)", explode(',', $params['item_ids']));
    }
    if (!empty($params['except_id']) && (empty($params['item_ids']) || !empty($params['item_ids']) && !in_array($params['except_id'], explode(',', $params['item_ids'])))) {
        $condition .= db_quote(' AND ?:pages.page_id != ?i AND ?:pages.parent_id != ?i', $params['except_id'], $params['except_id']);
    }
    if (AREA != 'A') {
        $condition .= " AND (" . fn_find_array_in_set($auth['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        $condition .= fn_get_localizations_condition('?:pages.localization', true);
        $condition .= db_quote(" AND (use_avail_period = ?s OR (use_avail_period = ?s AND avail_from_timestamp <= ?i AND avail_till_timestamp >= ?i))", 'N', 'Y', TIME, TIME);
    }
    $join = db_quote('LEFT JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id AND ?:page_descriptions.lang_code = ?s', $lang_code);
    if (!empty($params['limit'])) {
        $limit = db_quote(" LIMIT 0, ?i", $params['limit']);
    }
    if (!empty($params['neighbours'])) {
        $parent_ids = array();
        if (!empty($params['neighbours_page_id'])) {
            $id_path = db_get_field("SELECT id_path FROM ?:pages WHERE page_id = ?i", $params['neighbours_page_id']);
            $parent_ids = explode('/', $id_path);
            if (count($parent_ids) == 1) {
                array_unshift($parent_ids, 0);
            }
            $params['root_id'] = $parent_ids[0];
        } else {
            $parent_ids[] = 0;
        }
        $condition .= db_quote(" AND ?:pages.parent_id IN (?n)", array_unique($parent_ids));
    }
    fn_set_hook('get_pages', $params, $join, $condition, $fields, $group_by, $sortings, $lang_code);
    if (!empty($params['get_tree'])) {
        $params['sort_by'] = 'multi_level';
    }
    $sorting = db_sort($params, $sortings, 'position', 'asc');
    if (!empty($group_by)) {
        $group_by = ' GROUP BY ' . $group_by;
    }
    // Get search conditions
    if (!empty($params['get_conditions'])) {
        return array($fields, $join, $condition);
    }
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:67,代码来源:fn.cms.php

示例7: fn_get_static_data

function fn_get_static_data($params, $lang_code = DESCR_SL)
{
    $default_params = array();
    $params = array_merge($default_params, $params);
    $schema = fn_get_schema('static_data', 'schema');
    $section_data = $schema[$params['section']];
    $fields = array('sd.param_id', 'sd.param', '?:static_data_descriptions.descr');
    $condition = '';
    $sorting = "sd.position";
    if (!empty($params['multi_level'])) {
        $sorting = "sd.parent_id, sd.position, ?:static_data_descriptions.descr";
    }
    if (!empty($params['status'])) {
        $condition .= db_quote(" AND sd.status = ?s", $params['status']);
    }
    // Params from request
    if (!empty($section_data['owner_object'])) {
        $param = $section_data['owner_object'];
        $value = $param['default_value'];
        if (!empty($params['request'][$param['key']])) {
            $value = $params['request'][$param['key']];
        } elseif (!empty($_REQUEST[$param['key']])) {
            $value = $_REQUEST[$param['key']];
        }
        $condition .= db_quote(" AND sd.?p = ?s", $param['param'], $value);
    }
    if (!empty($params['use_localization'])) {
        $condition .= fn_get_localizations_condition('sd.localization');
    }
    if (!empty($params['get_params'])) {
        $fields[] = "sd.param_2";
        $fields[] = "sd.param_3";
        $fields[] = "sd.param_4";
        $fields[] = "sd.param_5";
        $fields[] = "sd.status";
        $fields[] = "sd.position";
        $fields[] = "sd.parent_id";
        $fields[] = "sd.id_path";
        $fields[] = "sd.class";
    }
    fn_set_hook('get_static_data', $params, $fields, $condition, $sorting, $lang_code);
    $s_data = db_get_hash_array("SELECT " . implode(', ', $fields) . " FROM ?:static_data AS sd LEFT JOIN ?:static_data_descriptions ON sd.param_id = ?:static_data_descriptions.param_id AND ?:static_data_descriptions.lang_code = ?s WHERE sd.section = ?s ?p ORDER BY sd.position", 'param_id', $lang_code, $params['section'], $condition);
    if (!empty($params['icon_name'])) {
        $_icons = fn_get_image_pairs(array_keys($s_data), $params['icon_name'], 'M', true, true, $lang_code);
        foreach ($s_data as $k => $v) {
            $s_data[$k]['icon'] = !empty($_icons[$k]) ? array_pop($_icons[$k]) : array();
        }
    }
    if (!empty($params['generate_levels'])) {
        foreach ($s_data as $k => $v) {
            if (!empty($v['id_path'])) {
                $s_data[$k]['level'] = substr_count($v['id_path'], '/');
            }
        }
    }
    if (!empty($params['multi_level']) && !empty($params['get_params'])) {
        $s_data = fn_make_tree($s_data, 0, 'param_id', 'subitems');
    }
    if (!empty($params['plain'])) {
        $s_data = fn_multi_level_to_plain($s_data, 'subitems');
    }
    return $s_data;
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:63,代码来源:fn.common.php

示例8: fn_get_static_data

function fn_get_static_data($params, $lang_code = DESCR_SL)
{
    $default_params = array('section' => 'C');
    $params = array_merge($default_params, $params);
    $fields = array('?:static_data.param_id', '?:static_data.param', '?:static_data_descriptions.descr');
    $condition = '';
    $sorting = "?:static_data.position";
    if (!empty($params['multi_level'])) {
        $sorting = "?:static_data.parent_id, ?:static_data.position, ?:static_data_descriptions.descr";
    }
    if (!empty($params['status'])) {
        $condition .= db_quote(" AND ?:static_data.status = ?s", $params['status']);
    }
    if (!empty($params['use_localization'])) {
        $condition .= fn_get_localizations_condition('?:static_data.localization');
    }
    if (!empty($params['get_params'])) {
        $fields[] = "?:static_data.param_2";
        $fields[] = "?:static_data.param_3";
        $fields[] = "?:static_data.param_4";
        $fields[] = "?:static_data.param_5";
        $fields[] = "?:static_data.status";
        $fields[] = "?:static_data.position";
        $fields[] = "?:static_data.parent_id";
        $fields[] = "?:static_data.id_path";
    }
    $s_data = db_get_hash_array("SELECT " . implode(', ', $fields) . " FROM ?:static_data LEFT JOIN ?:static_data_descriptions ON ?:static_data.param_id = ?:static_data_descriptions.param_id AND ?:static_data_descriptions.lang_code = ?s WHERE ?:static_data.section = ?s ?p ORDER BY ?:static_data.position", 'param_id', $lang_code, $params['section'], $condition);
    if (!empty($params['icon_name'])) {
        foreach ($s_data as $k => $v) {
            $s_data[$k]['icon'] = fn_get_image_pairs($v['param_id'], $params['icon_name'], 'M', true, true, $lang_code);
        }
    }
    if (!empty($params['generate_levels'])) {
        foreach ($s_data as $k => $v) {
            if (!empty($v['id_path'])) {
                $s_data[$k]['level'] = substr_count($v['id_path'], '/');
            }
        }
    }
    if (!empty($params['multi_level'])) {
        $delete_keys = array();
        foreach ($s_data as $k => $v) {
            if (!empty($v['parent_id'])) {
                if (!empty($s_data[$v['parent_id']])) {
                    $s_data[$v['parent_id']]['subitems'][$v['param_id']] = $v;
                    $s_data[$k] =& $s_data[$v['parent_id']]['subitems'][$v['param_id']];
                }
                $delete_keys[] = $k;
            }
        }
        foreach ($delete_keys as $k) {
            unset($s_data[$k]);
        }
    }
    if (!empty($params['plain'])) {
        $s_data = fn_multi_level_to_plain($s_data, 'subitems');
    }
    return $s_data;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:59,代码来源:fn.common.php

示例9: fn_get_news

function fn_get_news($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields = array('?:news.*', 'descr.news', 'descr.description');
    // Define sort fields
    $sortings = array('position' => '?:news.position', 'name' => 'descr.news', 'date' => '?:news.date');
    $limit = $condition = '';
    $join = db_quote(" LEFT JOIN ?:news_descriptions AS descr ON descr.news_id = ?:news.news_id AND descr.lang_code = ?s", $lang_code);
    $condition .= AREA == 'A' ? '1 ' : " ?:news.status = 'A'";
    $condition .= fn_get_localizations_condition('?:news.localization');
    // Get additional information about companies
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = ' ?:companies.company as company';
        $sortings['company'] = 'company';
        $join .= db_quote(" LEFT JOIN ?:companies ON ?:companies.company_id = ?:news.company_id");
    }
    if (isset($params['q']) && fn_string_not_empty($params['q'])) {
        $params['q'] = trim($params['q']);
        if ($params['match'] == 'any') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' OR ';
        } elseif ($params['match'] == 'all') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' AND ';
        } else {
            $pieces = array($params['q']);
            $search_type = '';
        }
        $_condition = array();
        foreach ($pieces as $piece) {
            if (strlen($piece) == 0) {
                continue;
            }
            $tmp = array();
            $tmp[] = db_quote("descr.news LIKE ?l", "%{$piece}%");
            $tmp[] = db_quote("descr.description LIKE ?l", "%{$piece}%");
            $_condition[] = '(' . join(' OR ', $tmp) . ')';
        }
        $_cond = implode($search_type, $_condition);
        if (!empty($_condition)) {
            $condition .= ' AND (' . $_cond . ') ';
        }
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:news.date >= ?i AND ?:news.date <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(' AND ?:news.news_id IN (?n)', explode(',', $params['item_ids']));
    }
    $limit = '';
    if (!empty($params['limit'])) {
        $limit = db_quote(" LIMIT 0, ?i", $params['limit']);
    } elseif (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(?:news.news_id) FROM ?:news ?p WHERE ?p", $join, $condition);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    fn_set_hook('get_news', $params, $fields, $join, $condition, $sorting, $limit, $lang_code);
    $sorting = db_sort($params, $sortings, 'date', 'desc');
    // Used for Extended search
    if (!empty($params['get_conditions'])) {
        return array($fields, $join, $condition);
    }
    $fields = join(', ', $fields);
    $news = db_get_array("SELECT ?p FROM ?:news ?p WHERE ?p ?p ?p", $fields, $join, $condition, $sorting, $limit);
    /**
     * Get additional data for selected news
     *
     * @param array  $news      news list
     * @param string $lang_code language code
     */
    fn_set_hook('get_news_post', $news, $lang_code);
    return array($news, $params);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:75,代码来源:func.php

示例10: fn_get_products


//.........这里部分代码省略.........
        $params['extend'][] = 'categories';
        if (!empty($_cond)) {
            $cache_feature_search = db_get_fields("SELECT product_id, COUNT(product_id) as cnt FROM ?:product_features_values WHERE (" . implode(' OR ', $_cond) . ") GROUP BY product_id HAVING cnt = {$total_hits}");
            $feature_search_condition .= db_quote(" AND products_categories.product_id IN (?n)", $cache_feature_search);
        }
    }
    // Category search condition for SQL query
    if (!empty($params['cid'])) {
        $cids = is_array($params['cid']) ? $params['cid'] : explode(',', $params['cid']);
        if (!empty($params['subcats']) && $params['subcats'] == 'Y') {
            $_ids = db_get_fields("SELECT a.category_id FROM ?:categories as a LEFT JOIN ?:categories as b ON b.category_id IN (?n) WHERE a.id_path LIKE CONCAT(b.id_path, '/%')", $cids);
            $cids = fn_array_merge($cids, $_ids, false);
        }
        $params['extend'][] = 'categories';
        $condition .= db_quote(" AND ?:categories.category_id IN (?n)", $cids);
    }
    // If we need to get the products by IDs and no IDs passed, don't search anything
    if (!empty($params['force_get_by_ids']) && empty($params['pid']) && empty($params['product_id'])) {
        return array(array(), $params, 0);
    }
    // Product ID search condition for SQL query
    if (!empty($params['pid'])) {
        $u_condition .= db_quote($union_condition . ' products.product_id IN (?n)', $params['pid']);
    }
    // Exclude products from search results
    if (!empty($params['exclude_pid'])) {
        $condition .= db_quote(' AND products.product_id NOT IN (?n)', $params['exclude_pid']);
    }
    // Search by feature comparison flag
    if (!empty($params['feature_comparison'])) {
        $condition .= db_quote(' AND products.feature_comparison = ?s', $params['feature_comparison']);
    }
    // Search products by localization
    $condition .= fn_get_localizations_condition('products.localization', true);
    $company_condition = '';
    if (fn_allowed_for('MULTIVENDOR')) {
        if ($params['area'] == 'C') {
            $company_condition .= " AND companies.status = 'A' ";
            $params['extend'][] = 'companies';
        } else {
            $company_condition .= fn_get_company_condition('products.company_id');
        }
    } else {
        $cat_company_condition = '';
        if (Registry::get('runtime.company_id')) {
            $params['extend'][] = 'categories';
            $cat_company_condition .= fn_get_company_condition('?:categories.company_id');
        } elseif (!empty($params['company_ids'])) {
            $params['extend'][] = 'categories';
            $cat_company_condition .= db_quote(' AND ?:categories.company_id IN (?a)', explode(',', $params['company_ids']));
        }
        $company_condition .= $cat_company_condition;
    }
    $condition .= $company_condition;
    if (!fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id') && isset($params['company_id'])) {
        $params['company_id'] = Registry::get('runtime.company_id');
    }
    if (isset($params['company_id']) && $params['company_id'] != '') {
        $condition .= db_quote(' AND products.company_id = ?i ', $params['company_id']);
    }
    if (!empty($params['filter_params'])) {
        foreach ($params['filter_params'] as $field => $f_vals) {
            $condition .= db_quote(' AND products.' . $field . ' IN (?a) ', $f_vals);
        }
    }
    if (isset($params['price_from']) && fn_is_numeric($params['price_from'])) {
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:67,代码来源:fn.catalog.php

示例11: fn_calculate_shipping_rates

function fn_calculate_shipping_rates(&$cart, &$cart_products, $auth, $calculate_selected = false)
{
    $shipping_rates = array();
    $condition = '';
    if ($calculate_selected == true) {
        $shipping_ids = !empty($cart['shipping']) ? array_keys($cart['shipping']) : array();
        if (!empty($shipping_ids)) {
            $condition = db_quote(" AND a.shipping_id IN (?n)", $shipping_ids);
        } else {
            return array();
        }
    }
    $condition .= fn_get_localizations_condition('a.localization');
    $location = fn_get_customer_location($auth, $cart);
    $destination_id = fn_get_available_destination($location);
    $package_infos = fn_prepare_package_info($cart, $cart_products);
    foreach ($package_infos as $o_id => $package_info) {
        $c = fn_get_company_condition('a.company_id', false, $o_id, false, true);
        $companies = Registry::get('s_companies');
        if (!empty($companies) && !empty($companies[$o_id]['shippings'])) {
            if (trim($c)) {
                $c = "{$c} OR ";
            }
            $c .= db_quote('a.shipping_id IN (?n)', explode(',', $companies[$o_id]['shippings']));
            $c = "({$c})";
        }
        if (trim($c)) {
            $c = " AND {$c}";
        }
        //TODO select companies shippings
        fn_set_hook('calculate_shipping_rates', $c, $o_id);
        if (AREA == 'C') {
            $condition .= " AND (" . fn_find_array_in_set($auth['usergroup_ids'], 'a.usergroup_ids', true) . ")";
        }
        $shipping_methods = db_get_hash_array("SELECT a.shipping_id, a.rate_calculation, a.service_id, a.self_service, b.shipping as name, b.delivery_time FROM ?:shippings as a LEFT JOIN ?:shipping_descriptions as b ON a.shipping_id = b.shipping_id AND b.lang_code = ?s WHERE (a.min_weight <= ?d AND (a.max_weight >= ?d OR a.max_weight = 0.00)) AND a.status = 'A' ?p ?p ORDER BY a.position", 'shipping_id', CART_LANGUAGE, $package_info['W'], $package_info['W'], $condition, $c);
        if (empty($shipping_methods)) {
            continue;
        }
        $found_rates = array();
        foreach ($shipping_methods as $method) {
            // Manual rate calculation
            if ($method['rate_calculation'] == 'M') {
                if ($destination_id !== false) {
                    $rate_data = db_get_row("SELECT rate_id, rate_value FROM ?:shipping_rates WHERE shipping_id = ?i AND destination_id = ?i", $method['shipping_id'], $destination_id);
                    if (!empty($rate_data)) {
                        $found_rates[$method['shipping_id']] = fn_calculate_shipping_rate($package_info, $rate_data['rate_value']);
                    }
                }
                // Realtime rate calculation
            } else {
                $charge = db_get_field("SELECT rate_value FROM ?:shipping_rates WHERE shipping_id = ?i AND destination_id = 0", $method['shipping_id']);
                $rate_data = fn_calculate_realtime_shipping_rate($method['service_id'], $location, $package_info, $auth);
                if ($rate_data !== false) {
                    $found_rates[$method['shipping_id']] = $rate_data['cost'];
                    $found_rates[$method['shipping_id']] += fn_calculate_shipping_rate($package_info, $charge);
                }
            }
        }
        $shipping_freight = 0;
        foreach ($cart_products as $v) {
            if (($v['is_edp'] != 'Y' || $v['is_edp'] == 'Y' && $v['edp_shipping'] == 'Y') && $v['free_shipping'] != 'Y') {
                $shipping_freight += $v['shipping_freight'] * $v['amount'];
            }
        }
        foreach ($shipping_methods as $method) {
            $shipping_rates[$method['shipping_id']]['name'] = $method['name'];
            $shipping_rates[$method['shipping_id']]['delivery_time'] = $method['delivery_time'];
            $shipping_rates[$method['shipping_id']]['rates'] = array();
            $shipping_rates[$method['shipping_id']]['self_service'] = $method['self_service'];
        }
        foreach ($found_rates as $shipping_id => $rate_value) {
            /*if (!isset($shipping_rates[$shipping_id])) {
            			$shipping_rates[$shipping_id]['name'] = $shipping_methods[$shipping_id]['name'];
            			$shipping_rates[$shipping_id]['delivery_time'] = $shipping_methods[$shipping_id]['delivery_time'];
            		}*/
            $shipping_rates[$shipping_id]['rates'][$o_id] = $rate_value + $shipping_freight;
        }
    }
    return $shipping_rates;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:80,代码来源:fn.cart.php

示例12: fn_get_news

function fn_get_news($params, $lang_code = CART_LANGUAGE)
{
    $fields = array('?:news.*', 'descr.news', 'descr.description');
    // Define sort fields
    $sortings = array('position' => '?:news.position', 'name' => '?:news_descriptions.news', 'date' => '?:news.date');
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    $limit = $condition = $sorting = '';
    $join = db_quote(" LEFT JOIN ?:news_descriptions as descr ON descr.news_id = ?:news.news_id AND descr.lang_code = ?s", $lang_code);
    $condition .= AREA == 'A' ? '1 ' : " ?:news.status = 'A'";
    $condition .= fn_get_localizations_condition('?:news.localization');
    if (!empty($params['b_id'])) {
        $join .= " LEFT JOIN ?:block_links ON ?:block_links.object_id = ?:news.news_id AND ?:block_links.location = 'news'";
        $condition .= db_quote(' AND ?:block_links.block_id = ?i', $params['b_id']);
    }
    if (isset($params['q']) && fn_string_no_empty($params['q'])) {
        $params['q'] = trim($params['q']);
        if ($params['match'] == 'any') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' OR ';
        } elseif ($params['match'] == 'all') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' AND ';
        } else {
            $pieces = array($params['q']);
            $search_type = '';
        }
        $_condition = array();
        foreach ($pieces as $piece) {
            if (strlen($piece) == 0) {
                continue;
            }
            $tmp = array();
            $tmp[] = db_quote("descr.news LIKE ?l", "%{$piece}%");
            $tmp[] = db_quote("descr.description LIKE ?l", "%{$piece}%");
            $_condition[] = '(' . join(' OR ', $tmp) . ')';
        }
        $_cond = implode($search_type, $_condition);
        if (!empty($_condition)) {
            $condition .= ' AND (' . $_cond . ') ';
        }
    }
    if (!empty($params['limit'])) {
        $limit = db_quote(" LIMIT 0, ?i", $params['limit']);
    }
    if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
        $params['sort_order'] = 'desc';
    }
    if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
        $params['sort_by'] = 'date';
    }
    $sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:news.date >= ?i AND ?:news.date <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['item_ids'])) {
        $condition .= db_quote(' AND ?:news.news_id IN (?n)', explode(',', $params['item_ids']));
    }
    // Used for Extended search
    if (!empty($params['get_conditions'])) {
        return array($fields, $join, $condition);
    }
    if (!empty($params['paginate'])) {
        $params['page'] = empty($params['page']) ? 1 : $params['page'];
        $total = db_get_field("SELECT COUNT(?:news.news_id) FROM ?:news ?p WHERE ?p", $join, $condition);
        $limit = fn_paginate($params['page'], $total, AREA == 'A' ? Registry::get('settings.Appearance.admin_elements_per_page') : Registry::get('settings.Appearance.elements_per_page'));
    }
    fn_set_hook('get_news', $params, $fields, $join, $condition, $sorting, $limit, $lang_code);
    $fields = join(', ', $fields);
    $news = db_get_array("SELECT ?p FROM ?:news ?p WHERE ?p ORDER BY ?p ?p", $fields, $join, $condition, $sorting, $limit);
    fn_set_hook('get_news_post', $news);
    return array($news, $params);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:73,代码来源:func.php

示例13: fn_get_pages

function fn_get_pages($params = array(), $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $params = fn_init_view('pages', $params);
    $default_params = array('page_id' => 0, 'page' => 1, 'visible' => false, 'get_tree' => '', 'items_per_page' => 0, 'pdescr' => '', 'subpages' => '');
    $params = array_merge($default_params, $params);
    if (empty($params['pname']) && empty($params['pdescr']) && empty($params['subpages'])) {
        $params['pname'] = 'Y';
    }
    $fields = array('?:pages.*', '?:page_descriptions.*');
    // Define sort fields
    $sortings = array('position' => array('?:pages.position', '?:page_descriptions.page'), 'name' => '?:page_descriptions.page', 'timestamp' => '?:pages.timestamp', 'type' => '?:pages.page_type', 'multi_level' => array('?:pages.parent_id', '?:pages.position', '?:page_descriptions.page'));
    $directions = array('asc' => 'asc', 'desc' => 'desc');
    $auth =& $_SESSION['auth'];
    $condition = '1';
    $join = $limit = $group_by = '';
    if (isset($params['q']) && fn_string_no_empty($params['q'])) {
        $params['q'] = trim($params['q']);
        if ($params['match'] == 'any') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' OR ';
        } elseif ($params['match'] == 'all') {
            $pieces = fn_explode(' ', $params['q']);
            $search_type = ' AND ';
        } else {
            $pieces = array($params['q']);
            $search_type = '';
        }
        $_condition = array();
        foreach ($pieces as $piece) {
            if (strlen($piece) == 0) {
                continue;
            }
            $tmp = array();
            if (!empty($params['pname']) && $params['pname'] == 'Y') {
                $tmp[] = db_quote("(?:page_descriptions.page LIKE ?l)", "%{$piece}%");
                // check search words
            }
            if ($params['pdescr'] == 'Y') {
                $tmp[] = db_quote("?:page_descriptions.description LIKE ?l", "%{$piece}%");
            }
            if (!empty($tmp)) {
                $_condition[] = '(' . implode(' OR ', $tmp) . ')';
            }
        }
        if (!empty($_condition)) {
            $condition .= ' AND ' . implode($search_type, $_condition);
        }
    }
    $condition .= fn_get_company_condition('?:pages.company_id');
    if (!empty($params['page_type'])) {
        $condition .= db_quote(" AND ?:pages.page_type = ?s", $params['page_type']);
    }
    if (isset($params['parent_id']) && $params['parent_id'] !== '') {
        $p_ids = array();
        if ($params['subpages'] == 'Y') {
            $p_ids = db_get_fields("SELECT a.page_id FROM ?:pages as a LEFT JOIN ?:pages as b ON b.page_id = ?i WHERE a.id_path LIKE CONCAT(b.id_path, '/%')", $params['parent_id']);
        }
        $p_ids[] = $params['parent_id'];
        $condition .= db_quote(" AND ?:pages.parent_id IN (?n)", $p_ids);
    }
    if (!empty($params['from_page_id'])) {
        $from_id_path = db_get_field("SELECT id_path FROM ?:pages WHERE page_id = ?i", $params['from_page_id']);
        $condition .= db_quote(" AND ?:pages.id_path LIKE ?l", "{$from_id_path}/%");
    }
    if (!empty($params['status'])) {
        $condition .= db_quote(" AND ?:pages.status IN (?a)", $params['status']);
    }
    if (!empty($params['vendor_pages']) && empty($params['company_id'])) {
        return array(array(), $params);
    } elseif (!empty($params['company_id'])) {
        $condition .= db_quote(" AND ?:pages.company_id = ?i", $params['company_id']);
    }
    if (!empty($params['visible'])) {
        // for pages tree: show visible branch only
        if (!empty($params['current_page_id'])) {
            $cur_id_path = db_get_field("SELECT id_path FROM ?:pages WHERE page_id = ?i", $params['current_page_id']);
            if (!empty($cur_id_path)) {
                $page_ids = explode('/', $cur_id_path);
            }
        }
        $page_ids[] = $params['page_id'];
        $condition .= db_quote(" AND ?:pages.parent_id IN (?n)", $page_ids);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:pages.timestamp >= ?i AND ?:pages.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['item_ids'])) {
        // get only defined pages
        $condition .= db_quote(" AND ?:pages.page_id IN (?n)", explode(',', $params['item_ids']));
    }
    if (!empty($params['except_id']) && (empty($params['item_ids']) || !empty($params['item_ids']) && !in_array($params['except_id'], explode(',', $params['item_ids'])))) {
        $condition .= db_quote(' AND ?:pages.page_id != ?i AND ?:pages.parent_id != ?i', $params['except_id'], $params['except_id']);
    }
    if (AREA != 'A') {
        $condition .= " AND (" . fn_find_array_in_set($auth['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        $condition .= fn_get_localizations_condition('?:pages.localization', true);
        $condition .= db_quote(" AND (use_avail_period = ?s OR (use_avail_period = ?s AND avail_from_timestamp >= ?i AND avail_till_timestamp <= ?i))", 'N', 'Y', TIME, TIME);
    }
//.........这里部分代码省略.........
开发者ID:diedsmiling,项目名称:busenika,代码行数:101,代码来源:fn.cms.php

示例14: fn_load_products_extra_data

/**
 * Lazily loads additional data related to products after they have been fetched from DB.
 * Used to ease main product loading SQL-query.
 *
 * @param array $products List of products
 * @param array $params Parameters passed to fn_get_products()
 * @param string $lang_code Language code passed to fn_get_products()
 *
 * @return array List of products with additional data merged into.
 */
function fn_load_products_extra_data($products, $params, $lang_code)
{
    $products = fn_array_elements_to_keys($products, 'product_id');
    $product_ids = array_keys($products);
    $extra_fields = array();
    // Fields from "products" table
    $extra_fields['?:products'] = array('primary_key' => 'product_id', 'fields' => empty($params['only_short_fields']) ? array('*') : array('product_id', 'product_code', 'product_type', 'status', 'company_id', 'list_price', 'amount', 'weight', 'tracking', 'is_edp'));
    // Load prices lazily when they are needed and no sorting or filtering by price is applied
    if (in_array('prices', $params['extend']) && $params['sort_by'] != 'price' && !in_array('prices2', $params['extend'])) {
        $extra_fields['?:product_prices'] = array('primary_key' => 'product_id', 'fields' => array('price' => 'MIN(IF(' . '?:product_prices.percentage_discount = 0,' . '?:product_prices.price,' . '?:product_prices.price - (?:product_prices.price * ?:product_prices.percentage_discount)/100' . '))'), 'condition' => db_quote(' AND ?:product_prices.lower_limit = 1 AND ?:product_prices.usergroup_id IN (?n)', $params['area'] == 'A' ? USERGROUP_ALL : array_unique(array_merge(array(USERGROUP_ALL), $_SESSION['auth']['usergroup_ids']))), 'group_by' => ' GROUP BY ?:product_prices.product_id');
    }
    // Descriptions
    $extra_fields['?:product_descriptions']['primary_key'] = 'product_id';
    $extra_fields['?:product_descriptions']['condition'] = db_quote(" AND ?:product_descriptions.lang_code = ?s", $lang_code);
    if (in_array('search_words', $params['extend'])) {
        $extra_fields['?:product_descriptions']['fields'][] = 'search_words';
    }
    if (in_array('description', $params['extend'])) {
        $extra_fields['?:product_descriptions']['fields'][] = 'short_description';
        if (in_array('full_description', $params['extend'])) {
            $extra_fields['?:product_descriptions']['fields'][] = 'full_description';
        } else {
            $extra_fields['?:product_descriptions']['fields']['full_description'] = "IF(?:product_descriptions.short_description = '', ?:product_descriptions.full_description, '')";
        }
    }
    // Categories
    if (in_array('categories', $params['extend'])) {
        $categories_join = ' INNER JOIN ?:categories ON ?:categories.category_id = ?:products_categories.category_id';
        if ($params['area'] == 'C') {
            if (!fn_is_preview_action($_SESSION['auth'], $params)) {
                $categories_join .= ' AND (' . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:categories.usergroup_ids', true) . ')';
            }
            $categories_join .= db_quote(' AND ?:categories.status IN (?a) ', array('A', 'H'));
        }
        $extra_fields['?:products_categories'] = array('primary_key' => 'product_id', 'fields' => array('category_ids' => 'GROUP_CONCAT(' . 'IF(?:products_categories.link_type = "M",' . ' CONCAT(?:products_categories.category_id, "M"),' . ' ?:products_categories.category_id)' . ')', 'position' => '?:products_categories.position'), 'condition' => fn_get_localizations_condition('?:categories.localization', true), 'join' => $categories_join, 'group_by' => ' GROUP BY ?:products_categories.product_id');
        if (!empty($params['cid'])) {
            $extra_fields['?:products_categories']['group_by'] .= db_quote(' ,?:products_categories.category_id = ?i', $params['cid']);
        }
    }
    /**
     * Allows you to extend configuration of extra fields that should be lazily loaded for products.
     *
     * @see fn_load_extra_data_by_item_ids()
     * @param array  $extra_fields
     * @param array  $products     List of products
     * @param array  $product_ids  List of product identifiers
     * @param array  $params       Parameters passed to fn_get_products()
     * @param string $lang_code    Language code passed to fn_get_products()
     */
    fn_set_hook('load_products_extra_data', $extra_fields, $products, $product_ids, $params, $lang_code);
    // Execute extra data loading SQL-queries and merge results into $products array
    fn_merge_extra_data_to_entity_list(fn_load_extra_data_by_entity_ids($extra_fields, $product_ids), $products);
    // Categories post-processing
    if (in_array('categories', $params['extend'])) {
        foreach ($products as $k => $v) {
            list($products[$k]['category_ids'], $products[$k]['main_category']) = fn_convert_categories($v['category_ids']);
        }
    }
    /**
     * Allows you lazily load extra data for products after they were fetched from DB or post-process lazy-loaded
     * additional data related to products.
     *
     * @param array  $products    List of products
     * @param array  $product_ids List of product identifiers
     * @param array  $params      Parameters passed to fn_get_products()
     * @param string $lang_code   Language code passed to fn_get_products()
     */
    fn_set_hook('load_products_extra_data_post', $products, $product_ids, $params, $lang_code);
    return $products;
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:80,代码来源:fn.catalog.php

示例15: fn_get_available_destination

function fn_get_available_destination($location)
{
    $country = !empty($location['country']) ? $location['country'] : '';
    $state = !empty($location['state']) ? $location['state'] : '';
    $zipcode = !empty($location['zipcode']) ? $location['zipcode'] : '';
    $city = !empty($location['city']) ? $location['city'] : '';
    $address = !empty($location['address']) ? $location['address'] : '';
    if (!empty($country)) {
        $state_id = fn_get_state_id($state, $country);
        $condition = '';
        if (AREA == 'C') {
            $condition .= fn_get_localizations_condition('localization');
            if (!empty($condition)) {
                $condition = db_quote('OR (1 ?p)', $condition);
            }
        }
        $__dests = db_get_array("SELECT a.* FROM ?:destination_elements as a LEFT JOIN ?:destinations as b ON b.destination_id = a.destination_id WHERE b.status = 'A' ?p", $condition);
        $destinations = array();
        foreach ($__dests as $k => $v) {
            $destinations[$v['destination_id']][$v['element_type']][] = $v['element'];
        }
        $concur_destinations = array();
        foreach ($destinations as $dest_id => $elm_types) {
            // Significance level. The more significance level means the most amount of coincidences
            $significance = 0;
            $dest_countries = !empty($elm_types['C']) ? $elm_types['C'] : array();
            foreach ($elm_types as $elm_type => $elms) {
                // Check country
                if ($elm_type == 'C') {
                    $suitable = fn_check_element($elms, $country);
                    if ($suitable == false) {
                        break;
                    }
                    $significance += 1 * (1 / count($elms));
                }
                // Check state
                if ($elm_type == 'S') {
                    // if country is in destanation_countries and it haven't got states,
                    // we suppose that destanation cover all country
                    if (!in_array($country, $dest_countries) || fn_get_country_states($country)) {
                        $suitable = fn_check_element($elms, $state_id);
                        if ($suitable == false) {
                            break;
                        }
                    } else {
                        $suitable = true;
                    }
                    $significance += 2 * (1 / count($elms));
                }
                // Check city
                if ($elm_type == 'T') {
                    $suitable = fn_check_element($elms, $city, true);
                    if ($suitable == false) {
                        break;
                    }
                    $significance += 3 * (1 / count($elms));
                }
                // Check zipcode
                if ($elm_type == 'Z') {
                    $suitable = fn_check_element($elms, $zipcode, true);
                    if ($suitable == false) {
                        break;
                    }
                    $significance += 4 * (1 / count($elms));
                }
                // Check address
                if ($elm_type == 'A') {
                    $suitable = fn_check_element($elms, $address, true);
                    if ($suitable == false) {
                        break;
                    }
                    $significance += 5 * (1 / count($elms));
                }
            }
            $significance = number_format($significance, 4, '.', '');
            if ($suitable == true) {
                $concur_destinations[$significance][] = $dest_id;
            }
        }
        if (!empty($concur_destinations)) {
            ksort($concur_destinations, SORT_NUMERIC);
            $concur_destinations = array_pop($concur_destinations);
            return reset($concur_destinations);
        } else {
            return false;
        }
    }
    return false;
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:89,代码来源:fn.locations.php


注:本文中的fn_get_localizations_condition函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。