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


PHP fn_sort_array_by_key函数代码示例

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


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

示例1: fn_get_tags

function fn_get_tags($params = array(), $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('tags', $params);
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define sort fields
    $sortings = array('tag' => '?:tags.tag', 'status' => '?:tags.status', 'popularity' => 'popularity', 'users' => 'users');
    $conditions = fn_tags_build_conditions($params);
    $sorting = db_sort($params, $sortings, 'tag', 'asc');
    $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(DISTINCT(?:tags.tag_id)) FROM ?:tags LEFT JOIN ?:tag_links ON ?:tags.tag_id = ?:tag_links.tag_id WHERE 1 ?p", $conditions);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $tags = db_get_hash_array("SELECT ?:tags.tag_id, ?:tag_links.object_id, ?:tag_links.object_type, ?:tags.tag, ?:tags.status, COUNT(?:tag_links.tag_id) as popularity " . "FROM ?:tags LEFT JOIN ?:tag_links ON ?:tag_links.tag_id = ?:tags.tag_id WHERE 1 ?p GROUP BY ?:tags.tag_id {$sorting} {$limit}", 'tag_id', $conditions);
    if (!empty($params['count_objects'])) {
        $objs = db_get_array("SELECT tag_id, COUNT(DISTINCT(object_id)) as count, object_type " . "FROM ?:tag_links WHERE tag_id IN (?n) GROUP BY tag_id, object_type", array_keys($tags));
        foreach ($objs as $v) {
            $tags[$v['tag_id']]['objects_count'][$v['object_type']] = $v['count'];
        }
    }
    // Generate popularity level
    foreach ($tags as $k => $v) {
        $level = ceil(log($v['popularity']));
        $tags[$k]['level'] = $level > TAGS_MAX_LEVEL ? TAGS_MAX_LEVEL : $level;
    }
    if (!empty($params['sort_popular'])) {
        $tags = fn_sort_array_by_key($tags, 'tag', SORT_ASC);
    }
    return array($tags, $params);
}
开发者ID:askzap,项目名称:ultimate,代码行数:34,代码来源:func.php

示例2: fn_set_hook

/**
 * Set hook to use by addons
 *
 * @param mixed $argN argument, passed to addon
 * @return boolean always true
 */
