Beispiel #1
0
/**
 * Returns an array of staff member data by specified user_id
 *
 * @param int $user_id - items per page
 * @param $lang_code - staff member identifier
 * @return array
 */
function fn_staff_get_staff_member_data($user_id, $lang_code = CART_LANGUAGE)
{
    $where = array('user_id' => $user_id);
    $data = db_get_row('SELECT * FROM ?:staff WHERE ?w', $where);
    $data['main_pair'] = fn_get_image_pairs($user_id, 'staff', 'M', true, true, $lang_code);
    return $data;
}
Beispiel #2
0
function fn_blog_get_page_data(&$page_data, $lang_code, $preview, $area)
{
    if ($page_data['page_type'] == PAGE_TYPE_BLOG) {
        $page_data['main_pair'] = fn_get_image_pairs($page_data['page_id'], 'blog', 'M', true, false, $lang_code);
        $page_data['author'] = db_get_field("SELECT CONCAT(u.firstname, ' ', u.lastname) FROM ?:blog_authors as b LEFT JOIN ?:users  as u ON b.user_id = u.user_id WHERE b.page_id = ?i", $page_data['page_id']);
    }
}
Beispiel #3
0
function fn_get_aff_banner_image_data($banner_id, $image_key = 'image', $lang_code = CART_LANGUAGE)
{
    $image_data = fn_get_image_pairs($banner_id, 'aff_banners', 'M', true, false, $lang_code);
    if (!empty($image_data['image_id'])) {
        $image_data[$image_key]['image_path'] = empty($image_data[$image_key]['image_path']) ? '' : 'http://' . Registry::get('config.http_host') . $image_data[$image_key]['image_path'];
    }
    return empty($image_data) ? false : $image_data;
}
Beispiel #4
0
function fn_get_banner_data($banner_id, $lang_code = CART_LANGUAGE)
{
    $status_condition = AREA == 'A' ? '' : " AND ?:banners.status IN ('A', 'H') ";
    $banner = db_get_row("SELECT ?:banners.banner_id, ?:banners.status, ?:banners.url, ?:banner_descriptions.banner, ?:banners.type, ?:banners.target, ?:banners.localization, ?:banners.timestamp, ?:banner_descriptions.description FROM ?:banners LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s WHERE ?:banners.banner_id = ?i ?p", $lang_code, $banner_id, $status_condition);
    if (!empty($banner)) {
        $banner['main_pair'] = fn_get_image_pairs($banner['banner_id'], 'banner', 'M', true, false, $lang_code);
    }
    return $banner;
}
Beispiel #5
0
function fn_get_paypal_settings($lang_code = DESCR_SL)
{
    $pp_settings = Settings::instance()->getValues('paypal', 'ADDON');
    if (!empty($pp_settings['general']['pp_statuses'])) {
        $pp_settings['general']['pp_statuses'] = unserialize($pp_settings['general']['pp_statuses']);
    }
    $pp_settings['general']['main_pair'] = fn_get_image_pairs(fn_paypal_get_logo_id(), 'paypal_logo', 'M', false, true, $lang_code);
    return $pp_settings['general'];
}
Beispiel #6
0
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;
}
function fn_exim_mailru_get_image_url($product_id, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code)
{
    $image_pair = fn_get_image_pairs($product_id, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code);
    $image_data = fn_image_to_display($image_pair, Registry::get('settings.Thumbnails.product_details_thumbnail_width'), Registry::get('settings.Thumbnails.product_details_thumbnail_height'));
    if (strpos($image_data['image_path'], '.php')) {
        $image_data['image_path'] = fn_generate_thumbnail($image_data['detailed_image_path'], $image_data['width'], $image_data['height']);
    }
    if (!empty($image_data['image_path'])) {
        $url = $image_data['image_path'];
    } else {
        $url = '';
    }
    return htmlspecialchars($url, ENT_QUOTES, 'UTF-8');
}
Beispiel #8
0
function fn_advanced_menu_get_categories_post(&$categories_list, $params, $lang_code)
{
    if (!empty($categories_list)) {
        if (isset($params['block_data']) && $params['block_data']['properties']['template'] == 'blocks/categories/categories_dropdown_horizontal.tpl') {
            foreach ($categories_list as $k => $v) {
                $categories_list[$k]['background_image_pair'] = fn_get_image_pairs($v['category_id'], 'menu', 'M', true, true, CART_LANGUAGE);
                $advanced_menu = unserialize($v['advanced_menu']);
                $categories_list[$k]['advanced_menu'] = $advanced_menu;
                if (isset($advanced_menu['feature_id']) && !empty($advanced_menu['feature_id'])) {
                    $categories_list[$k]['subcategories'][] = fn_get_feature_by_id($advanced_menu['feature_id'], $v['category_id'], $v['id_path'], $advanced_menu['number_of_variants']);
                }
            }
        }
    }
}
function fn_get_product_option_data($option_id, $product_id, $lang_code = DESCR_SL)
{
    $extra_variant_fields = '';
    $fields = "a.*, b.option_name, b.option_text, b.description, b.inner_hint, b.incorrect_message, b.comment, c.product_id";
    $join = db_quote(" LEFT JOIN ?:product_options_descriptions as b ON a.option_id = b.option_id AND b.lang_code = ?s" . " LEFT JOIN ?:product_global_option_links as c ON c.option_id = a.option_id", $lang_code);
    $condition = db_quote("a.option_id = ?i AND a.product_id = ?i", $option_id, $product_id);
    /**
     * Changes params before option data selecting
     *
     * @param int    $option_id            Option identifier
     * @param int    $product_id           Product identifier
     * @param string $fields               Fields to be selected
     * @param string $condition            String containing SQL-query condition possibly prepended with a logical operator (AND or OR)
     * @param string $join                 String with the complete JOIN information (JOIN type, tables and fields) for an SQL-query
     * @param string $extra_variant_fields Additional variant fields to be selected
     * @param string $lang_code            2-letters language code
     */
    fn_set_hook('get_product_option_data_pre', $option_id, $product_id, $fields, $condition, $join, $extra_variant_fields, $lang_code);
    $opt = db_get_row("SELECT " . $fields . " FROM ?:product_options as a" . $join . " WHERE " . $condition . " ORDER BY a.position");
    if (!empty($opt)) {
        $_cond = $opt['option_type'] == 'C' ? ' AND a.position = 1' : '';
        $join = '';
        if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
            $extra_variant_fields .= 'IF(shared_option_variants.variant_id IS NOT NULL, shared_option_variants.modifier, a.modifier) as modifier, ';
            $extra_variant_fields .= 'IF(shared_option_variants.variant_id IS NOT NULL, shared_option_variants.modifier_type, a.modifier_type) as modifier_type, ';
            $join .= db_quote(' LEFT JOIN ?:ult_product_option_variants shared_option_variants ON shared_option_variants.variant_id = a.variant_id AND shared_option_variants.company_id = ?i', Registry::get('runtime.company_id'));
        }
        $join .= db_quote(' LEFT JOIN ?:product_option_variants_link povl ON povl.option_variant_id = a.variant_id ');
        $opt['variants'] = db_get_hash_array("SELECT a.variant_id, a.position, a.modifier, a.modifier_type, a.weight_modifier, a.weight_modifier_type, a.status, a.set_by_user, {$extra_variant_fields} b.variant_name, povl.product_id AS required_product_id FROM ?:product_option_variants as a LEFT JOIN ?:product_option_variants_descriptions as b ON a.variant_id = b.variant_id AND b.lang_code = ?s {$join} WHERE a.option_id = ?i {$_cond} ORDER BY a.position", 'variant_id', $lang_code, $option_id);
        if (!empty($opt['variants'])) {
            foreach ($opt['variants'] as $k => $v) {
                $opt['variants'][$k]['image_pair'] = fn_get_image_pairs($v['variant_id'], 'variant_image', 'V', true, true, $lang_code);
            }
        }
    }
    /**
     * Changes option data
     *
     * @param array  $opt        Option data
     * @param int    $product_id Product identifier
     * @param string $lang_code  2-letters language code
     */
    fn_set_hook('get_product_option_data_post', $opt, $product_id, $lang_code);
    return $opt;
}
Beispiel #10
0
/**
 * Gets all logos
 * @TODO Remove "create" functionality from Getter
 *
 * @param int $company_id company ID
 * @param int $layout_id layout ID
 * @param string $style_id Style ID
 * @return array logos list
 */
