本文整理汇总了PHP中fn_paginate函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_paginate函数的具体用法?PHP fn_paginate怎么用?PHP fn_paginate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fn_paginate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fn_get_seo_rules
function fn_get_seo_rules($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
$lang_code = fn_get_corrected_seo_lang_code($lang_code);
$global_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' GROUP BY dispatch");
$local_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s", $lang_code);
if ($diff = array_diff($global_total, $local_total)) {
foreach ($diff as $disp) {
fn_create_seo_name(0, 's', str_replace('.', '-', $disp), 0, $disp, DESCR_SL);
}
}
// Init filter
$params = fn_init_view('seo_rules', $params);
// Set default values to input params
$params['page'] = empty($params['page']) ? 1 : $params['page'];
// default page is 1
$condition = '';
if (isset($params['name']) && fn_string_no_empty($params['name'])) {
$condition .= db_quote(" AND name LIKE ?l", "%" . trim($params['name']) . "%");
}
if (isset($params['controller']) && fn_string_no_empty($params['controller'])) {
$condition .= db_quote(" AND dispatch LIKE ?l", "%" . trim($params['controller']) . "%");
}
$limit = '';
if (!empty($items_per_page)) {
$total = db_get_field("SELECT COUNT(*) FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
$limit = fn_paginate($params['page'], $total, $items_per_page);
}
$seo_data = db_get_array("SELECT name, dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p ORDER BY dispatch {$limit}", $lang_code, $condition);
return array($seo_data, $params);
}
示例2: fn_get_discussion_posts
function fn_get_discussion_posts($thread_id = 0, $page = 0, $first_limit = '', $random = 'N')
{
$sets = Registry::get('addons.discussion');
$discussion_object_types = fn_get_discussion_objects();
if (empty($thread_id)) {
return false;
}
$thread_data = db_get_row("SELECT type, object_type FROM ?:discussion WHERE thread_id = ?i", $thread_id);
if ($thread_data['type'] == 'D') {
return false;
}
$join = $fields = '';
if ($thread_data['type'] == 'C' || $thread_data['type'] == 'B') {
$join .= " LEFT JOIN ?:discussion_messages ON ?:discussion_messages.post_id = ?:discussion_posts.post_id ";
$fields .= ", ?:discussion_messages.message";
}
if ($thread_data['type'] == 'R' || $thread_data['type'] == 'B') {
$join .= " LEFT JOIN ?:discussion_rating ON ?:discussion_rating.post_id = ?:discussion_posts.post_id ";
$fields .= ", ?:discussion_rating.rating_value";
}
$status_cond = AREA == 'A' ? '' : " AND ?:discussion_posts.status = 'A'";
$total_pages = db_get_field("SELECT COUNT(*) FROM ?:discussion_posts WHERE thread_id = ?i {$status_cond}", $thread_id);
if ($first_limit != '') {
$limit = "LIMIT {$first_limit}";
} else {
$limit = fn_paginate($page, $total_pages, $sets[$discussion_object_types[$thread_data['object_type']] . '_posts_per_page']);
}
$order_by = $random == 'N' ? '?:discussion_posts.timestamp DESC' : 'RAND()';
return db_get_array("SELECT ?:discussion_posts.* {$fields} FROM ?:discussion_posts {$join} WHERE ?:discussion_posts.thread_id = ?i {$status_cond} ORDER BY ?p {$limit}", $thread_id, $order_by);
}
示例3: fn_get_logs
function fn_get_logs($params, $items_per_page = null)
{
// Init filter
$params = fn_init_view('logs', $params);
if ($items_per_page === null) {
$items_per_page = Registry::get('settings.Appearance.admin_elements_per_page');
}
$sortings = array('timestamp' => '?:logs.timestamp', 'user' => array('?:users.lastname', '?:users.firstname'));
$directions = array('asc' => 'asc', 'desc' => 'desc');
$fields = array('?:logs.*', '?:users.firstname', '?:users.lastname');
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'] = 'timestamp';
$params['sort_order'] = 'desc';
}
$params['page'] = empty($params['page']) ? 1 : $params['page'];
if (is_array($sortings[$params['sort_by']])) {
$sorting = join(' ' . $directions[$params['sort_order']] . ', ', $sortings[$params['sort_by']]) . ' ' . $directions[$params['sort_order']];
} else {
$sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
}
$join = "LEFT JOIN ?:users USING(user_id)";
$condition = '';
if (!empty($params['period']) && $params['period'] != 'A') {
list($time_from, $time_to) = fn_create_periods($params);
$condition .= db_quote(" AND (?:logs.timestamp >= ?i AND ?:logs.timestamp <= ?i)", $time_from, $time_to);
}
if (isset($params['q_user']) && fn_string_no_empty($params['q_user'])) {
$condition .= db_quote(" AND (?:users.lastname LIKE ?l OR ?:users.firstname LIKE ?l)", "%" . trim($params['q_user']) . "%", "%" . trim($params['q_user']) . "%");
}
if (!empty($params['q_type'])) {
$condition .= db_quote(" AND (?:logs.type LIKE ?l OR ?:logs.type LIKE ?l)", "%{$params['q_type']}%", "%{$params['q_type']}%");
}
if (!empty($params['q_action'])) {
$condition .= db_quote(" AND (?:logs.action LIKE ?l OR ?:logs.action LIKE ?l)", "%{$params['q_action']}%", "%{$params['q_action']}%");
}
$limit = '';
$total = 0;
if (!empty($items_per_page)) {
$total = db_get_field("SELECT COUNT(DISTINCT(?:logs.log_id)) FROM ?:logs ?p WHERE 1 ?p", $join, $condition);
$limit = fn_paginate($params['page'], $total, $items_per_page);
}
$data = db_get_array("SELECT " . join(', ', $fields) . " FROM ?:logs ?p WHERE 1 ?p ORDER BY {$sorting} {$limit}", $join, $condition);
if (!$total) {
$total = count($data);
}
foreach ($data as $k => $v) {
$data[$k]['backtrace'] = !empty($v['backtrace']) ? unserialize($v['backtrace']) : array();
$data[$k]['content'] = !empty($v['content']) ? unserialize($v['content']) : array();
}
return array($data, $params, $total);
}
示例4: fn_get_states
function fn_get_states($country = '', $lang_code = CART_LANGUAGE, $paginate = false)
{
if (empty($country)) {
return '';
}
$limit = '';
if ($paginate == true) {
$state_count = db_get_field("SELECT COUNT(*) FROM ?:states WHERE country_code = ?s", $country);
$limit = fn_paginate(@$_REQUEST['page'], $state_count, Registry::get('settings.Appearance.admin_elements_per_page'));
}
return db_get_array("SELECT a.state_id, a.country_code, a.code, a.status, b.state FROM ?:states as a LEFT JOIN ?:state_descriptions as b ON b.state_id = a.state_id AND b.lang_code = ?s WHERE a.country_code = ?s ORDER BY b.state {$limit}", $lang_code, $country);
}
示例5: 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);
}
示例6: fn_get_companies
function fn_get_companies($params, &$auth, $items_per_page = 0)
{
// Init filter
$_view = 'companies';
$params = fn_init_view($_view, $params);
// Set default values to input params
$params['page'] = empty($params['page']) ? 1 : $params['page'];
// Define fields that should be retrieved
$fields = array("?:companies.company_id", "?:companies.email", "?:companies.company", "?:companies.timestamp", "?:companies.status");
// Define sort fields
$sortings = array('id' => "?:users.user_id", 'company' => "?:companies.company", 'email' => "?:companies.email", 'date' => "?:companies.timestamp", 'status' => "?:companies.status");
$directions = array('asc' => 'asc', 'desc' => 'desc');
$condition = $join = $group = '';
$condition .= fn_get_company_condition('?:companies.company_id');
$group .= " GROUP BY ?:companies.company_id";
/*
* TODO search
if (!empty($params['company'])) {
$condition .= db_quote(" AND ?:users.company LIKE ?l", "%$params[company]%");
}
*/
fn_set_hook('get_companies', $params, $fields, $sortings, $condition, $join);
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'] = 'company';
}
$sorting = (is_array($sortings[$params['sort_by']]) ? implode(' ' . $directions[$params['sort_order']] . ', ', $sortings[$params['sort_by']]) : $sortings[$params['sort_by']]) . " " . $directions[$params['sort_order']];
// Reverse sorting (for usage in view)
$params['sort_order'] = $params['sort_order'] == 'asc' ? 'desc' : 'asc';
// Paginate search results
$limit = '';
if (!empty($items_per_page)) {
$total = db_get_field("SELECT COUNT(DISTINCT(?:companies.company_id)) FROM ?:companies {$join} WHERE 1 {$condition}");
$limit = fn_paginate($params['page'], $total, $items_per_page);
}
$companies = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:companies {$join} WHERE 1 {$condition} {$group} ORDER BY {$sorting} {$limit}");
return array($companies, $params);
}
示例7: array
}
return array(CONTROLLER_STATUS_OK, "mailing_lists.manage");
}
if ($mode == 'update') {
fn_add_breadcrumb(fn_get_lang_var('newsletters'), "newsletters.manage");
$view->assign('autoresponders', fn_get_newsletters(array('type' => NEWSLETTER_TYPE_AUTORESPONDER, 'only_available' => false), DESCR_SL));
$view->assign('mailing_list', fn_get_mailing_list_data($_REQUEST['list_id'], DESCR_SL));
} elseif ($mode == 'delete') {
if (!empty($_REQUEST['list_id'])) {
db_query("DELETE FROM ?:common_descriptions WHERE object_id = ?i AND object_holder='mailing_lists'", $_REQUEST['list_id']);
db_query("DELETE FROM ?:mailing_lists WHERE list_id = ?i", $_REQUEST['list_id']);
db_query("DELETE FROM ?:user_mailing_lists WHERE list_id = ?i", $_REQUEST['list_id']);
$_mailing_lists = fn_get_mailing_lists(array('only_available' => false, 'limit' => $limit), DESCR_SL);
if (empty($_mailing_lists)) {
$view->display('addons/news_and_emails/views/mailing_lists/manage.tpl');
}
}
exit;
} elseif ($mode == 'manage') {
$total_pages = db_get_field("SELECT COUNT(*) FROM ?:mailing_lists");
$limit = fn_paginate(@$_REQUEST['page'], $total_pages, Registry::get('settings.Appearance.admin_elements_per_page'));
$mailing_lists = fn_get_mailing_lists(array('only_available' => false, 'limit' => $limit), DESCR_SL);
$subscribers = db_get_hash_array("SELECT * FROM ?:subscribers", 'subscriber_id');
foreach ($mailing_lists as &$list) {
$list['subscribers_num'] = db_get_field("SELECT COUNT(*) FROM ?:user_mailing_lists WHERE list_id={$list['list_id']}");
}
$view->assign('mailing_lists', $mailing_lists);
$view->assign('autoresponders', fn_get_newsletters(array('type' => NEWSLETTER_TYPE_AUTORESPONDER, 'only_available' => false), DESCR_SL));
$view->assign('subscribers', $subscribers);
}
/** /Body **/
示例8: fn_get_usergroup_requests
function fn_get_usergroup_requests($params, $items_per_page = 0, $status = 'P', $lang_code = CART_LANGUAGE)
{
// Set default values to input params
$params['page'] = empty($params['page']) ? 1 : $params['page'];
// default page is 1
$fields = array("?:usergroup_links.user_id", "?:usergroup_links.link_id", "?:usergroup_links.usergroup_id", "?:usergroup_links.status", "?:users.firstname", "?:users.lastname", "?:usergroup_descriptions.usergroup");
$sortings = array('customer' => array("?:users.lastname", "?:users.firstname"), 'usergroup' => "?:usergroup_descriptions.usergroup", 'status' => "?:usergroup_links.status");
$directions = array('asc' => 'asc', 'desc' => 'desc');
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'] = 'customer';
}
$sorting = (is_array($sortings[$params['sort_by']]) ? implode(' ' . $directions[$params['sort_order']] . ', ', $sortings[$params['sort_by']]) : $sortings[$params['sort_by']]) . " " . $directions[$params['sort_order']];
// Reverse sorting (for usage in view)
$params['sort_order'] = $params['sort_order'] == 'asc' ? 'desc' : 'asc';
$condition = '';
if (!empty($params['cname'])) {
$arr = explode(' ', $params['cname']);
if (sizeof($arr) == 2) {
$condition .= db_quote(" AND ?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l", "%{$arr['0']}%", "%{$arr['1']}%");
} else {
$condition .= db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%{$params['cname']}%", "%{$params['cname']}%");
}
}
if (!empty($params['ugname'])) {
$condition .= db_quote(" AND ?:usergroup_descriptions.usergroup LIKE ?l", "%{$params['ugname']}%");
}
$join = db_quote("LEFT JOIN ?:users ON ?:usergroup_links.user_id = ?:users.user_id LEFT JOIN ?:usergroup_descriptions ON ?:usergroup_links.usergroup_id = ?:usergroup_descriptions.usergroup_id AND ?:usergroup_descriptions.lang_code = ?s", $lang_code);
$limit = '';
if (!empty($items_per_page)) {
$total = db_get_field("SELECT COUNT(?:usergroup_links.link_id) FROM ?:usergroup_links {$join} WHERE ?:usergroup_links.status = ?s {$condition}", $status);
$limit = fn_paginate($params['page'], $total, $items_per_page);
}
$requests = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:usergroup_links {$join} WHERE ?:usergroup_links.status = ?s {$condition} ORDER BY {$sorting} {$limit}", $status);
return array($requests, $params);
}
示例9: fn_get_available_group
$view->assign('avail_positions', fn_get_available_group($selected_section, 0, DESCR_SL));
$view->assign('specific_settings', fn_process_specific_settings(fn_get_block_specific_settings()));
$view->assign('location', $selected_section);
$view->assign('blocks', $blocks);
} elseif ($mode == 'manage_items') {
$view->assign('location', $_REQUEST['location']);
$view->assign('block', fn_get_block_data($_REQUEST['block_id'], CART_LANGUAGE, false, $_REQUEST['location']));
$object_id = empty($_REQUEST['object_id']) ? '' : $_REQUEST['object_id'];
$view->assign('object_id', $object_id);
$view->assign('redir_url', empty($_REQUEST['redir_url']) ? '' : $_REQUEST['redir_url']);
$block_items = db_get_field("SELECT item_ids FROM ?:block_links WHERE block_id = ?i AND object_id = ?i", $_REQUEST['block_id'], $object_id);
if (!empty($block_items)) {
$items_ids = explode(',', $block_items);
$page = empty($_REQUEST['page']) ? 1 : $_REQUEST['page'];
$items_per_page = Registry::get('settings.Appearance.admin_elements_per_page');
fn_paginate($page, count($items_ids), $items_per_page);
if (!empty($_SESSION['items_per_page'])) {
$items_per_page = $_SESSION['items_per_page'];
}
$start_pos = ($page - 1) * $items_per_page;
$view->assign('start_position', $start_pos);
$view->assign('block_items', array_slice($items_ids, $start_pos, $items_per_page));
} else {
list($blocks) = fn_get_blocks(array('location' => $_REQUEST['location']));
if (!empty($blocks)) {
$view->assign('block', fn_get_selected_block_data(array('selected_block_id' => $_REQUEST['block_id']), $blocks, $_REQUEST['object_id'], $_REQUEST['location']));
}
}
} elseif ($mode == 'specific_settings') {
$specific_settings = fn_get_block_specific_settings();
if (!empty($specific_settings[$_REQUEST['type']]) && !empty($specific_settings[$_REQUEST['type']][$_REQUEST['value']])) {
示例10: fn_pay_affiliates
function fn_pay_affiliates($params, $do_pagination = false, $page = 1)
{
// Init filter
$params = fn_init_view('pay_affiliates', $params);
// Set default values to input params
$params['page'] = empty($params['page']) ? 1 : $params['page'];
// default page is 1
// Define sort fields
$sortings = array('username' => 'user_login', 'email' => 'email', 'partner' => 'firstname', 'amount' => 'amount', 'awaiting_amount' => 'awaiting_amount', 'date' => 'date');
$directions = array('asc' => 'asc', 'desc' => 'desc');
if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) {
$params['sort_order'] = 'desc';
}
$sorting_direction = $directions[$params['sort_order']];
if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
$params['sort_by'] = 'username';
}
$sort_by = $params['sort_by'];
if ($sort_by == 'date' || $sort_by == 'awaiting_amount') {
$sort_by = 'username';
}
$sorting = (is_array($sortings[$sort_by]) ? implode(' ' . $sorting_direction . ', ', $sortings[$sort_by]) : $sortings[$sort_by]) . " " . $sorting_direction;
// Reverse sorting (for usage in view)
$params['sort_order'] = $params['sort_order'] == 'asc' ? 'desc' : 'asc';
$pay_filter = array();
$pay_filter['min_payment'] = empty($params['min_payment']) ? '' : 'Y';
$pay_filter['last_payout'] = empty($params['last_payout']) ? '' : 'Y';
$pay_filter['amount_from'] = empty($params['amount_from']) ? '' : floatval($params['amount_from']);
$pay_filter['amount_to'] = empty($params['amount_to']) ? '' : floatval($params['amount_to']);
$_SESSION['pay_filter'] = $pay_filter;
$join = $condition = $group = '';
$having = array();
if (!empty($params['min_payment'])) {
$having[] = 'SUM(pa.amount) >= AVG(ap.min_payment)';
}
if (isset($params['amount_from']) && fn_is_numeric($params['amount_from'])) {
$having[] = db_quote("SUM(pa.amount) >= ?d", $params['amount_from']);
}
if (isset($params['amount_to']) && fn_is_numeric($params['amount_to'])) {
$having[] = db_quote("SUM(pa.amount) <= ?d", $params['amount_to']);
}
if (!empty($params['last_payout'])) {
$condition .= db_quote(" AND pa.date < ?i", fn_parse_date(fn_get_date_of_payment_period(), true));
}
$group = 'GROUP BY pa.partner_id' . (empty($having) ? ' ' : ' HAVING (' . implode(') AND (', $having) . ') ');
if ($do_pagination) {
if (empty($page)) {
$page = 1;
}
$cnt_list_stats = db_get_fields("SELECT DISTINCT(pa.partner_id) FROM ?:aff_partner_actions as pa LEFT JOIN ?:aff_partner_profiles as pp ON pa.partner_id = pp.user_id LEFT JOIN ?:affiliate_plans as ap ON ap.plan_id = pp.plan_id WHERE pa.approved = 'Y' AND pa.payout_id = 0 ?p ?p", $condition, $group);
$limit = fn_paginate($page, count($cnt_list_stats));
} else {
$limit = '';
}
$partner_balances = db_get_hash_array("SELECT pa.partner_id, u.user_login, u.firstname, u.lastname, u.email, SUM(amount) as amount FROM ?:aff_partner_actions as pa LEFT JOIN ?:users as u ON pa.partner_id = u.user_id LEFT JOIN ?:aff_partner_profiles as pp ON pa.partner_id = pp.user_id LEFT JOIN ?:affiliate_plans as ap ON ap.plan_id = pp.plan_id WHERE pa.approved = 'Y' AND payout_id = 0 ?p ?p ORDER BY {$sorting} {$limit}", 'partner_id', $condition, $group);
$_partners = db_get_hash_array("SELECT pa.partner_id, SUM(amount) as amount FROM ?:aff_partner_actions as pa LEFT JOIN ?:aff_partner_profiles as pp ON pa.partner_id = pp.user_id LEFT JOIN ?:affiliate_plans as ap ON ap.plan_id = pp.plan_id WHERE pa.approved = 'N' AND payout_id = 0 GROUP BY pa.partner_id ORDER BY amount {$sorting_direction}", 'partner_id');
$last_payout_dates = db_get_hash_array("SELECT partner_id, MAX(date) as date FROM ?:affiliate_payouts GROUP BY partner_id ORDER BY date {$sorting_direction}", 'partner_id');
if ($params['sort_by'] != 'date' && $params['sort_by'] != 'awaiting_amount') {
foreach ($partner_balances as $_partner_id => $_partner_data) {
$partner_balances[$_partner_id]['awaiting_amount'] = empty($_partners[$_partner_id]['amount']) ? '' : floatval($_partners[$_partner_id]['amount']);
$partner_balances[$_partner_id]['last_payout_date'] = @$last_payout_dates[$_partner_id]['date'];
}
} else {
$temp_balances = array();
if ($params['sort_by'] == 'awaiting_amount') {
foreach ($_partners as $_partner_id => $_partner_data) {
if (!empty($partner_balances[$_partner_id])) {
$temp_balances[$_partner_id] = $partner_balances[$_partner_id];
$temp_balances[$_partner_id]['awaiting_amount'] = floatval($_partner_data['amount']);
$temp_balances[$_partner_id]['last_payout_date'] = @$last_payout_dates[$_partner_id]['date'];
unset($partner_balances[$_partner_id]);
}
}
} else {
foreach ($last_payout_dates as $_partner_id => $_date) {
if (!empty($partner_balances[$_partner_id])) {
$temp_balances[$_partner_id] = $partner_balances[$_partner_id];
$temp_balances[$_partner_id]['awaiting_amount'] = empty($_partners[$_partner_id]['amount']) ? '' : floatval($_partners[$_partner_id]['amount']);
$temp_balances[$_partner_id]['last_payout_date'] = $_date['date'];
unset($partner_balances[$_partner_id]);
}
}
}
$temp_balances2 = array();
foreach ($partner_balances as $_partner_id => $_partner_data) {
$temp_balances2[$_partner_id] = $_partner_data;
$temp_balances2[$_partner_id]['awaiting_amount'] = empty($_partners[$_partner_id]['amount']) ? '' : floatval($_partners[$_partner_id]['amount']);
$temp_balances2[$_partner_id]['last_payout_date'] = @$last_payout_dates[$_partner_id]['date'];
}
$partner_balances = $sorting_direction == 'desc' ? $temp_balances + $temp_balances2 : $temp_balances2 + $temp_balances;
}
return array($partner_balances, $params);
}
示例11: fn_get_subscribers
function fn_get_subscribers($params, $lang_code = CART_LANGUAGE)
{
// Init filter
$params = fn_init_view('subscribers', $params);
// Set default values to input params
$default_params = array('page' => 1);
$params = array_merge($default_params, $params);
// Define fields that should be retrieved
$fields = array('?:subscribers.subscriber_id', '?:subscribers.email', '?:subscribers.timestamp', '?:subscribers.subscriber_id', "GROUP_CONCAT(?:user_mailing_lists.list_id) as list_ids");
// Define sort fields
$sortings = array('email' => '?:subscribers.email', 'timestamp' => '?:subscribers.timestamp');
$directions = array('asc' => 'asc', 'desc' => 'desc');
$condition = '';
$group_by = "?:subscribers.subscriber_id";
$join = db_quote(" LEFT JOIN ?:user_mailing_lists ON ?:user_mailing_lists.subscriber_id = ?:subscribers.subscriber_id");
if (isset($params['email']) && fn_string_no_empty($params['email'])) {
$condition .= db_quote(" AND ?:subscribers.email LIKE ?l", "%" . trim($params['email']) . "%");
}
if (!empty($params['list_id'])) {
$condition .= db_quote(" AND ?:user_mailing_lists.list_id = ?i", $params['list_id']);
}
if (!empty($params['confirmed'])) {
$condition .= db_quote(" AND ?:user_mailing_lists.confirmed = ?i", $params['confirmed'] == 'Y');
}
if (!empty($params['format'])) {
$condition .= db_quote(" AND ?:user_mailing_lists.format = ?i", $params['format']);
}
if (!empty($params['language'])) {
$condition .= db_quote(" AND ?:user_mailing_lists.lang_code = ?s", $params['language']);
}
if (!empty($params['period']) && $params['period'] != 'A') {
list($params['time_from'], $params['time_to']) = fn_create_periods($params);
$condition .= db_quote(" AND (?:subscribers.timestamp >= ?i AND ?:subscribers.timestamp <= ?i)", $params['time_from'], $params['time_to']);
}
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'] = 'timestamp';
}
$sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
// Reverse sorting (for usage in view)
$params['sort_order'] = $params['sort_order'] == 'asc' ? 'desc' : 'asc';
$total = db_get_field("SELECT COUNT(DISTINCT(?:subscribers.subscriber_id)) FROM ?:subscribers {$join} WHERE 1 {$condition}");
$limit = fn_paginate($params['page'], $total, Registry::get('settings.Appearance.admin_elements_per_page'));
$subscribers = db_get_array('SELECT ' . implode(', ', $fields) . " FROM ?:subscribers {$join} WHERE 1 {$condition} GROUP BY {$group_by} ORDER BY {$sorting} {$limit}");
return array($subscribers, $params);
}
示例12: fn_get_configurator_groups
function fn_get_configurator_groups($params, $items_per_page = 0)
{
$default_params = array('page' => 1);
$params = array_merge($default_params, $params);
$sortings = array('group_id' => "?:conf_groups.group_id", 'group_name' => "?:conf_group_descriptions.configurator_group_name", 'step_name' => "?:conf_groups.step_id", 'display_type' => "?:conf_groups.configurator_group_type", 'status' => "?:conf_groups.status");
$directions = array('asc' => 'asc', 'desc' => 'desc');
if (empty($params['group_sort_order']) || empty($directions[$params['group_sort_order']])) {
$params['group_sort_order'] = 'asc';
}
if (empty($params['group_sort_by']) || empty($sortings[$params['group_sort_by']])) {
$params['group_sort_by'] = 'group_name';
}
$sorting = $sortings[$params['group_sort_by']] . ' ' . $directions[$params['group_sort_order']];
// Reverse sorting (for usage in view)
$params['group_sort_order'] = $params['group_sort_order'] == 'asc' ? 'desc' : 'asc';
$limit = '';
if (!empty($items_per_page)) {
$group_data_count = db_get_field("SELECT COUNT(*) FROM ?:conf_groups");
$limit = fn_paginate($params['page'], $group_data_count, $items_per_page);
}
$groups = db_get_hash_array("SELECT ?:conf_groups.group_id, ?:conf_group_descriptions.configurator_group_name, ?:conf_group_descriptions.full_description, ?:conf_groups.step_id, ?:conf_groups.status, ?:conf_groups.configurator_group_type FROM ?:conf_groups LEFT JOIN ?:conf_group_descriptions ON ?:conf_group_descriptions.group_id = ?:conf_groups.group_id WHERE ?:conf_group_descriptions.lang_code = ?s ORDER BY {$sorting} {$limit}", 'group_id', DESCR_SL);
return array($groups, $params);
}
示例13: fn_twg_set_response_categories
function fn_twg_set_response_categories(&$response, $params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
if (empty($items_per_page)) {
$result = fn_twg_api_get_categories($params, $lang_code);
$response->setMeta(db_get_field("SELECT COUNT(*) FROM ?:categories"), 'total_items');
$response->setResponseList($result);
} else {
$default_params = array('depth' => 0, 'page' => 1);
$params = array_merge($default_params, $params);
$params['type'] = 'plain_tree';
$categories = fn_twg_api_get_categories($params, $lang_code);
if (!empty($categories)) {
$total = count($categories['category']);
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
fn_paginate($params['page'], $total, $items_per_page);
$view = fn_twg_get_view_object();
$pagination = $view->getTemplateVars('pagination');
$start = $pagination['prev_page'] * $pagination['items_per_page'];
$end = $start + $items_per_page;
$result = array();
for ($i = $start; $i < $end; $i++) {
if (!isset($categories['category'][$i])) {
break;
}
$result[] = $categories['category'][$i];
}
$response->setResponseList(array('category' => $result));
$pagination_params = array('items_per_page' => !empty($items_per_page) ? $items_per_page : TWG_RESPONSE_ITEMS_LIMIT, 'page' => !empty($_REQUEST['page']) ? $_REQUEST['page'] : 1);
fn_twg_set_response_pagination($response, $pagination_params);
}
}
$category_id = !empty($params['id']) ? $params['id'] : 0;
if (!empty($category_id)) {
$parent_data = db_get_row("SELECT a.parent_id, b.category\n FROM ?:categories AS a\n LEFT JOIN ?:category_descriptions AS b\n ON a.parent_id = b.category_id\n WHERE a.category_id = ?i AND b.lang_code = ?s", $category_id, $lang_code);
if (!empty($parent_data)) {
$response->setMeta($parent_data['parent_id'], 'grand_id');
$response->setMeta($parent_data['category'], 'grand_category');
}
$response->setMeta($category_id, 'category_id');
$category_data = array_pop(db_get_array("SELECT category, description\n FROM ?:category_descriptions\n WHERE category_id = ?i AND lang_code = ?s", $params['category_id'], $lang_code));
$response->setMeta($category_data['category'], 'category_name');
$response->setMeta($category_data['description'], 'description');
}
}
示例14: fn_get_carts
//.........这里部分代码省略.........
// Define sort fields
$sortings = array('customer' => "CONCAT(?:users.lastname, ?:users.firstname)", 'date' => "?:user_session_products.timestamp");
$directions = array('asc' => 'asc', 'desc' => 'desc');
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'] = 'customer';
}
$sorting = $sortings[$params['sort_by']] . ' ' . $directions[$params['sort_order']];
// Reverse sorting (for usage in view)
$params['sort_order'] = $params['sort_order'] == 'asc' ? 'desc' : 'asc';
$condition = $join = '';
$group = " GROUP BY ?:user_session_products.user_id";
if (isset($params['cname']) && fn_string_no_empty($params['cname'])) {
$arr = fn_explode(' ', $params['cname']);
foreach ($arr as $k => $v) {
if (!fn_string_no_empty($v)) {
unset($arr[$k]);
}
}
if (sizeof($arr) == 2) {
$condition .= db_quote(" AND ?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
} else {
$condition .= db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%" . trim($params['cname']) . "%", "%" . trim($params['cname']) . "%");
}
}
if (isset($params['email']) && fn_string_no_empty($params['email'])) {
$condition .= db_quote(" AND ?:users.email LIKE ?l", "%" . trim($params['email']) . "%");
}
if (!empty($params['user_id'])) {
$condition .= db_quote(" AND ?:user_session_products.user_id = ?i", $params['user_id']);
}
if (!empty($params['online_only'])) {
$join .= ' LEFT JOIN ?:sessions ON ?:sessions.session_id = ?:user_session_products.session_id';
$condition .= db_quote(" AND ?:sessions.expiry > ?i", TIME + SESSION_ALIVE_TIME - 300);
}
if (!empty($params['with_info_only'])) {
$condition .= db_quote(" AND ?:users.email != ''");
}
if (!empty($params['users_type'])) {
if ($params['users_type'] == 'R') {
$condition .= db_quote(" AND !ISNULL(?:users.user_id)");
} elseif ($params['users_type'] == 'G') {
$condition .= db_quote(" AND ISNULL(?:users.user_id)");
}
}
if (!empty($params['total_from']) || !empty($params['total_to'])) {
$having = '';
if (fn_is_numeric($params['total_from'])) {
$having .= db_quote(" AND SUM(price * amount) >= ?d", $params['total_from']);
}
if (fn_is_numeric($params['total_to'])) {
$having .= db_quote(" AND SUM(price * amount) <= ?d", $params['total_to']);
}
if (!empty($having)) {
$users4total = db_get_fields("SELECT user_id FROM ?:user_session_products GROUP BY user_id HAVING 1 {$having}");
if (!empty($users4total)) {
$condition .= db_quote(" AND (?:user_session_products.user_id IN (?n))", $users4total);
} else {
$condition .= " AND (?:user_session_products.user_id = 'no')";
}
}
}
if (!empty($params['period']) && $params['period'] != 'A') {
list($params['time_from'], $params['time_to']) = fn_create_periods($params);
$condition .= db_quote(" AND (?:user_session_products.timestamp >= ?i AND ?:user_session_products.timestamp <= ?i)", $params['time_from'], $params['time_to']);
}
$_condition = array();
if (!empty($params['product_type_c'])) {
$_condition[] = "?:user_session_products.type = 'C'";
}
if (!empty($params['product_type_w']) && $params['product_type_w'] == 'Y') {
$_condition[] = "?:user_session_products.type = 'W'";
}
if (!empty($_condition)) {
$condition .= " AND (" . implode(" OR ", $_condition) . ")";
}
if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
$arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
if (empty($params['product_view_id'])) {
$condition .= db_quote(" AND ?:user_session_products.product_id IN (?n)", $arr);
} else {
$condition .= db_quote(" AND ?:user_session_products.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true))));
}
$group .= " HAVING COUNT(?:user_session_products.user_id) >= " . count($arr);
}
$join .= " LEFT JOIN ?:users ON ?:user_session_products.user_id = ?:users.user_id";
// checking types for retrieving from the database
$type_restrictions = array('C');
fn_set_hook('get_carts', $type_restrictions);
if (!empty($type_restrictions) && is_array($type_restrictions)) {
$condition .= " AND ?:user_session_products.type IN ('" . implode("', '", $type_restrictions) . "')";
}
$total = db_get_field("SELECT COUNT(DISTINCT ?:user_session_products.user_id) FROM ?:user_session_products {$join} WHERE 1 {$condition}");
$limit = fn_paginate($params['page'], $total);
$carts_list = db_get_hash_array("SELECT " . implode(', ', $fields) . " FROM ?:user_session_products {$join} WHERE 1 {$condition} {$group} ORDER BY {$sorting} {$limit}", 'user_id');
$_SESSION['abandoned_carts'] = db_get_fields("SELECT ?:user_session_products.user_id FROM ?:user_session_products {$join} WHERE 1 {$condition} GROUP BY user_id");
return array($carts_list, $params);
}
示例15: empty
}
$q = empty($_REQUEST['q']) ? '' : $_REQUEST['q'];
return array(CONTROLLER_STATUS_OK, "languages.manage?q={$q}");
}
//
// Get language variables values
//
if ($mode == 'manage') {
if (isset($_REQUEST['q']) && fn_string_no_empty($_REQUEST['q'])) {
$_query = db_quote(" lang_code = ?s AND (name LIKE ?l OR value LIKE ?l)", DESCR_SL, "%" . trim($_REQUEST['q']) . "%", "%" . trim($_REQUEST['q']) . "%");
} else {
$_query = db_quote(" lang_code = ?s", DESCR_SL);
}
$page = empty($_REQUEST['page']) ? 1 : $_REQUEST['page'];
$lang_data_count = db_get_field("SELECT COUNT(*) FROM ?:language_values WHERE {$_query}");
$limit = fn_paginate($page, $lang_data_count, Registry::get('settings.Appearance.admin_elements_per_page'));
$lang_data = db_get_array("SELECT name, value FROM ?:language_values WHERE {$_query} ORDER BY name {$limit}");
Registry::set('navigation.tabs', array('translations' => array('title' => fn_get_lang_var('translations'), 'js' => true), 'languages' => array('title' => fn_get_lang_var('languages'), 'js' => true)));
$view->assign('lang_data', $lang_data);
$view->assign('langs', Registry::get('languages'));
} elseif ($mode == 'delete_variable') {
if (!empty($_REQUEST['name'])) {
db_query("DELETE FROM ?:language_values WHERE name = ?s", $_REQUEST['name']);
}
return array(CONTROLLER_STATUS_REDIRECT, "languages.manage");
//
// Delete languages
//
} elseif ($mode == 'delete_language') {
if (!empty($_REQUEST['lang_code'])) {
fn_delete_languages($_REQUEST['lang_code']);