function fn_set_hook($arg0 = NULL, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5 = NULL, &$arg6 = NULL, &$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL, &$arg10 = NULL, &$arg11 = NULL, &$arg12 = NULL, &$arg13 = NULL, &$arg14 = NULL, &$arg15 = NULL)
{
    $hooks = Registry::get('hooks');
    $test = $arg0;
    static $loaded_addons;
    static $callable_functions;
    static $hooks_already_sorted;
    for ($args = array(), $i = 0; $i < 16; $i++) {
        $name = 'arg' . $i;
        if ($i < func_num_args()) {
            $args[$i] =& ${$name};
        }
        unset(${$name}, $name);
    }
    //    if($test=="calculate_cart_items"){
    //        //var_dump($callback['func']); echo" ==== ";
    //        var_dump($args); echo"<br/>______________________________<br/>";
    //    }
    $hook_name = array_shift($args);
    // Check for the core functions
    $core_func = 'fn_core_' . $hook_name;
    if (is_callable($core_func)) {
        call_user_func_array($core_func, $args);
    }
    $edition_acronym = fn_get_edition_acronym(PRODUCT_EDITION);
    if (!empty($edition_acronym)) {
        $edition_hook_func = "fn_{$edition_acronym}_{$hook_name}";
        if (function_exists($edition_hook_func)) {
            call_user_func_array($edition_hook_func, $args);
        }
    }
    if (isset($hooks[$hook_name])) {
        // cache hooks sorting
        if (!isset($hooks_already_sorted[$hook_name])) {
            $hooks[$hook_name] = fn_sort_array_by_key($hooks[$hook_name], 'priority');
            $hooks_already_sorted[$hook_name] = true;
            Registry::set('hooks', $hooks, true);
        }
        foreach ($hooks[$hook_name] as $callback) {
            //cache loaded addon
            if (!isset($loaded_addons[$callback['addon']])) {
                // FIXME: duplicate with cache in fn_load_addon
                fn_load_addon($callback['addon']);
                $loaded_addons[$callback['addon']] = true;
            }
            // cache if hook function callable
            if (!isset($callable_functions[$callback['func']])) {
                if (!is_callable($callback['func'])) {
                    throw new DeveloperException("Hook {$callback['func']} is not callable");
                }
                $callable_functions[$callback['func']] = true;
            }
            call_user_func_array($callback['func'], $args);
        }
    }
    return true;
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:63,代码来源:fn.control.php

示例3: fn_set_hook

/**
 * Set hook to use by addons
 *
 * @param mixed $argN argument, passed to addon
 * @return boolean always true
 */
function fn_set_hook($arg0 = NULL, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5 = NULL, &$arg6 = NULL, &$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL, &$arg10 = NULL, &$arg11 = NULL, &$arg12 = NULL, &$arg13 = NULL, &$arg14 = NULL, &$arg15 = NULL)
{
    $hooks = Registry::get('hooks');
    static $loaded_addons;
    static $callable_functions;
    static $hooks_already_sorted;
    for ($args = array(), $i = 0; $i < 10; $i++) {
        $name = 'arg' . $i;
        if ($i < func_num_args()) {
            $args[$i] =& ${$name};
        }
        unset(${$name}, $name);
    }
    $hook_name = array_shift($args);
    if (isset($hooks[$hook_name])) {
        // cache hooks sorting
        if (!isset($hooks_already_sorted[$hook_name])) {
            $hooks[$hook_name] = fn_sort_array_by_key($hooks[$hook_name], 'priority');
            $hooks_already_sorted[$hook_name] = true;
        }
        foreach ($hooks[$hook_name] as $callback) {
            //cache loaded addon
            if (!isset($loaded_addons[$callback['addon']])) {
                // FIXME: duplicate with cache in fn_load_addon
                fn_load_addon($callback['addon']);
                $loaded_addons[$callback['addon']] = true;
            }
            // cache if hook function callable
            if (!isset($callable_functions[$callback['func']])) {
                if (!is_callable($callback['func'])) {
                    die("Hook {$callback['func']} is not callable");
                }
                $callable_functions[$callback['func']] = true;
            }
            call_user_func_array($callback['func'], $args);
        }
    }
    return true;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:45,代码来源:fn.control.php

示例4: fn_set_hook

/**
 * Set hook to use by addons
 *
 * @param mixed $argN argument, passed to addon
 * @return boolean always true
 */
function fn_set_hook($hook_name = NULL, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5 = NULL, &$arg6 = NULL, &$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL, &$arg10 = NULL, &$arg11 = NULL, &$arg12 = NULL, &$arg13 = NULL, &$arg14 = NULL, &$arg15 = NULL)
{
    /**
     * @var bool[]|null $callable_functions Cache of validations that hook's function is callable groupped by func name.
     */
    static $callable_functions;
    /**
     * @var array $hooks_already_sorted Cache of hook lists ordered by addon priority and groupped by hook name.
     */
    static $hooks_already_sorted = array();
    /**
     * @var array|null $hooks Function's local cache of hooks that have been registered by addons.
     */
    static $hooks = null;
    /**
     * @var bool $addons_initiated Function's local cache of addons' initialization state.
     */
    static $addons_initiated = false;
    // We use local hooks cache that was filled at previous fn_set_hook() call
    // only if addons were already initiated at that call.
    if ($addons_initiated) {
        $update_hooks_cache = false;
    } else {
        $update_hooks_cache = true;
        // Update local cache of addons' init state
        $addons_initiated = Registry::get('addons_initiated');
    }
    if ($hooks === null || $update_hooks_cache || defined('DISABLE_HOOK_CACHE')) {
        // Updating local hooks cache
        $hooks = Registry::get('hooks');
        $hooks_already_sorted = array();
    }
    $arg_count = func_num_args();
    if ($arg_count === 1) {
        $args = array();
    } elseif ($arg_count === 2) {
        $args = array(&$arg1);
    } elseif ($arg_count === 3) {
        $args = array(&$arg1, &$arg2);
    } elseif ($arg_count === 4) {
        $args = array(&$arg1, &$arg2, &$arg3);
    } elseif ($arg_count === 5) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4);
    } elseif ($arg_count === 6) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5);
    } elseif ($arg_count === 7) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6);
    } elseif ($arg_count === 8) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7);
    } elseif ($arg_count === 9) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8);
    } elseif ($arg_count === 10) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9);
    } elseif ($arg_count === 11) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9, &$arg10);
    } elseif ($arg_count === 12) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9, &$arg10, &$arg11);
    } elseif ($arg_count === 13) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9, &$arg10, &$arg11, &$arg12);
    } elseif ($arg_count === 14) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9, &$arg10, &$arg11, &$arg12, &$arg13);
    } elseif ($arg_count === 15) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9, &$arg10, &$arg11, &$arg12, &$arg13, &$arg14);
    } elseif ($arg_count === 16) {
        $args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9, &$arg10, &$arg11, &$arg12, &$arg13, &$arg14, &$arg15);
    }
    // Check for the core functions
    if (is_callable('fn_core_' . $hook_name)) {
        call_user_func_array('fn_core_' . $hook_name, $args);
    }
    $edition_acronym = fn_get_edition_acronym(PRODUCT_EDITION);
    if (!empty($edition_acronym) && function_exists("fn_{$edition_acronym}_{$hook_name}")) {
        call_user_func_array("fn_{$edition_acronym}_{$hook_name}", $args);
    }
    if (isset($hooks[$hook_name])) {
        // cache hooks sorting
        if (!isset($hooks_already_sorted[$hook_name])) {
            $hooks[$hook_name] = fn_sort_array_by_key($hooks[$hook_name], 'priority');
            $hooks_already_sorted[$hook_name] = true;
            Registry::set('hooks', $hooks, true);
        }
        foreach ($hooks[$hook_name] as $callback) {
            // cache if hook function callable
            if (!isset($callable_functions[$callback['func']])) {
                if (!is_callable($callback['func'])) {
                    throw new DeveloperException("Hook {$callback['func']} is not callable");
                }
                $callable_functions[$callback['func']] = true;
            }
            call_user_func_array($callback['func'], $args);
        }
    }
    return true;
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:100,代码来源:fn.control.php