function fn_get_logos($company_id = null, $layout_id = 0, $style_id = '')
{
    /**
     * Changes params before selecting logo
     *
     * @param int    $company_id company ID
     * @param int    $layout_id  layout ID
     * @param string $style_id   Style ID
     */
    fn_set_hook('get_logos_pre', $company_id, $layout_id, $style_id);
    $condition = array();
    $company_condition = '';
    if (is_null($company_id)) {
        if (Registry::get('runtime.company_id')) {
            $company_id = Registry::get('runtime.company_id');
        } elseif (fn_allowed_for('MULTIVENDOR')) {
            $company_id = 0;
        }
    }
    if (!is_null($company_id)) {
        $company_condition = db_quote(' AND company_id = ?i', $company_id);
    }
    if (!empty($company_id) && fn_allowed_for('ULTIMATE')) {
        $layout_data = Layout::instance($company_id)->getDefault();
    } else {
        $layout_data = array('layout_id' => Registry::get('runtime.layout.layout_id'), 'style_id' => Registry::get('runtime.layout.style_id'));
    }
    $layout_id = !empty($layout_id) ? $layout_id : $layout_data['layout_id'];
    $style_id = !empty($style_id) ? $style_id : $layout_data['style_id'];
    $condition[] = db_quote('IF(layout_id = 0, 1, IF(layout_id = ?i, 1, 0))', $layout_id);
    if (!empty($style_id)) {
        $condition[] = db_quote('IF(style_id = \'\', 1, IF(style_id = ?s, 1, 0))', $style_id);
    }
    /**
     * Changes conditions before selecting logo
     *
     * @param int    $company_id        company ID
     * @param int    $layout_id         layout ID
     * @param string $style_id          Style ID
     * @param array  $condition         Selecting conditions
     * @param string $company_condition Condition by companies
     */
    fn_set_hook('get_logos', $company_id, $layout_id, $style_id, $condition, $company_condition);
    $logos = db_get_hash_array("SELECT * FROM ?:logos WHERE ?p ?p", 'type', implode(' AND ', $condition), $company_condition);
    $logo_ids = array();
    foreach ($logos as $l) {
        $logo_ids[] = $l['logo_id'];
    }
    $images = fn_get_image_pairs($logo_ids, 'logos', 'M', true, false);
    foreach ($logos as $k => $v) {
        if (empty($images[$v['logo_id']])) {
            $logos[$k]['image'] = array();
            continue;
        }
        $image = reset($images[$v['logo_id']]);
        $logos[$k]['image'] = $image['icon'];
    }
    /**
     * Changes logos before returning
     *
     * @param int    $company_id company ID
     * @param int    $layout_id  layout ID
     * @param string $style_id   Style ID
     * @param array  $logos      Selected logos
     */
    fn_set_hook('get_logos_post', $company_id, $layout_id, $style_id, $logos);
    return $logos;
}
Beispiel #11
0
             $_products[$_k] = $_v;
             if (in_array($_v['product_id'], $selected_ids)) {
                 $_products[$_k]['selected'] = 'Y';
                 $c_price += $_products[$_k]['price'];
             } else {
                 $_products[$_k]['selected'] = 'N';
             }
             // Recommended products
             if (in_array($_v['product_id'], $default_ids)) {
                 $_products[$_k]['recommended'] = 'Y';
             }
             $_products[$_k]['compatible_classes'] = db_get_hash_array("SELECT ?:conf_compatible_classes.slave_class_id, ?:conf_classes.group_id FROM ?:conf_compatible_classes LEFT JOIN ?:conf_classes ON ?:conf_classes.class_id = ?:conf_compatible_classes.slave_class_id WHERE ?:conf_compatible_classes.master_class_id = ?i AND ?:conf_classes.status = 'A'", 'slave_class_id', $_v['class_id']);
         }
         $product_configurator_groups[$k]['products_count'] = count($_products);
         $product_configurator_groups[$k]['products'] = $_products;
         $product_configurator_groups[$k]['main_pair'] = fn_get_image_pairs($v['group_id'], 'conf_group', 'M');
     }
 }
 if (empty($product_configurator_groups)) {
     unset($product_configurator_steps[$step_id]);
     continue;
 }
 if (empty($current_step_id)) {
     $current_step_id = $step_id;
 }
 Registry::set('navigation.tabs.pc_' . $step_id, array('title' => $step_value['step_name'], 'section' => 'configurator', 'js' => true));
 // Substitute configuration price instead of product price
 if (!empty($c_price)) {
     $product['price'] = $c_price;
 }
 // Define list of incompatible products
Beispiel #12
0
function fn_get_credit_cards_images()
{
    $data = db_get_array("SELECT ?:static_data.param_id, ?:static_data_descriptions.descr  FROM ?:static_data INNER JOIN ?:images_links ON ?:static_data.param_id = ?:images_links.object_id AND ?:images_links.object_type = 'credit_card' LEFT JOIN ?:static_data_descriptions ON ?:static_data.param_id = ?:static_data_descriptions.param_id WHERE ?:static_data.status = 'A' AND ?:static_data.section = 'C' ORDER BY ?:static_data.position, ?:static_data_descriptions.descr ");
    if (empty($data)) {
        return array();
    }
    $images = array();
    foreach ($data as $key => $entry) {
        $image = fn_get_image_pairs($entry['param_id'], 'credit_card', 'M');
        if (!empty($image['icon'])) {
            $image['icon']['alt'] = empty($image['icon']['alt']) ? $entry['descr'] : $image['icon']['alt'];
            $images[] = $image['icon'];
        }
    }
    return $images;
}
Beispiel #13
0
function fn_banners_install()
{
    // FIXME
    if (DEFAULT_LANGUAGE != 'en') {
        db_query("UPDATE ?:banner_images SET lang_code = ?s WHERE lang_code = ?s", DEFAULT_LANGUAGE, 'en');
        // Demo data
    }
    $banners = db_get_array("SELECT ?:banners.banner_id, ?:banner_images.banner_image_id FROM ?:banners LEFT JOIN ?:banner_images ON ?:banner_images.banner_id = ?:banners.banner_id AND ?:banner_images.lang_code = ?s", DEFAULT_LANGUAGE);
    foreach ($banners as $k => $v) {
        $banners[$k]['main_pair'] = fn_get_image_pairs($v['banner_image_id'], 'promo', 'M', true, false, DEFAULT_LANGUAGE);
    }
    foreach (Languages::getAll() as $lang_code => $v) {
        fn_banners_clone($banners, $lang_code);
    }
    return true;
}
Beispiel #14
0
function fn_exim_get_detailed_image_url($product_id, $object_type, $pair_type, $lang_code)
{
    $image_pair = fn_get_image_pairs($product_id, $object_type, $pair_type, false, true, $lang_code);
    return !empty($image_pair['detailed']['http_image_path']) ? $image_pair['detailed']['http_image_path'] : '';
}
Beispiel #15
0
    //fn_set_notification('I','view>',print_r($view));
    $view->assign('total_print', $total_print);
    $view->assign('order_info', $order_info);
    $view->assign('fonts_path', fn_get_theme_path('[relative]/[theme]/media/fonts'));
    if ($order_info['shipping_cost'] != 0) {
        $view->assign('shipping_cost', true);
    }
    if ($mode == "send_account_payment") {
        if (!empty($order_info['email'])) {
            fn_disable_live_editor_mode();
            $html = array($view->displayMail('addons/rus_payments/print_invoice_payment.tpl', false, 'C'));
            Pdf::render($html, fn_get_files_dir_path() . 'account_payment.pdf', 'save');
            $data = array('order_info' => $order_info, 'total_print' => $total_print, 'fonts_path' => fn_get_theme_path('[relative]/[theme]/media/fonts'));
            Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'default_company_orders_department', 'data' => $data, 'attachments' => array(fn_get_files_dir_path() . 'account_payment.pdf'), 'tpl' => 'addons/rus_payments/print_invoice_payment.tpl', 'is_html' => true), 'A');
            fn_set_notification('N', __('notice'), __('text_email_sent'));
        }
    } else {
        $view->assign('show_print_button', true);
        $view->displayMail('addons/rus_payments/print_invoice_payment.tpl', true, 'C');
    }
    exit;
} elseif ($mode == 'get_stamp') {
    Header("Content-Type: image/png");
    Header("Content-Type: image/jpg");
    Header("Content-Type: image/jpeg");
    Header("Content-Type: image/gif");
    $path_stamp = fn_get_image_pairs($_REQUEST['payment_id'], 'stamp', 'M', true, true, DESCR_SL);
    $image = fn_get_contents($path_stamp['icon']['absolute_path']);
    fn_echo($image);
    exit;
}
Beispiel #16
0
function fn_exim_get_detailed_image_url($product_id, $object_type, $pair_type, $lang_code)
{
    $image_pair = fn_get_image_pairs($product_id, $object_type, $pair_type, false, true, $lang_code);
    $protocol = fn_get_storefront_protocol();
    return !empty($image_pair['detailed'][$protocol . '_image_path']) ? $image_pair['detailed'][$protocol . '_image_path'] : '';
}
Beispiel #17
0
 public function prepareImages($params, $product_id = 0, $object_name = '', $main_type = 'M')
 {
     if (isset($params['main_pair'])) {
         $_REQUEST['file_product_main_image_icon'] = array();
         $_REQUEST['type_product_main_image_icon'] = array();
         $_REQUEST['file_product_main_image_detailed'] = array();
         $_REQUEST['type_product_main_image_detailed'] = array();
         $_REQUEST['product_main_image_data'] = array();
         if ($product_id != 0) {
             $products_images = fn_get_image_pairs($product_id, 'product', 'M', true, true, DEFAULT_LANGUAGE);
             if (!empty($products_images)) {
                 fn_delete_image_pair($products_images['pair_id']);
             }
         }
         if (!empty($params['main_pair']['detailed']['image_path'])) {
             $_REQUEST['file_product_main_image_detailed'][] = $params['main_pair']['detailed']['image_path'];
             $_REQUEST['type_product_main_image_detailed'][] = strpos($params['main_pair']['detailed']['image_path'], '://') === false ? 'server' : 'url';
         }
         if (!empty($params['main_pair']['icon']['image_path'])) {
             $_REQUEST['file_product_main_image_icon'][] = $params['main_pair']['icon']['image_path'];
             $_REQUEST['type_product_main_image_icon'][] = strpos($params['main_pair']['icon']['image_path'], '://') === false ? 'server' : 'url';
         }
         $_REQUEST['product_main_image_data'][] = array('pair_id' => 0, 'type' => 'M', 'object_id' => 0, 'image_alt' => !empty($params['main_pair']['icon']['alt']) ? $params['main_pair']['icon']['alt'] : '', 'detailed_alt' => !empty($params['main_pair']['detailed']['alt']) ? $params['main_pair']['detailed']['alt'] : '');
     }
     if (isset($params['image_pairs'])) {
         $_REQUEST['file_product_add_additional_image_icon'] = array();
         $_REQUEST['type_product_add_additional_image_icon'] = array();
         $_REQUEST['file_product_add_additional_image_detailed'] = array();
         $_REQUEST['type_product_add_additional_image_detailed'] = array();
         $_REQUEST['product_add_additional_image_data'] = array();
         if ($product_id != 0) {
             $additional_images = fn_get_image_pairs($product_id, 'product', 'A', true, true, DEFAULT_LANGUAGE);
             foreach ($additional_images as $pair) {
                 fn_delete_image_pair($pair['pair_id']);
             }
         }
         foreach ($params['image_pairs'] as $pair_id => $pair) {
             if (!empty($pair['icon']['image_path'])) {
                 $_REQUEST['file_product_add_additional_image_icon'][] = $pair['icon']['image_path'];
                 $_REQUEST['type_product_add_additional_image_icon'][] = strpos($pair['icon']['image_path'], '://') === false ? 'server' : 'url';
             }
             if (!empty($pair['detailed']['image_path'])) {
                 $_REQUEST['file_product_add_additional_image_detailed'][] = $pair['detailed']['image_path'];
                 $_REQUEST['type_product_add_additional_image_detailed'][] = strpos($pair['detailed']['image_path'], '://') === false ? 'server' : 'url';
             }
             $_REQUEST['product_add_additional_image_data'][] = array('position' => !empty($pair['position']) ? $pair['position'] : 0, 'pair_id' => 0, 'type' => 'A', 'object_id' => 0, 'image_alt' => !empty($pair['icon']['alt']) ? $pair['icon']['alt'] : '', 'detailed_alt' => !empty($pair['detailed']['alt']) ? $pair['detailed']['alt'] : '');
         }
     }
 }