示例5: fn_get_product_features_list

/**
 * Gets product features list
 *
 * @param array $product Array with product data
 * @param string $display_on Code determines zone (product/catalog page) for that features are selected
 * @param string $lang_code 2-letters language code
 * @return array Product features
 */
function fn_get_product_features_list($product, $display_on = 'C', $lang_code = CART_LANGUAGE)
{
    /**
     * Changes params before getting product features list
     *
     * @param array  $product    Array with product data
     * @param string $display_on Code determines zone (product/catalog page) for that features are selected
     * @param string $lang_code  2-letters language code
     */
    fn_set_hook('get_product_features_list_pre', $product, $display_on, $lang_code);
    $product_id = $product['product_id'];
    $features_list = array();
    if ($display_on == 'H') {
        $condition = " AND f.display_on_header = 'Y'";
    } elseif ($display_on == 'C') {
        $condition = " AND f.display_on_catalog = 'Y'";
    } elseif ($display_on == 'CP') {
        $condition = " AND (f.display_on_catalog = 'Y' OR f.display_on_product = 'Y')";
    } elseif ($display_on == 'A') {
        $condition = '';
    } else {
        $condition = " AND f.display_on_product = 'Y'";
    }
    $path = !empty($product['main_category']) ? explode('/', db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $product['main_category'])) : array();
    if (fn_allowed_for('ULTIMATE')) {
        $product['shared_product'] = fn_ult_is_shared_product($product_id);
        if ($product['shared_product'] == 'Y') {
            //we should get features for all categories, not only main
            $path = !empty($product['category_ids']) ? explode('/', implode('/', db_get_fields("SELECT id_path FROM ?:categories WHERE category_id IN (?a)", $product['category_ids']))) : array();
        }
    }
    $find_set = array(" f.categories_path = '' ");
    foreach ($path as $k => $v) {
        $find_set[] = db_quote(" FIND_IN_SET(?i, f.categories_path) ", $v);
    }
    $find_in_set = db_quote(" AND (?p)", implode('OR', $find_set));
    $condition .= $find_in_set;
    $fields = db_quote("v.feature_id, v.value, v.value_int, v.variant_id, f.feature_type, fd.description, fd.prefix, fd.suffix, vd.variant, f.parent_id, ft.filter_id, ft.field_type, f.position, gf.position as gposition");
    $join = db_quote("LEFT JOIN ?:product_features_values as v ON v.feature_id = f.feature_id " . " LEFT JOIN ?:product_features_descriptions as fd ON fd.feature_id = v.feature_id AND fd.lang_code = ?s" . " LEFT JOIN ?:product_feature_variants fv ON fv.variant_id = v.variant_id" . " LEFT JOIN ?:product_filters AS ft ON ft.feature_id = f.feature_id" . " LEFT JOIN ?:product_feature_variant_descriptions as vd ON vd.variant_id = fv.variant_id AND vd.lang_code = ?s" . " LEFT JOIN ?:product_features as gf ON gf.feature_id = f.parent_id AND gf.feature_type = ?s ", $lang_code, $lang_code, 'G');
    $condition = db_quote("f.status = 'A' AND IF(f.parent_id, (SELECT status FROM ?:product_features as df WHERE df.feature_id = f.parent_id), 'A') = 'A' AND v.product_id = ?i ?p AND (v.variant_id != 0 OR (f.feature_type != 'C' AND v.value != '') OR (f.feature_type = 'C') OR v.value_int != '') AND v.lang_code = ?s", $product_id, $condition, $lang_code);
    /**
     * Change SQL parameters before fetching product feature data
     *
     * @param string $fields    String of comma-separated SQL fields to be selected in an SQL-query
     * @param string $join      String with the complete JOIN information (JOIN type, tables and fields) for an SQL-query
     * @param string $condition String containing SQL-query condition possibly prepended with a logical operator (AND or OR)
     * @param array  $product   Array with product data
     * @param string $lang_code 2-letters language code
     */
    fn_set_hook('get_product_features_list_before_select', $fields, $join, $condition, $product, $display_on, $lang_code);
    $_data = db_get_array("SELECT {$fields} FROM ?:product_features as f {$join} WHERE {$condition} ORDER BY fd.description, fv.position");
    if (!empty($_data)) {
        foreach ($_data as $k => $feature) {
            if ($feature['feature_type'] == 'C') {
                if ($feature['value'] != 'Y' && $display_on != 'A') {
                    unset($_data[$k]);
                    continue;
                }
            }
            if (empty($features_list[$feature['feature_id']])) {
                $features_list[$feature['feature_id']] = $feature;
            }
            if (!empty($feature['variant_id'])) {
                // feature has several variants
                if (!empty($feature['filter_id'])) {
                    $range_data = array('range_id' => $feature['variant_id'], 'range_name' => $feature['variant'], 'feature_type' => $feature['feature_type']);
                    $features_list[$feature['feature_id']]['features_hash'] = fn_add_range_to_url_hash('', $range_data, $feature['field_type']);
                }
                $features_list[$feature['feature_id']]['variants'][$feature['variant_id']] = array('value' => $feature['value'], 'value_int' => $feature['value_int'], 'variant_id' => $feature['variant_id'], 'variant' => $feature['variant']);
            }
            unset($features_list[$feature['feature_id']]['filter_id']);
            unset($features_list[$feature['feature_id']]['field_type']);
        }
    }
    $groups = array();
    foreach ($features_list as $f_id => $data) {
        $groups[$data['parent_id']]['features'][$f_id] = $data;
        $groups[$data['parent_id']]['position'] = empty($data['parent_id']) ? $data['position'] : $data['gposition'];
    }
    $features_list = array();
    if (!empty($groups)) {
        $groups = fn_sort_array_by_key($groups, 'position');
        foreach ($groups as $g) {
            $g['features'] = fn_sort_array_by_key($g['features'], 'position');
            $features_list = fn_array_merge($features_list, $g['features']);
        }
    }
    unset($groups);
    foreach ($features_list as $f_id => $data) {
        unset($features_list[$f_id]['position']);
        unset($features_list[$f_id]['gposition']);
    }