function fn_yml_get_rees46_yml($filename)
{
    $arr_category = array();
    $company = Registry::get('addons.my_yml.company_name');
    $location = Registry::get('config.http_location');
    $lmod = date('Y-m-d H:i');
    $modification = Registry::get('addons.rees46.modification');
    header("Content-Type: text/xml;charset=utf-8");
    /*============================================================================*/
    // Вывод заголовка файла
    $f = fopen($filename, "wb");
    fwrite($f, '<?xml version="1.0" encoding="utf-8"?>' . chr(10));
    fwrite($f, '<!DOCTYPE yml_catalog SYSTEM "shops.dtd">' . chr(10));
    fwrite($f, '<yml_catalog date="' . $lmod . '">' . chr(10));
    fwrite($f, '<shop>' . chr(10));
    /*============================================================================*/
    // Вывод данных о компании
    fwrite($f, chr(9) . '<name>' . Registry::get('settings.Company.company_name') . '</name>' . chr(10));
    fwrite($f, chr(9) . '<company>' . Registry::get('settings.Company.company_name') . '</company>' . chr(10));
    fwrite($f, chr(9) . '<url>' . $location . '</url>' . chr(10));
    /*============================================================================*/
    fwrite($f, chr(9) . '<currencies>' . chr(10));
    //        <currency id="RUR" rate="1"/>
    //        <currency id="USD" rate="CBRF"/>
    //        <currency id="EUR" rate="CBRF" plus="3"/>
    //        <currency id="UAH" rate="5.6"/>
    //        <currency id="KZT" rate="0.19"/>
    // Получаем список валют (только активных)
    $currencies = db_get_array("SELECT * FROM ?:currencies WHERE status='A'", USERGROUP_ALL);
    foreach ($currencies as $currency) {
        fwrite($f, chr(9) . chr(9) . '<currency id="' . $currency['currency_code'] . '" rate="' . $currency['coefficient'] . '"/>' . chr(10));
    }
    fwrite($f, chr(9) . '</currencies>' . chr(10));
    /*============================================================================*/
    // Загружаем дерево разделов каталога
    recursive_category(0, $f, $arr_category);
    /*============================================================================*/
    fwrite($f, chr(9) . '<offers>' . chr(10));
    /*----------------------------------------------------------------------------*/
    //        <offer id="12341" type="vendor.model" available="true" bid="13">
    //            <url>http://best.seller.ru/product_page.asp?pid=12344</url>
    //            <price>700</price>
    //            <currencyId>USD</currencyId>
    //            <categoryId> 6 </categoryId>
    //            <picture>http://best.seller.ru/img/device12345.jpg</picture>
    //            <delivery> true </delivery>
    //            <local_delivery_cost>300</local_delivery_cost>
    //            <typePrefix> Принтер </typePrefix>
    //            <vendor> НP </vendor>
    //            <vendorCode> Q7533A </vendorCode>
    //            <model> Color LaserJet 3000</model>
    //            <description>
    //                A4, 64Mb, 600x600 dpi, USB 2.0, 29стр/мин ч/б / 15стр/мин цв, лотки на 100л и 250л, плотность до 175г/м, до 60000 стр/месяц
    //            </description>
    //            <manufacturer_warranty>true</manufacturer_warranty>
    //            <country_of_origin>Япония</country_of_origin>
    //        </offer>
    $query = "SELECT DISTINCT\n                p.product_id AS id,\n                pdesc.product AS name,\n                pdesc.full_description AS descript\n\t\tFROM cscart_products AS p\n\t\t\tLEFT JOIN cscart_product_features_values AS pfval\n\t\t\tON p.product_id = pfval.product_id\n\t\t\tLEFT JOIN cscart_product_descriptions AS pdesc\n            \t\tON p.product_id=pdesc.product_id\n                        LEFT JOIN cscart_product_prices AS prices\n                        ON p.product_id = prices.product_id\n\t\tWHERE pdesc.lang_code='RU' AND p.status='A' AND p.amount > 0 AND prices.price > 0";
    $products = db_get_array($query, USERGROUP_ALL);
    foreach ($products as $product) {
        $offer = 'offer id="' . $product['id'] . '" available="true"';
        fwrite($f, chr(9) . chr(9) . '<' . $offer . '>' . chr(10));
        //        // пишем ссылку на страницу.
        fwrite($f, chr(9) . chr(9) . chr(9) . '<url>' . fn_url(htmlentities('products.view?product_id=' . $product["id"])) . '</url>' . chr(10));
        // вытаскиваем цену товара
        $query = "SELECT price FROM\n                      cscart_product_prices\n                      WHERE product_id=" . $product['id'] . " AND usergroup_id=0";
        $line1 = db_get_row($query);
        $i = intval($line1['price']);
        fwrite($f, chr(9) . chr(9) . chr(9) . '<price>' . $i . '</price>' . chr(10));
        // здесь ставится валюта цены. в данном случае рубли
        $query = "SELECT currency_code AS currency FROM cscart_currencies WHERE is_primary='Y'";
        $line1 = db_get_row($query);
        fwrite($f, chr(9) . chr(9) . chr(9) . '<currencyId>' . $line1['currency'] . '</currencyId>' . chr(10));
        // список категорий для маркета именовали через ID категорий, и теперь получаем
        // ID категории конкретного товара
        $query = "SELECT category_id FROM\n                    cscart_products_categories WHERE product_id=" . $product['id'] . " AND link_type='M' ORDER BY category_id";
        $result1 = db_get_array($query);
        if (count($result1) > 0) {
            $line1 = db_get_row($query);
        }
        fwrite($f, chr(9) . chr(9) . chr(9) . '<categoryId>' . $line1['category_id'] . '</categoryId>' . chr(10));
        // изображения.
        $img = fn_get_image_pairs($product["id"], "product", "M", false, true);
        fwrite($f, chr(9) . chr(9) . chr(9) . '<picture>' . $img["detailed"]["http_image_path"] . '</picture>' . chr(10));
        fwrite($f, chr(9) . chr(9) . chr(9) . '<delivery>true</delivery>' . chr(10));
        $query = "SELECT \n\t\tp.product_id AS id,\n                pfvdesc.variant AS vendor\n\tFROM cscart_products AS p\n                LEFT JOIN cscart_product_features_values AS pfval\n                ON pfval.product_id = p.product_id\n                LEFT JOIN cscart_product_feature_variant_descriptions AS pfvdesc\n                ON pfvdesc.variant_id = pfval.variant_id\n                LEFT JOIN cscart_product_features_descriptions AS pfdesc\n                ON pfdesc.feature_id = pfval.feature_id \n\tWHERE p.product_id =" . $product['id'] . " AND pfval.feature_id AND \n\t\t(pfdesc.description LIKE 'brand' OR \n\t\tpfdesc.description LIKE 'vendor' OR\n\t\tpfdesc.description LIKE 'бренд' OR\n\t\tpfdesc.description LIKE 'брэнд' OR\n\t\tpfdesc.description LIKE 'производитель' OR\n\t\tpfdesc.description LIKE 'торговая марка' OR\n\t\tpfdesc.description LIKE 'вендор')";
        $line = db_get_row($query);
        if (!empty($line['vendor'])) {
            $vendor = check_xml($line['vendor']);
        }
        if (!empty($vendor)) {
            fwrite($f, chr(9) . chr(9) . chr(9) . '<vendor>' . $vendor . '</vendor>' . chr(10));
        }
        // описание получаем из  короткого описания товара
        fwrite($f, chr(9) . chr(9) . chr(9) . '<name> ' . check_xml($product["name"]) . '</name>' . chr(10));
        // описание
        fwrite($f, chr(9) . chr(9) . chr(9) . '<description>' . chr(10));
        fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . check_xml(strip_tags($product["descript"])) . chr(10));
        fwrite($f, chr(9) . chr(9) . chr(9) . '</description>' . chr(10));
        if ($modification && $modification != 'none') {
            $query = "SELECT \n\t\t\t\tfd.description AS description,\n\t\t\t\tfvard.variant AS variant\n\t\t\t  FROM cscart_product_features_values AS fv\n\t\t\t  LEFT JOIN cscart_product_features_descriptions AS fd\n\t\t\t\tON fd.feature_id = fv.feature_id\n\t\t\t  LEFT JOIN cscart_product_feature_variants AS fvar\n\t\t\t\tON fvar.feature_id = fv.feature_id\n\t\t\t  LEFT JOIN cscart_product_feature_variant_descriptions AS fvard\n\t\t\t\tON fvard.variant_id = fvar.variant_id\n\t\t\tLEFT JOIN cscart_product_features AS pf\n\t\t\t\tON pf.feature_id = fv.feature_id\n\t\t\t  WHERE\n\t\t\t\tfv.product_id = " . $product['id'] . " AND\n\t\t\t\t(fd.description LIKE 'пол' OR fd.description LIKE 'gender') AND\n\t\t\t\tfv.variant_id = fvar.variant_id AND\n\t\t\t\tpf.status = 'A'";
            $line = db_get_row($query);
            $gender = '';
            if (!empty($line['variant'])) {
                $gender = $line['variant'];
                $gender = mb_substr(mb_strtolower($gender), 0, 4);
                if ($gender == 'male' || $gender == 'мужс') {
                    $gender = 'm';
                } elseif ($gender == 'fema' || $gender == 'женс') {
                    $gender = 'f';
                } else {
                    $gender = '';
                }
            }
            $query = "SELECT DISTINCT optvd.variant_name AS name\n\t\t\t\tFROM (\n\t\t\t\t\t(SELECT\topt.option_id AS option_id,\n\t\t\t\t\t\topt.product_id AS product_id,\n\t\t\t        \t\topt.status AS status\n\t\t\t\t\tFROM cscart_product_options AS opt)\n\t\t\t\t\tUNION\n\t\t\t\t\t(SELECT\topt.option_id AS option_id,\n\t\t\t\t\t\topt.product_id AS product_id,\n\t\t\t        \t\tNULL\n\t\t\t\t\tFROM cscart_product_global_option_links AS opt)\n\t\t\t\t\tORDER BY product_id\n\t\t\t        ) AS opt\n\t\t\t\tLEFT JOIN cscart_product_options_descriptions AS optd\n\t\t\t\t\tON optd.option_id = opt.option_id\n\t\t\t\tLEFT JOIN cscart_product_option_variants AS optv\n\t\t\t\t\tON optv.option_id = opt.option_id\n\t\t\t\tLEFT JOIN cscart_product_option_variants_descriptions AS optvd\n\t\t\t\t\tON optvd.variant_id = optv.variant_id\n\t\t\tWHERE\topt.product_id = " . $product['id'] . " AND\n\t\t\t\t(opt.status = 'A' OR opt.status IS NULL) AND\n\t\t\t\t(optd.option_name LIKE 'size' OR\n\t\t\t\toptd.option_name LIKE 'размер')\n\t\t\tORDER BY name";
            $sizes = db_get_array($query, USERGROUP_ALL);
            switch ($modification) {
                case 'fashion':
                    if (!empty($gender)) {
                        fwrite($f, chr(9) . chr(9) . chr(9) . '<fashion>' . chr(10));
                        if (!empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<gender>' . $gender . '</gender>' . chr(10));
                        }
                        if (!empty($sizes) && !empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<sizes>' . chr(10));
                            foreach ($sizes as $size) {
                                $size_items = mb_strtolower($size['name']);
                                $size_item = '';
                                if (!is_numeric($size_items)) {
                                    if ($size_items == 'xx small' || $size_items == 'xxs') {
                                        $size_item = 'XXS';
                                    }
                                    if ($size_items == 'x small' || $size_items == 'xs') {
                                        $size_item = 'XS';
                                    }
                                    if ($size_items == 'small' || $size_items == 's') {
                                        $size_item = 'S';
                                    }
                                    if ($size_items == 'medium' || $size_items == 'm') {
                                        $size_item = 'M';
                                    }
                                    if ($size_items == 'large' || $size_items == 'l') {
                                        $size_item = 'L';
                                    }
                                    if ($size_items == 'x large' || $size_items == 'xl') {
                                        $size_item = 'XL';
                                    }
                                    if ($size_items == 'xx large' || $size_items == 'xxl') {
                                        $size_item = 'XXL';
                                    }
                                    if ($size_items == 'xxx large' || $size_items == 'xxxl') {
                                        $size_item = 'XXXL';
                                    }
                                } else {
                                    $size_item = $size_items;
                                }
                                if (!empty($size_item)) {
                                    fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . chr(9) . '<size>' . $size_item . '</size>' . chr(10));
                                }
                            }
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '</sizes>' . chr(10));
                        }
                        fwrite($f, chr(9) . chr(9) . chr(9) . '</fashion>' . chr(10));
                    }
                    break;
                case 'cosmetic':
                    if (!empty($gender)) {
                        fwrite($f, chr(9) . chr(9) . chr(9) . '<cosmetic>' . chr(10));
                        if (!empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<gender>' . $gender . '</gender>' . chr(10));
                        }
                        fwrite($f, chr(9) . chr(9) . chr(9) . '</cosmetic>' . chr(10));
                    }
                    break;
                case 'child':
                    if (!empty($gender)) {
                        fwrite($f, chr(9) . chr(9) . chr(9) . '<child>' . chr(10));
                        if (!empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<gender>' . $gender . '</gender>' . chr(10));
                        }
                        if (!empty($sizes) && !empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<sizes>' . chr(10));
                            foreach ($sizes as $size) {
                                $size_items = mb_strtolower($size['name']);
                                $size_item = '';
                                if (!is_numeric($size_items)) {
                                    if ($size_items == 'xx small' || $size_items == 'xxs') {
                                        $size_item = 'XXS';
                                    }
                                    if ($size_items == 'x small' || $size_items == 'xs') {
                                        $size_item = 'XS';
                                    }
                                    if ($size_items == 'small' || $size_items == 's') {
                                        $size_item = 'S';
                                    }
                                    if ($size_items == 'medium' || $size_items == 'm') {
                                        $size_item = 'M';
                                    }
                                    if ($size_items == 'large' || $size_items == 'l') {
                                        $size_item = 'L';
                                    }
                                    if ($size_items == 'x large' || $size_items == 'xl') {
                                        $size_item = 'XL';
                                    }
                                    if ($size_items == 'xx large' || $size_items == 'xxl') {
                                        $size_item = 'XXL';
                                    }
                                    if ($size_items == 'xxx large' || $size_items == 'xxxl') {
                                        $size_item = 'XXXL';
                                    }
                                } else {
                                    $size_item = $size_items;
                                }
                                if (!empty($size_item)) {
                                    fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . chr(9) . '<size>' . $size_item . '</size>' . chr(10));
                                }
                            }
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '</sizes>' . chr(10));
                        }
                        fwrite($f, chr(9) . chr(9) . chr(9) . '</child>' . chr(10));
                    }
                    break;
            }
        }
        fwrite($f, chr(9) . chr(9) . '</offer>' . chr(10));
    }
    /*----------------------------------------------------------------------------*/
    /*----------------------------------------------------------------------------*/
    fwrite($f, chr(9) . '</offers>' . chr(10));
    /*============================================================================*/
    fwrite($f, '</shop>' . chr(10));
    fwrite($f, '</yml_catalog>' . chr(10));
    fclose($f);
    readfile($filename);
    exit;
}
Beispiel #19
0
function fn_prepare_checkout_payment_methods(&$cart, &$auth, $lang_code = CART_LANGUAGE)
{
    static $payment_methods, $payment_groups;
    // Get payment methods
    if (empty($payment_methods)) {
        $payment_methods = fn_get_payments(array('usergroup_ids' => $auth['usergroup_ids']));
    }
    // Check if payment method has surcharge rates
    foreach ($payment_methods as $k => $v) {
        if ($payment_methods[$k]['processor_type'] == 'C') {
            continue;
        }
        $payment_methods[$k]['surcharge_value'] = 0;
        if (floatval($v['a_surcharge'])) {
            $payment_methods[$k]['surcharge_value'] += $v['a_surcharge'];
        }
        if (floatval($v['p_surcharge']) && !empty($cart['total'])) {
            $payment_methods[$k]['surcharge_value'] += fn_format_price($cart['total'] * $v['p_surcharge'] / 100);
        }
        $payment_methods[$k]['image'] = fn_get_image_pairs($v['payment_id'], 'payment', 'M', true, true, $lang_code);
        $payment_groups[$v['payment_category']][$k] = $payment_methods[$k];
    }
    if (!empty($payment_groups)) {
        ksort($payment_groups);
    }
    fn_set_hook('prepare_checkout_payment_methods', $cart, $auth, $payment_groups);
    return $payment_groups;
}
Beispiel #20
0
        $addons = Registry::get('addons');
        foreach ($addons as $addon_id => $addon) {
            if ($view->templateExists('addons/' . $addon_id . '/views/payments/components/cc_processors/' . $processor_template)) {
                $view->assign('processor_template', 'addons/' . $addon_id . '/views/payments/components/cc_processors/' . $processor_template);
                break;
            }
        }
    }
    $view->assign('processor_params', $processor_data['processor_params']);
    $view->assign('processor_name', $processor_data['processor']);
    $view->assign('callback', $processor_data['callback']);
    $view->assign('payment_id', $_REQUEST['payment_id']);
    // Show methods list
} elseif ($mode == 'manage') {
    $payments = fn_get_payments(DESCR_SL);
    Tygh::$app['view']->assign('usergroups', fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H')), DESCR_SL));
    Tygh::$app['view']->assign('payments', $payments);
    Tygh::$app['view']->assign('templates', fn_get_payment_templates());
    Tygh::$app['view']->assign('payment_processors', fn_get_payment_processors());
} elseif ($mode == 'update') {
    $payment = fn_get_payment_method_data($_REQUEST['payment_id'], DESCR_SL);
    $payment['icon'] = fn_get_image_pairs($payment['payment_id'], 'payment', 'M', true, true, DESCR_SL);
    Tygh::$app['view']->assign('usergroups', fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H')), DESCR_SL));
    Tygh::$app['view']->assign('payment', $payment);
    Tygh::$app['view']->assign('templates', fn_get_payment_templates($payment));
    Tygh::$app['view']->assign('payment_processors', fn_get_payment_processors());
    Tygh::$app['view']->assign('taxes', fn_get_taxes());
    if (Registry::get('runtime.company_id') && Registry::get('runtime.company_id') != $payment['company_id']) {
        Tygh::$app['view']->assign('hide_for_vendor', true);
    }
}
Beispiel #21
0
function fn_watermarks_update_company(&$company_data, &$company_id, &$lang_code, &$action)
{
    if ($action == 'add') {
        // Clone watermark images
        $clone_from = !empty($company_data['clone_from']) && $company_data['clone_from'] != 'all' ? $company_data['clone_from'] : null;
        if (!is_null($clone_from)) {
            if (!empty($company_id)) {
                $clone_to = $company_id;
                $image_pair = fn_get_image_pairs($clone_from, 'watermark', 'M');
            } else {
                $clone_to = WATERMARK_IMAGE_ID;
                $image_pair = fn_get_image_pairs(WATERMARK_IMAGE_ID, 'watermark', 'M');
            }
            if (!empty($image_pair)) {
                fn_clone_image_pairs($clone_to, $clone_from, 'watermark');
            }
        } else {
            // check if company options are valid
            $option_types = fn_get_apply_watermark_options();
            foreach ($option_types as $type => $options) {
                foreach ($options as $name => $option_id) {
                    $image_name = $type == 'icons' ? 'icon' : 'detailed';
                    Settings::instance($company_id)->updateValueById($option_id, 'N', $company_id);
                }
            }
        }
    }
}
     if (!empty($_condition)) {
         $condition .= ' AND (' . $_cond . ') ';
     }
 }
 if (!count($store_locations_params)) {
     $condition .= " AND shop_type = '1'";
 }
 $sorting = " ?:store_locations.position, ?:store_location_descriptions.name";
 $limit = '';
 if (!empty($params['items_per_page'])) {
     $params['total_items'] = db_get_field("SELECT COUNT(?:store_locations.store_location_id) FROM ?:store_locations ?p WHERE ?p", $join, $condition);
     $limit = db_paginate($params['page'], $params['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);
 foreach ($data as $key_data => $dataStore) {
     $data[$key_data]['image_pairs'] = fn_get_image_pairs($dataStore['store_location_id'], 'store_locations', 'M', true, true, $lang_code);
     //        $aviable_cities_all[] = ucfirst($dataStore['city']);
     //        if(!in_array(strtolower($dataStore['city']),array('iasi','bucuresti'))){
     //            $aviable_cities[] = ucfirst($dataStore['city']);
     //        }
 }
 $aviable_countries_temp = array();
 $romaniaArray = array();
 $selectCountries = db_get_array("SELECT ?:store_locations.country, ?:country_descriptions.country as country_title FROM ?:store_locations JOIN ?:country_descriptions ON ?:store_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s WHERE ?:store_locations.status = 'A' GROUP BY ?:store_locations.country ORDER BY ?:country_descriptions.country", CART_LANGUAGE);
 foreach ($selectCountries as $aviable_country) {
     $aviable_countries_all[] = ucfirst($aviable_country['country']);
     if (!in_array(strtolower($aviable_country['country']), array('RO'))) {
         $aviable_countries_temp[$aviable_country['country']] = $aviable_country['country_title'];
     } else {
         $romaniaArray[$aviable_country['country']] = $aviable_country['country_title'];
     }
Beispiel #23
0
function fn_twg_api_add_product_to_cart($products, &$cart)
{
    $products_data = array();
    foreach ($products as $product) {
        $cid = fn_generate_cart_id($product['product_id'], $product);
        if (!empty($products_data[$cid])) {
            $products_data[$cid]['amount'] += $product['amount'];
        }
        // Get product options images
        $product['combination_hash'] = $cid;
        if (!empty($product['combination_hash']) && !empty($product['product_options'])) {
            $image = fn_get_image_pairs($product['combination_hash'], 'product_option', 'M', true, true, CART_LANGUAGE);
            if (!empty($image)) {
                $product['main_pair'] = $image;
            }
        }
        $products_data[$cid] = $product;
    }
    $auth =& $_SESSION['auth'];
    // actions copied from the checkout.php 'add' action
    $ids = fn_add_product_to_cart($products_data, $cart, $auth);
    fn_save_cart_content($cart, $auth['user_id']);
    $cart['change_cart_products'] = true;
    fn_calculate_cart_content($cart, $auth, 'S', true, 'F', true);
    return $ids;
}
Beispiel #24
0
function fn_exim_get_image_url($product_id, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code)
{
    $image_data = fn_get_image_pairs($product_id, $object_type, $pair_type, $get_icon, $get_detailed, $lang_code);
    if (isset($image_data['icon']['absolute_path']) && is_file($image_data['icon']['absolute_path'])) {
        return 'http://' . Registry::get('config.http_host') . $image_data['icon']['http_image_path'];
    }
    return false;
}
function fn_get_product_options_inventory($params, $items_per_page = 0, $lang_code = DESCR_SL)
{
    $default_params = array('page' => 1, 'product_id' => 0, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:product_options_inventory WHERE product_id = ?i", $params['product_id']);
        $limit = db_paginate($params['page'], $params['items_per_page']);
    }
    $inventory = db_get_array("SELECT * FROM ?:product_options_inventory WHERE product_id = ?i ORDER BY position {$limit}", $params['product_id']);
    foreach ($inventory as $k => $v) {
        $inventory[$k]['combination'] = fn_get_product_options_by_combination($v['combination']);
        $inventory[$k]['image_pairs'] = fn_get_image_pairs($v['combination_hash'], 'product_option', 'M', true, true, $lang_code);
        $inventory[$k]['additional_image_pairs'] = fn_get_image_pairs($v['combination_hash'], 'product_option', 'A', true, true, $lang_code);
    }
    $product_options = fn_get_product_options($params['product_id'], $lang_code, true, true);
    $product_inventory = db_get_field("SELECT tracking FROM ?:products WHERE product_id = ?i", $params['product_id']);
    return array($inventory, $params, $product_options, $product_inventory);
}
Beispiel #26
0
        $suffix = ".manage?selected_section=classes";
    }
    //
    // Update class properties
    //
    if ($mode == 'update_class_properties') {
        $class_id = fn_update_configurator_class($_REQUEST['update_class_data'], $_REQUEST['class_id'], DESCR_SL);
        $suffix = ".update_class?class_id={$class_id}";
    }
    return array(CONTROLLER_STATUS_OK, "configurator{$suffix}");
}
if ($mode == 'update_group') {
    fn_add_breadcrumb(fn_get_lang_var('product_groups'), "configurator.manage?selected_section=groups");
    $configurator_group = db_get_row("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 AND ?:conf_groups.group_id = ?i", DESCR_SL, $_REQUEST['group_id']);
    Registry::set('navigation.tabs', array('general' => array('title' => fn_get_lang_var('general'), 'js' => true), 'products' => array('title' => fn_get_lang_var('products'), 'js' => true)));
    $configurator_group['main_pair'] = fn_get_image_pairs($_REQUEST['group_id'], 'conf_group', 'M', true, true, DESCR_SL);
    $configurator_group['product_ids'] = db_get_fields("SELECT ?:conf_group_products.product_id FROM ?:conf_group_products WHERE ?:conf_group_products.group_id = ?i", $_REQUEST['group_id']);
    $view->assign('configurator_group', $configurator_group);
    list($steps, $search) = fn_get_configurator_steps($_REQUEST);
    $view->assign('steps', $steps);
} elseif ($mode == 'add_group') {
    fn_add_breadcrumb(fn_get_lang_var('product_groups'), "configurator.manage?selected_section=groups");
    Registry::set('navigation.tabs', array('general' => array('title' => fn_get_lang_var('general'), 'js' => true), 'products' => array('title' => fn_get_lang_var('products'), 'js' => true)));
    list($steps) = fn_get_configurator_steps($_REQUEST);
    $view->assign('steps', $steps);
} elseif ($mode == 'update_class') {
    fn_add_breadcrumb(fn_get_lang_var('product_classes'), "configurator.manage?selected_section=classes");
    $product_class = db_get_row("SELECT ?:conf_classes.*, ?:conf_class_descriptions.class_name FROM ?:conf_classes LEFT JOIN ?:conf_class_descriptions ON ?:conf_class_descriptions.class_id = ?:conf_classes.class_id WHERE ?:conf_class_descriptions.lang_code = ?s AND ?:conf_classes.class_id = ?i", DESCR_SL, $_REQUEST['class_id']);
    // Get class products
    $product_class['product_ids'] = db_get_fields("SELECT ?:products.product_id FROM ?:products LEFT JOIN ?:conf_class_products ON ?:conf_class_products.product_id = ?:products.product_id WHERE ?:conf_class_products.class_id = ?i", $_REQUEST['class_id']);
    $product_class['compatible_classes'] = db_get_fields("SELECT ?:conf_compatible_classes.slave_class_id FROM ?:conf_compatible_classes WHERE master_class_id = ?i", $_REQUEST['class_id']);
Beispiel #27
0
* 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');
}
$_REQUEST['category_id'] = empty($_REQUEST['category_id']) ? 0 : $_REQUEST['category_id'];
if ($mode == 'catalog') {
    fn_add_breadcrumb(__('catalog'));
    $root_categories = fn_get_subcategories(0);
    foreach ($root_categories as $k => $v) {
        $root_categories[$k]['main_pair'] = fn_get_image_pairs($v['category_id'], 'category', 'M');
    }
    Tygh::$app['view']->assign('root_categories', $root_categories);
} elseif ($mode == 'view') {
    $_statuses = array('A', 'H');
    $_condition = fn_get_localizations_condition('localization', true);
    $preview = fn_is_preview_action($auth, $_REQUEST);
    if (!$preview) {
        $_condition .= ' AND (' . fn_find_array_in_set($auth['usergroup_ids'], 'usergroup_ids', true) . ')';
        $_condition .= db_quote(' AND status IN (?a)', $_statuses);
    }
    if (fn_allowed_for('ULTIMATE')) {
        $_condition .= fn_get_company_condition('?:categories.company_id');
    }
    $category_exists = db_get_field("SELECT category_id FROM ?:categories WHERE category_id = ?i ?p", $_REQUEST['category_id'], $_condition);
    if (!empty($category_exists)) {
Beispiel #28
0
function fn_banners_install()
{
    $banners = db_get_hash_multi_array("SELECT ?:banners.banner_id, ?:banner_images.banner_image_id, ?:banner_images.lang_code FROM ?:banners LEFT JOIN ?:banner_images ON ?:banner_images.banner_id = ?:banners.banner_id", array('lang_code', 'banner_id'));
    $langs = array_keys(Languages::getAll());
    $need_clone_langs = array_diff($langs, array_keys($banners));
    if (!empty($need_clone_langs)) {
        $clone_lang = DEFAULT_LANGUAGE;
        if (in_array(DEFAULT_LANGUAGE, $need_clone_langs)) {
            $clone_lang = 'en';
        }
        foreach ($banners[$clone_lang] as $banner_id => &$banner) {
            $banner['main_pair'] = fn_get_image_pairs($banner['banner_image_id'], 'promo', 'M', true, false, $clone_lang);
        }
        foreach ($need_clone_langs as $need_clone_lang) {
            fn_banners_clone($banners[$clone_lang], $need_clone_lang);
        }
    }
    foreach ($banners['en'] as $banner_id => &$banner) {
        $banner['main_pair'] = fn_get_image_pairs($banner['banner_image_id'], 'promo', 'M', true, false, 'en');
    }
    if (!in_array('en', $langs)) {
        $banner_images_ids = db_get_fields("SELECT banner_image_id FROM ?:banner_images WHERE lang_code = ?s", 'en');
        foreach ($banner_images_ids as $banner_image_id) {
            fn_delete_image_pairs($banner_image_id, 'promo');
        }
        if (!empty($banner_images_ids)) {
            db_query("DELETE FROM ?:banner_images WHERE banner_image_id IN (?n)", $banner_images_ids);
        }
    }
    return true;
}
Beispiel #29
0
 protected function body($file)
 {
     $offered = array();
     if ($this->options['disable_cat_d'] == "Y") {
         $visible_categories = $this->getVisibleCategories();
     }
     $fields = array('p.product_id', 'p.product_code', 'd.lang_code', 'pc.category_id', 'cd.category', 'pp.price', 'p.list_price', 'p.status', 'p.amount', 'p.weight', 'p.shipping_freight', 'p.free_shipping', 'd.product', 'd.full_description', 'p.company_id', 'p.tracking', 'p.list_price', 'p.yml_brand', 'p.yml_origin_country', 'p.yml_store', 'p.yml_pickup', 'p.yml_delivery', 'p.yml_adult', 'p.yml_cost', 'p.yml_export_yes', 'p.yml_bid', 'p.yml_cbid', 'p.yml_model', 'p.yml_sales_notes', 'p.yml_type_prefix', 'p.yml_market_category', 'p.yml_manufacturer_warranty', 'p.yml_seller_warranty');
     $fields[] = "(\n                SELECT GROUP_CONCAT(IF(pc2.link_type = 'M', CONCAT(pc2.category_id, 'M'), pc2.category_id))\n                FROM ?:products_categories as pc2\n                WHERE product_id = p.product_id\n            ) as category_ids";
     $joins = array(db_quote("LEFT JOIN ?:product_descriptions as d ON d.product_id = p.product_id AND d.lang_code = ?s", $this->lang_code), db_quote("LEFT JOIN ?:product_prices as pp" . " ON pp.product_id = p.product_id AND pp.lower_limit = 1 AND pp.usergroup_id = 0"), db_quote("LEFT JOIN ?:products_categories as pc ON pc.product_id = p.product_id AND pc.link_type = ?s", 'M'), db_quote("LEFT JOIN ?:category_descriptions as cd ON cd.category_id = pc.category_id AND cd.lang_code = ?s", $this->lang_code));
     $condition = '';
     if ($this->company_id > 0) {
         $condition .= db_quote(' AND company_id = ?i', $this->company_id);
     }
     $product_ids = db_get_fields("SELECT product_id FROM ?:products WHERE yml_export_yes = ?s AND status = ?s " . $condition, 'Y', 'A');
     $offset = 0;
     while ($ids = array_slice($product_ids, $offset, self::ITERATION_ITEMS)) {
         $offset += self::ITERATION_ITEMS;
         $products = db_get_array('SELECT ' . implode(', ', $fields) . ' FROM ?:products as p' . ' ' . implode(' ', $joins) . ' WHERE p.product_id IN(?n)', $ids);
         $products_images_main = fn_get_image_pairs($ids, 'product', 'M', false, true, $this->lang_code);
         $products_images_additional = fn_get_image_pairs($ids, 'product', 'A', false, true, $this->lang_code);
         $params = array('get_options' => false, 'get_taxed_prices' => false, 'detailed_params' => false);
         fn_gather_additional_products_data($products, $params);
         foreach ($products as $k => &$product) {
             $is_broken = false;
             $price = !floatval($product['price']) ? fn_parse_price($product['price']) : intval($product['price']);
             if ($this->options['export_null_price'] == 'N' && empty($price)) {
                 $is_broken = true;
             }
             if (in_array($product['category_id'], $this->disabled_category_ids)) {
                 $is_broken = true;
             }
             if ($this->options['disable_cat_d'] == 'Y' && !in_array($product['category_id'], $visible_categories)) {
                 $is_broken = true;
             }
             $product['product'] = $this->escape($product['product']);
             $product['full_description'] = $this->escape($product['full_description']);
             $product['product_features'] = $this->getProductFeatures($product);
             $product['brand'] = $this->getBrand($product);
             if ($this->options['export_type'] == 'vendor_model') {
                 if (empty($product['brand']) || empty($product['yml_model'])) {
                     $is_broken = true;
                 }
             }
             if ($product['tracking'] == 'O') {
                 $product['amount'] = db_get_field("SELECT SUM(amount) FROM ?:product_options_inventory WHERE product_id = ?i", $product['product_id']);
             }
             if ($this->options['export_stock'] == 'Y' && $product['amount'] <= 0) {
                 $is_broken = true;
             }
             if ($is_broken) {
                 unset($products[$k]);
                 continue;
             }
             $product['product_url'] = fn_url('products.view?product_id=' . $product['product_id']);
             // Images
             $images = array_merge($products_images_main[$product['product_id']], $products_images_additional[$product['product_id']]);
             $product['images'] = array_slice($images, 0, self::IMAGES_LIMIT);
             list($key, $value) = $this->offer($product);
             $offered[$key] = $value;
         }
         if (!empty($offered)) {
             fwrite($file, fn_yandex_market_array_to_yml($offered));
             unset($offered);
         }
     }
 }
Beispiel #30
0
 /**
  * Get blocks for the twigmo homepage
  * @param  string $dispatch        Dispatch of needed location
  * @param  array  $allowed_objects - array of blocks types
  * @return array  blocks
  */
 public static final function getBlocksForLocation($dispatch, $allowed_objects)
 {
     $allowed_page_types = array('T', 'L', 'F');
     $blocks = array();
     $location = Location::instance(fn_twg_get_default_layout_id())->get($dispatch);
     if (!$location) {
         return $blocks;
     }
     $get_cont_params = array('location_id' => $location['location_id']);
     $container = Container::getList($get_cont_params);
     if (!$container or !$container['CONTENT']) {
         return $blocks;
     }
     $grids_params = array('container_ids' => $container['CONTENT']['container_id']);
     $grids = Grid::getList($grids_params);
     if (!$grids) {
         return $blocks;
     }
     $block_grids = Block::instance()->getList(array('?:bm_snapping.*', '?:bm_blocks.*', '?:bm_blocks_descriptions.*'), Grid::getIds($grids));
     $image_params = TwigmoSettings::get('images.catalog');
     foreach ($block_grids as $block_grid) {
         foreach ($block_grid as $block) {
             if ($block['status'] != 'A' or !in_array($block['type'], $allowed_objects)) {
                 continue;
             }
             $block_data = array('block_id' => $block['block_id'], 'title' => $block['name'], 'hide_header' => isset($block['properties']['hide_header']) ? $block['properties']['hide_header'] : 'N', 'user_class' => $block['user_class']);
             $block_scheme = SchemesManager::getBlockScheme($block['type'], array());
             if ($block['type'] == 'html_block') {
                 // Html block
                 if (isset($block['content']['content']) and fn_string_not_empty($block['content']['content'])) {
                     $block_data['html'] = $block['content']['content'];
                 }
             } elseif (!empty($block_scheme['content']) and !empty($block_scheme['content']['items'])) {
                 // Products and categories: get items
                 $template_variable = 'items';
                 $field = $block_scheme['content']['items'];
                 fn_set_hook('render_block_content_pre', $template_variable, $field, $block_scheme, $block);
                 $items = RenderManager::getValue($template_variable, $field, $block_scheme, $block);
                 // Filter pages - only texts, links and forms posible
                 if ($block['type'] == 'pages') {
                     foreach ($items as $item_id => $item) {
                         if (!in_array($item['page_type'], $allowed_page_types)) {
                             unset($items[$item_id]);
                         }
                     }
                 }
                 if (empty($items)) {
                     continue;
                 }
                 $block_data['total_items'] = count($items);
                 // Images
                 if ($block['type'] == 'products' or $block['type'] == 'categories') {
                     $object_type = $block['type'] == 'products' ? 'product' : 'category';
                     foreach ($items as $items_id => $item) {
                         if (!empty($item['main_pair'])) {
                             $main_pair = $item['main_pair'];
                         } else {
                             $main_pair = fn_get_image_pairs($item[$object_type . '_id'], $object_type, 'M', true, true);
                         }
                         if (!empty($main_pair)) {
                             $items[$items_id]['icon'] = TwigmoImage::getApiImageData($main_pair, $object_type, 'icon', $image_params);
                         }
                     }
                 }
                 // Banners properties
                 if ($block['type'] == 'banners') {
                     $rotation = $block['properties']['template'] == 'addons/banners/blocks/carousel.tpl' ? 'Y' : 'N';
                     $block_data['delay'] = $rotation == 'Y' ? $block['properties']['delay'] : 0;
                     $block_data['hide_navigation'] = isset($block['properties']['navigation']) && $block['properties']['navigation'] == 'N' ? 'Y' : 'N';
                 }
                 $block_data[$block['type']] = Api::getAsList($block['type'], $items);
             }
             $blocks[$block['block_id']] = $block_data;
         }
     }
     return $blocks;
 }