//.........这里部分代码省略.........
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:101,代码来源:fn.catalog.php

示例6: fn_calculate_taxes


//.........这里部分代码省略.........
                                $shipping_rates[$shipping_id]['taxed_price'] += $_tax['tax_subtotal'];
                            }
                        }
                        $shipping_rates[$shipping_id]['inc_tax'] = true;
                    }
                    if (!empty($shipping_rates[$shipping_id]['rate']) && $shipping_rates[$shipping_id]['taxed_price'] > 0) {
                        $shipping_rates[$shipping_id]['taxed_price'] += $shipping_rates[$shipping_id]['rate'];
                    }
                }
                if (!isset($cart['chosen_shipping'][$group_key]) || $cart['chosen_shipping'][$group_key] != $shipping_id) {
                    continue;
                }
                // Add shipping taxes to "tax" array
                if (!empty($taxes)) {
                    foreach ($taxes as $tax_id => $tax) {
                        if (empty($subtotal[$tax_id])) {
                            $subtotal[$tax_id] = fn_init_tax_subtotals($tax);
                        }
                        $subtotal[$tax_id]['subtotal'] += $shipping['rate'];
                        $subtotal[$tax_id]['applies']['S'] += $shipping['rate'];
                        $subtotal[$tax_id]['applies']['items']['S'][$group_key][$shipping_id] = true;
                        /*                        if (!isset($subtotal[$tax_id]['groups'][$group_key]['shippings'])) {
                                                    $subtotal[$tax_id]['groups'][$group_key]['shippings'] = 0;
                                                }
                        
                                                $subtotal[$tax_id]['groups'][$group_key]['shippings'] += $shipping['rate'];*/
                        $priority_stack['shippings'][$group_key] = -1;
                        $applied_taxes['shippings'][$group_key] = 0;
                    }
                }
            }
        }
        if (!empty($subtotal)) {
            $subtotal = fn_sort_array_by_key($subtotal, 'priority');
        }
        // Apply DDC and calculate tax rates
        $calculated_taxes = array();
        if (empty($priority_stack)) {
            $priority_stack['products'][0] = -1;
            $priority_stack['shippings'][0] = -1;
            $applied_taxes['products'][0] = 0;
            $applied_taxes['shippings'][0] = 0;
        }
        foreach ($subtotal as $tax_id => $_st) {
            if (empty($_st['tax_id'])) {
                $_st['tax_id'] = $tax_id;
            }
            $product_tax = fn_calculate_tax_rates(array($_st), fn_format_price($_st['applies']['P'] * $ddc), 1, $auth, $cart);
            $shipping_tax = fn_calculate_tax_rates(array($_st), fn_format_price($_st['applies']['S']), 1, $auth, $cart);
            if (empty($product_tax) && empty($shipping_tax)) {
                continue;
            }
            if (empty($_st['groups'])) {
                $_st['groups'][0]['products'] = $_st['applies']['P'];
                $_st['groups'][0]['shippings'] = $_st['applies']['S'];
            }
            foreach ($_st['groups'] as $group_key => $applies) {
                $apply_tax_stack = array('products' => 0, 'shippings' => 0);
                if (!isset($priority_stack['products'][$group_key])) {
                    $priority_stack['products'][$group_key] = -1;
                }
                if (!isset($priority_stack['shippings'][$group_key])) {
                    $priority_stack['shippings'][$group_key] = -1;
                }
                if ($priority_stack['products'][$group_key] < 0 && !empty($applies['products'])) {
                    $priority_stack['products'][$group_key] = $_st['priority'];
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:67,代码来源:fn.cart.php

示例7: _renderGrid

 /**
  * Renders grid
  * @param  int    $grid Grid data to be rendered
  * @return string HTML code of rendered grid
  */
 private function _renderGrid($grid)
 {
     $content = '';
     if ($this->_area == 'A' || $grid['status'] != 'D') {
         if (isset($grid['children']) && !empty($grid['children'])) {
             $grid['children'] = fn_sort_array_by_key($grid['children'], 'grid_id');
             $parent_grid = $this->_parent_grid;
             $this->_parent_grid = $grid;
             foreach ($grid['children'] as $child_grid) {
                 $content .= $this->_renderGrid($child_grid);
             }
             $this->_parent_grid = $parent_grid;
         } else {
             $content .= $this->renderBlocks($grid);
         }
     }
     $this->_view->assign('content', $content);
     $this->_view->assign('parent_grid', $this->_parent_grid);
     $this->_view->assign('grid', $grid);
     return $this->_view->fetch($this->_theme . 'grid.tpl');
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:26,代码来源:RenderManager.php

示例8: die

*   (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev    *
*                                                                          *
* This  is  commercial  software,  only  users  who have purchased a valid *
* license  and  accept  to the terms of the  License Agreement can install *
* and use this program.                                                    *
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    return;
}
if ($mode == 'update' || $mode == 'manage') {
    $processors = Tygh::$app['view']->getTemplateVars('payment_processors');
    if (!empty($processors)) {
        foreach ($processors as &$processor) {
            if ($processor['processor'] == 'Kupivkredit') {
                $processor['russian'] = 'Y';
                $processor['type'] = 'R';
                $processor['position'] = 'a_99';
            }
        }
        $processors = fn_sort_array_by_key($processors, 'position');
        Tygh::$app['view']->assign('payment_processors', $processors);
    }
}
开发者ID:ambient-lounge,项目名称:site,代码行数:31,代码来源:payments.post.php

示例9: fn_gather_reward_points_data

function fn_gather_reward_points_data(&$product, &$auth, $get_point_info = true)
{
    // Check, if the product has any option points modifiers
    if (empty($product['options_update']) && !empty($product['product_options'])) {
        foreach ($product['product_options'] as $_id => $option) {
            if (!empty($product['product_options'][$_id]['variants'])) {
                foreach ($product['product_options'][$_id]['variants'] as $variant) {
                    if (!empty($variant['point_modifier']) && floatval($variant['point_modifier'])) {
                        $product['options_update'] = true;
                        break 2;
                    }
                }
            }
        }
    }
    if (isset($product['exclude_from_calculate']) || isset($product['points_info']['reward']) && !(Registry::get('runtime.controller') == 'products' && Registry::get('runtime.mode') == 'options') || $get_point_info == false) {
        return false;
    }
    if (!isset($product['main_category'])) {
        $product['main_category'] = db_get_field("SELECT category_id FROM ?:products_categories WHERE product_id = ?i AND link_type = 'M'", $product['product_id']);
    }
    $candidates = array(PRODUCT_REWARD_POINTS => $product['product_id'], CATEGORY_REWARD_POINTS => $product['main_category'], GLOBAL_REWARD_POINTS => 0);
    $reward_points = array();
    foreach ($candidates as $object_type => $object_id) {
        $_reward_points = fn_get_reward_points($object_id, $object_type, $auth['usergroup_ids']);
        if ($object_type == CATEGORY_REWARD_POINTS && !empty($_reward_points)) {
            // get the "override point" setting
            $category_is_op = db_get_field("SELECT is_op FROM ?:categories WHERE category_id = ?i", $_reward_points['object_id']);
        }
        if ($object_type == CATEGORY_REWARD_POINTS && (empty($_reward_points) || $category_is_op != 'Y')) {
            // if there is no points of main category of the "override point" setting is disabled
            // then get point of secondary categories
            $secondary_categories = db_get_fields("SELECT category_id FROM ?:products_categories WHERE product_id = ?i AND link_type = 'A'", $product['product_id']);
            if (!empty($secondary_categories)) {
                $secondary_categories_points = array();
                foreach ($secondary_categories as $value) {
                    $_rp = fn_get_reward_points($value, $object_type, $auth['usergroup_ids']);
                    if (isset($_rp['amount'])) {
                        $secondary_categories_points[] = $_rp;
                    }
                    unset($_rp);
                }
                if (!empty($secondary_categories_points)) {
                    $sorted_points = fn_sort_array_by_key($secondary_categories_points, 'amount', Registry::get('addons.reward_points.several_points_action') == 'minimal_absolute' || Registry::get('addons.reward_points.several_points_action') == 'minimal_percentage' ? SORT_ASC : SORT_DESC);
                    $_reward_points = array_shift($sorted_points);
                }
            }
            if (!isset($_reward_points['amount'])) {
                if (Registry::get('addons.reward_points.higher_level_extract') == 'Y' && !empty($candidates[$object_type])) {
                    $id_path = db_get_field("SELECT REPLACE(id_path, '{$candidates[$object_type]}', '') FROM ?:categories WHERE category_id = ?i", $candidates[$object_type]);
                    if (!empty($id_path)) {
                        $c_ids = explode('/', trim($id_path, '/'));
                        $c_ids = array_reverse($c_ids);
                        foreach ($c_ids as $category_id) {
                            $__reward_points = fn_get_reward_points($category_id, $object_type, $auth['usergroup_ids']);
                            if (!empty($__reward_points)) {
                                // get the "override point" setting
                                $_category_is_op = db_get_field("SELECT is_op FROM ?:categories WHERE category_id = ?i", $__reward_points['object_id']);
                                if ($_category_is_op == 'Y') {
                                    $category_is_op = $_category_is_op;
                                    $_reward_points = $__reward_points;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!empty($_reward_points) && ($object_type == GLOBAL_REWARD_POINTS || $object_type == PRODUCT_REWARD_POINTS && $product['is_op'] == 'Y' || $object_type == CATEGORY_REWARD_POINTS && (!empty($category_is_op) && $category_is_op == 'Y'))) {
            // if global points or category points (and override points is enabled) or product points (and override points is enabled)
            $reward_points = $_reward_points;
            break;
        }
    }
    if (isset($reward_points['amount'])) {
        if ((defined('ORDER_MANAGEMENT') || Registry::get('runtime.controller') == 'checkout') && isset($product['subtotal']) && isset($product['original_price'])) {
            if (Registry::get('addons.reward_points.points_with_discounts') == 'Y' && $reward_points['amount_type'] == 'P' && !empty($product['discounts'])) {
                $product['discount'] = empty($product['discount']) ? 0 : $product['discount'];
                $reward_points['coefficient'] = floatval($product['price']) ? ($product['price'] * $product['amount'] - $product['discount']) / $product['price'] * $product['amount'] / pow($product['amount'], 2) : 0;
            } else {
                $reward_points['coefficient'] = 1;
            }
        } else {
            $reward_points['coefficient'] = Registry::get('addons.reward_points.points_with_discounts') == 'Y' && $reward_points['amount_type'] == 'P' && isset($product['discounted_price']) ? $product['discounted_price'] / $product['price'] : 1;
        }
        if (isset($product['extra']['configuration'])) {
            if ($reward_points['amount_type'] == 'P') {
                // for configurable product calc reward points only for base price
                $price = $product['original_price'];
                if (!empty($product['discount'])) {
                    $price -= $product['discount'];
                }
                $reward_points['amount'] = $price * $reward_points['amount'] / 100;
            } else {
                $points_info = Registry::get("runtime.product_configurator.points_info");
                if (!empty($points_info[$product['product_id']])) {
                    $reward_points['amount'] = $points_info[$product['product_id']]['reward'];
                    $reward_points['coefficient'] = 1;
                }
//.........这里部分代码省略.........
开发者ID:ambient-lounge,项目名称:site,代码行数:101,代码来源:func.php

示例10: fn_get_addons

/**
 * Gets addons list
 *
 * @param array $params search params
 * @param int $items_per_page items per page for pagination
 * @param string $lang_code language code
 * @return array addons list and filtered search params
 */
function fn_get_addons($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    $params = LastView::instance()->update('addons', $params);
    $default_params = array('type' => 'any');
    $params = array_merge($default_params, $params);
    $addons = array();
    $sections = Settings::instance()->getAddons();
    $all_addons = fn_get_dir_contents(Registry::get('config.dir.addons'), true, false);
    $installed_addons = db_get_hash_array('SELECT a.addon, a.status, b.name as name, b.description as description, a.separate, a.unmanaged, a.has_icon ' . 'FROM ?:addons as a LEFT JOIN ?:addon_descriptions as b ON b.addon = a.addon AND b.lang_code = ?s' . 'ORDER BY b.name ASC', 'addon', $lang_code);
    foreach ($installed_addons as $key => $addon) {
        $installed_addons[$key]['has_sections'] = Settings::instance()->sectionExists($sections, $addon['addon']);
        $installed_addons[$key]['has_options'] = $installed_addons[$key]['has_sections'] ? Settings::instance()->optionsExists($addon['addon'], 'ADDON') : false;
        // Check add-on snaphot
        if (!fn_check_addon_snapshot($key)) {
            $installed_addons[$key]['status'] = 'D';
            $installed_addons[$key]['snapshot_correct'] = false;
        } else {
            $installed_addons[$key]['snapshot_correct'] = true;
        }
    }
    foreach ($all_addons as $addon) {
        $addon_scheme = SchemesManager::getScheme($addon);
        if (in_array($params['type'], array('any', 'installed', 'active', 'disabled'))) {
            $search_status = $params['type'] == 'active' ? 'A' : ($params['type'] == 'disabled' ? 'D' : '');
            if (!empty($installed_addons[$addon])) {
                // exclude unmanaged addons from the list
                if ($installed_addons[$addon]['unmanaged'] == true) {
                    continue;
                }
                if (!empty($search_status) && $installed_addons[$addon]['status'] != $search_status) {
                    continue;
                }
                $addons[$addon] = $installed_addons[$addon];
                if ($addon_scheme != false && !$addon_scheme->getUnmanaged()) {
                    $addons[$addon]['originals'] = $addon_scheme->getOriginals();
                }
                fn_update_lang_objects('installed_addon', $addons[$addon]);
                // Generate custom description
                $func = 'fn_addon_dynamic_description_' . $addon;
                if (function_exists($func)) {
                    $addons[$addon]['description'] = $func($addons[$addon]['description']);
                }
            }
        }
        if (empty($installed_addons[$addon]) && empty($params['for_company']) && in_array($params['type'], array('any', 'not_installed'))) {
            if ($addon_scheme != false && !$addon_scheme->getUnmanaged()) {
                $addons[$addon] = array('status' => 'N', 'name' => $addon_scheme->getName(), 'snapshot_correct' => fn_check_addon_snapshot($addon), 'description' => $addon_scheme->getDescription(), 'has_icon' => $addon_scheme->hasIcon());
            }
        }
    }
    if (!empty($params['q'])) {
        foreach ($addons as $addon => $addon_data) {
            if (!preg_match('/' . preg_quote($params['q'], '/') . '/ui', $addon_data['name'], $m)) {
                unset($addons[$addon]);
            }
        }
    }
    $addons = fn_sort_array_by_key($addons, 'name', SORT_ASC);
    return array($addons, $params);
}
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:68,代码来源:fn.addons.php

示例11: _buildGridStructure

 /**
  * @param ExSimpleXmlElement $parent
  * @param $grids
  * @param array  $except_fields
  * @param string $lang_code
  */
 private function _buildGridStructure(&$parent, $grids, $except_fields = array(), $lang_code = DESCR_SL)
 {
     $except_block_fields = array_flip(array('block_id', 'snapping_id', 'grid_id', 'company_id'));
     foreach ($grids as $grid) {
         $xml_grid = $parent->addChild('grid');
         $blocks = Block::instance($this->_company_id)->getList(array('?:bm_snapping.*', '?:bm_blocks.*'), array($grid['grid_id']));
         if (!empty($blocks)) {
             $blocks = $blocks[$grid['grid_id']];
         }
         $attrs = array_diff_key($grid, $except_fields);
         foreach ($attrs as $attr => $value) {
             $xml_grid->addAttribute($attr, $value);
         }
         if (!empty($grid['children'])) {
             $grid['children'] = fn_sort_array_by_key($grid['children'], 'grid_id');
             $this->_buildGridStructure($xml_grid, $grid['children'], $except_fields, $lang_code);
         }
         if (!empty($blocks)) {
             $xml_blocks = $xml_grid->addChild('blocks');
             foreach ($blocks as $block_id => $block) {
                 $block_descr = Block::instance($this->_company_id)->getFullDescription($block['block_id']);
                 $block = array_merge(Block::instance($this->_company_id)->getById($block['block_id']), $block);
                 $block = array_diff_key($block, $except_block_fields);
                 $xml_block = $xml_blocks->addChild('block');
                 $this->_buildAttrStructure($xml_block, $block);
                 $xml_translations = $xml_block->addChild('translations');
                 foreach ($block_descr as $_lang_code => $data) {
                     if ($_lang_code == $lang_code) {
                         // We do not needed default language
                         continue;
                     }
                     $xml_translation = $xml_translations->addChildCData('translation', $data['name']);
                     $xml_translation->addAttribute('lang_code', $_lang_code);
                     unset($xml_translation);
                 }
                 $contents = Block::instance($this->_company_id)->getAllContents($block_id);
                 $xml_contents = $xml_block->addChild('contents');
                 foreach ($contents as $content) {
                     if (!empty($content['lang_code']) && $content['lang_code'] == $lang_code) {
                         continue;
                     }
                     if (!empty($content['content'])) {
                         $this->_buildAttrStructure($xml_contents, array('item' => array_diff_key($content, $except_block_fields)));
                     }
                 }
             }
         }
     }
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:55,代码来源:Exim.php

示例12: db_get_array

    $privileges_data = db_get_array("SELECT a.* FROM ?:privileges as a ORDER BY a.section_id");
    $_preload = array();
    foreach ($privileges_data as $key => $privilege) {
        $section = 'privilege_sections.' . $privilege['section_id'];
        if (!in_array($section, $_preload)) {
            $_preload[] = $section;
        }
        $_preload[] = 'privileges.' . $privilege['privilege'];
    }
    fn_preload_lang_vars($_preload);
    $_sections = array();
    foreach ($privileges_data as $key => $privilege) {
        $_sections[$privilege['section_id']] = __('privilege_sections.' . $privilege['section_id']);
        $privileges_data[$key]['description'] = __('privileges.' . $privilege['privilege']);
    }
    $privileges_data = fn_sort_array_by_key($privileges_data, 'description');
    asort($_sections);
    $privileges = array_fill_keys(array_keys($_sections), array());
    foreach ($privileges_data as $privilege) {
        $privilege['section'] = $_sections[$privilege['section_id']];
        $privileges[$privilege['section_id']][] = $privilege;
    }
    Registry::get('view')->assign('usergroup_privileges', $usergroup_privileges);
    Registry::get('view')->assign('usergroup_name', $usergroup_name);
    Registry::get('view')->assign('privileges', $privileges);
    Registry::set('navigation.tabs', $tabs);
} elseif ($mode == 'requests') {
    list($requests, $search) = fn_get_usergroup_requests($_REQUEST, Registry::get('settings.Appearance.admin_orders_per_page'));
    Registry::get('view')->assign('usergroup_requests', $requests);
    Registry::get('view')->assign('search', $search);
}
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:31,代码来源:usergroups.php

示例13: fn_get_tags

function fn_get_tags($params = array(), $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('tags', $params);
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    /**
     * Change parameters for getting tags
     *
     * @param array $params Params list
     * @param int $items_per_page Tags per page
     * @param array $default_params Default params
     */
    fn_set_hook('get_tags_pre', $params, $items_per_page, $default_params);
    $params = array_merge($default_params, $params);
    $fields = array('?:tags.tag_id', '?:tag_links.object_id', '?:tag_links.object_type', '?:tags.tag', '?:tags.status', 'COUNT(?:tag_links.tag_id) as popularity');
    $joins = array('LEFT JOIN ?:tag_links ON ?:tag_links.tag_id = ?:tags.tag_id');
    $conditions = fn_tags_build_conditions($params);
    // Define sort fields
    $sortings = array('tag' => '?:tags.tag', 'status' => '?:tags.status', 'popularity' => 'popularity', 'users' => 'users');
    $sorting = db_sort($params, $sortings, 'tag', 'asc');
    $group = 'GROUP BY ?:tags.tag_id';
    /**
     * Gets tags
     *
     * @param array $params Params list
     * @param int $items_per_page Tags per page
     * @param array $fields List of SQL fields to be selected in an SQL-query
     * @param array $joins List of strings with the complete JOIN information (JOIN type, tables and fields) for an SQL-query
     * @param string $conditions String containing the SQL-query conditions prepended with a logical operator (AND or OR)
     * @param string $group String containing the SQL-query GROUP BY field
     * @param string $sorting String containing the SQL-query ORDER BY field
     */
    fn_set_hook('get_tags', $params, $items_per_page, $fields, $joins, $conditions, $group, $sorting);
    $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(DISTINCT(?:tags.tag_id)) FROM ?:tags LEFT JOIN ?:tag_links ON ?:tags.tag_id = ?:tag_links.tag_id WHERE 1 ?p", $conditions);
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $tags = db_get_hash_array("SELECT " . implode(', ', $fields) . " " . "FROM ?:tags " . implode(' ', $joins) . " WHERE 1 ?p {$group} {$sorting} {$limit}", 'tag_id', $conditions);
    if (!empty($params['count_objects'])) {
        $objs = db_get_array("SELECT tag_id, COUNT(DISTINCT(object_id)) as count, object_type " . "FROM ?:tag_links WHERE tag_id IN (?n) GROUP BY tag_id, object_type", array_keys($tags));
        foreach ($objs as $v) {
            $tags[$v['tag_id']]['objects_count'][$v['object_type']] = $v['count'];
        }
    }
    // Generate popularity level
    foreach ($tags as $k => $v) {
        $level = ceil(log($v['popularity']));
        $tags[$k]['level'] = $level > TAGS_MAX_LEVEL ? TAGS_MAX_LEVEL : $level;
    }
    if (!empty($params['sort_popular'])) {
        $tags = fn_sort_array_by_key($tags, 'tag', SORT_ASC);
    }
    /**
     * Change tags
     *
     * @param array $params Params list
     * @param int $items_per_page Tags per page
     * @param array $tags Tags
     */
    fn_set_hook('get_tags_post', $params, $items_per_page, $tags);
    return array($tags, $params);
}
开发者ID:arpad9,项目名称:bygmarket,代码行数:65,代码来源:func.php

示例14: _checkStoreCost

 private function _checkStoreCost($stores)
 {
     $pickup_surcharge = 0;
     $check = false;
     $group_key = $this->_shipping_info['keys']['group_key'];
     $shipping_id = $this->_shipping_info['keys']['shipping_id'];
     if (!empty($_SESSION['cart']['select_store'])) {
         $select_store = $_SESSION['cart']['select_store'];
         if (!empty($select_store[$group_key][$shipping_id])) {
             $store_id = $select_store[$group_key][$shipping_id];
             if (!empty($stores[$store_id]['pickup_surcharge'])) {
                 $pickup_surcharge = $stores[$store_id]['pickup_surcharge'];
             } else {
                 $check = true;
             }
         } elseif (!empty($stores)) {
             $check = true;
         }
     } else {
         $check = true;
     }
     if ($check) {
         $stores = fn_sort_array_by_key($stores, 'pickup_surcharge');
         $first = array_shift($stores);
         $pickup_surcharge = $first['pickup_surcharge'];
         $_SESSION['cart']['select_store'][$group_key][$shipping_id] = $first['store_location_id'];
         $_SESSION['cart']['pickup_surcharge'][$group_key][$shipping_id] = $pickup_surcharge;
     }
     return $pickup_surcharge;
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:30,代码来源:Pickup.php

示例15: _sort

 /**
  * Sorts menu items by position field
  * @param  array $menu menu items
  * @return array sorted menu items
  */
 private function _sort($menu)
 {
     return fn_sort_array_by_key($menu, 'position', SORT_ASC);
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:9,代码来源:BackendMenu.php


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