Example #1
0
function fn_rus_pickpoint_install()
{
    $service = array('status' => 'A', 'module' => 'pickpoint', 'code' => 'pickpoint', 'sp_file' => '', 'description' => 'Pickpoint');
    $service['service_id'] = db_query('INSERT INTO ?:shipping_services ?e', $service);
    foreach (Languages::getAll() as $service['lang_code'] => $lang_data) {
        db_query('INSERT INTO ?:shipping_service_descriptions ?e', $service);
    }
    db_query("CREATE TABLE IF NOT EXISTS `?:rus_pickpoint_postamat` (\n        `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,\n        `city_name` varchar(150) NOT NULL,\n        `country_name` varchar(150) NOT NULL,\n        `region_name` varchar(150) NOT NULL,\n        `number` varchar(20) NOT NULL,\n        `name` varchar(250) NOT NULL,\n        `work_time` varchar(100) NOT NULL,\n        `post_code` varchar(16) NOT NULL,\n        `address` varchar(255) NOT NULL,\n        PRIMARY KEY (`id`)\n    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
    $http_url = fn_get_storefront_protocol();
    $url = $http_url . '://e-solution.pickpoint.ru/api/';
    RusPickpoint::postamatPickpoint($url . 'postamatlist');
}
Example #2
0
function fn_rus_exim_1c_get_information()
{
    $storefront_url = fn_get_storefront_url(fn_get_storefront_protocol());
    if (fn_allowed_for('ULTIMATE')) {
        if (Registry::get('runtime.company_id') || Registry::get('runtime.simple_ultimate')) {
        } else {
            $storefront_url = '';
        }
    }
    $exim_1c_info = '';
    if (!empty($storefront_url)) {
        $exim_1c_info = __('exim_1c_information', array('[http_location]' => $storefront_url . '/' . 'exim_1c'));
    }
    return $exim_1c_info;
}
Example #3
0
function fn_price_list_info()
{
    $schema = fn_get_schema('price_list', 'schema');
    if (empty($schema)) {
        // workaround to avoid notices when installing addon
        return;
    }
    $storefront_url = fn_get_storefront_url(fn_get_storefront_protocol());
    if (fn_allowed_for('ULTIMATE')) {
        if (Registry::get('runtime.company_id') || Registry::get('runtime.simple_ultimate')) {
        } else {
            $storefront_url = '';
        }
    }
    if (!empty($storefront_url)) {
        return __('price_list.text_regenerate', array('[buttons]' => fn_price_list_generate_buttons($schema), '[links]' => fn_price_list_generate_links($schema, $storefront_url)));
    } else {
        return __('price_list.text_select_storefront');
    }
}
Example #4
0
/**
 * Gets product url
 *
 * @param $product_id
 * @param string $lang_code
 * @return bool
 */
function fn_exim_get_product_url($product_id, $lang_code = '')
{
    if (fn_allowed_for('ULTIMATE')) {
        if (Registry::get('runtime.company_id')) {
            $company_id = Registry::get('runtime.company_id');
        } else {
            $company_id = db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $product_id);
        }
        $company_url = '&company_id=' . $company_id;
    } else {
        $company_url = '';
    }
    $url = fn_url('products.view?product_id=' . $product_id . $company_url, 'C', fn_get_storefront_protocol(), $lang_code);
    fn_set_hook('exim_get_product_url', $url, $product_id, $options, $lang_code);
    return $url;
}
Example #5
0
/**
 * Define whether current page should be indexed
 *
 * $indexed_pages's element structure:
 * 'dipatch' => array( 'index' => array('param1','param2'),
 *                      'noindex' => array('param3'),
 *                  )
 * the page can be indexed only if the current dispatch is in keys of the $indexed_pages array.
 * If so, the page is indexed only if param1 and param2 are the keys of the $_REQUEST array and param3 is not.
 * @param array $request
 * @return bool $index_page  indicate whether indexed or not
 */
function fn_seo_is_indexed_page($request)
{
    if (defined('HTTPS') && fn_get_storefront_protocol() == 'http') {
        return false;
    }
    $controller_status = Registry::get('view')->getTemplateVars('exception_status');
    if (!empty($controller_status) && $controller_status != CONTROLLER_STATUS_OK) {
        return false;
    }
    $index_schema = fn_get_schema('seo', 'indexation');
    // backward compatibility, since 4.3.1
    $seo_vars = fn_get_seo_vars();
    foreach ($seo_vars as $seo_var) {
        if (!empty($seo_var['indexed_pages'])) {
            $index_schema = fn_array_merge($index_schema, $seo_var['indexed_pages']);
        }
    }
    // deprecated
    fn_set_hook('seo_is_indexed_page', $index_schema);
    $controller = Registry::get('runtime.controller');
    $mode = Registry::get('runtime.mode');
    if (isset($index_schema[$controller . '.' . $mode]) && is_array($index_schema[$controller . '.' . $mode])) {
        $dispatch_rules = $index_schema[$controller . '.' . $mode];
        if (empty($dispatch_rules['index']) && empty($dispatch_rules['noindex'])) {
            $index_page = true;
        } else {
            $index_cond = true;
            if (!empty($dispatch_rules['index']) && is_array($dispatch_rules['index'])) {
                $index_cond = false;
                if (sizeof(array_intersect($dispatch_rules['index'], array_keys($request))) == sizeof($dispatch_rules['index'])) {
                    $index_cond = true;
                }
            }
            $noindex_cond = true;
            if (isset($dispatch_rules['noindex'])) {
                if (is_bool($dispatch_rules['noindex'])) {
                    $noindex_cond = false;
                } elseif (is_array($dispatch_rules['noindex'])) {
                    $noindex_cond = false;
                    if (sizeof(array_intersect($dispatch_rules['noindex'], array_keys($request))) == 0) {
                        $noindex_cond = true;
                    }
                }
            }
            $index_page = $index_cond && $noindex_cond;
        }
    } else {
        // All pages that are not listed at schema should be indexed
        $index_page = true;
    }
    return $index_page;
}
Example #6
0
function fn_google_sitemap_get_content($map_page = 0)
{
    $sitemap_settings = Registry::get('addons.google_sitemap');
    $location = fn_get_storefront_url(fn_get_storefront_protocol());
    $lmod = date("Y-m-d", TIME);
    // HEAD SECTION
    $simple_head = <<<HEAD
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">


HEAD;
    $simple_foot = <<<FOOT

</urlset>
FOOT;
    $index_map_url = <<<HEAD
    <url>
        <loc>{$location}/</loc>
        <lastmod>{$lmod}</lastmod>
        <changefreq>{$sitemap_settings['site_change']}</changefreq>
        <priority>{$sitemap_settings['site_priority']}</priority>
    </url>

HEAD;
    // END HEAD SECTION
    $parts = 0;
    if ($sitemap_settings['include_categories'] == "Y") {
        $parts++;
        $get_categories = true;
    }
    if ($sitemap_settings['include_products'] == "Y") {
        $parts++;
        $get_products = true;
    }
    if ($sitemap_settings['include_pages'] == "Y") {
        $parts++;
        $get_pages = true;
    }
    if ($sitemap_settings['include_extended'] == "Y") {
        $parts++;
        $get_features = true;
    }
    if (fn_allowed_for('MULTIVENDOR') && $sitemap_settings['include_companies'] == 'Y') {
        $parts++;
        $get_companies = true;
    }
    fn_set_progress('parts', $parts);
    // SITEMAP CONTENT
    $link_counter = 1;
    $file_counter = 1;
    $sitemap_path = fn_get_files_dir_path(false) . 'google_sitemap/';
    fn_rm($sitemap_path);
    fn_mkdir($sitemap_path);
    $file = fopen($sitemap_path . 'sitemap' . $file_counter . '.xml', "wb");
    fwrite($file, $simple_head . $index_map_url);
    $languages = db_get_hash_single_array("SELECT lang_code, name FROM ?:languages WHERE status = 'A'", array('lang_code', 'name'));
    if (!empty($get_categories)) {
        $categories = db_get_fields("SELECT category_id FROM ?:categories WHERE FIND_IN_SET(?i, usergroup_ids) AND status = 'A' ?p", USERGROUP_ALL, fn_get_google_sitemap_company_condition('?:categories.company_id'));
        fn_set_progress('step_scale', count($categories));
        //Add the all active categories
        foreach ($categories as $category) {
            $links = fn_google_sitemap_generate_link('category', $category, $languages);
            $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['categories_change'], $sitemap_settings['categories_priority']);
            fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot, 'categories');
            fwrite($file, $item);
        }
    }
    if (!empty($get_products)) {
        $total = ITEMS_PER_PAGE;
        $i = 0;
        $params = $_REQUEST;
        $params['custom_extend'] = array('categories');
        $params['sort_by'] = 'null';
        $params['only_short_fields'] = true;
        // NEEDED ONLY FOR NOT TO LOAD UNNECESSARY FIELDS FROM DB
        $params['area'] = 'C';
        $original_auth = $_SESSION['auth'];
        $_SESSION['auth'] = fn_fill_auth(array(), array(), false, 'C');
        fn_set_progress('step_scale', db_get_field("SELECT COUNT(*) FROM ?:products WHERE status = 'A'"));
        while ($params['pid'] = db_get_fields("SELECT product_id FROM ?:products WHERE status = 'A' ORDER BY product_id ASC LIMIT {$i}, {$total}")) {
            $i += $total;
            list($products) = fn_get_products($params, ITEMS_PER_PAGE);
            foreach ($products as $product) {
                $links = fn_google_sitemap_generate_link('product', $product['product_id'], $languages);
                $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['products_change'], $sitemap_settings['products_priority']);
                fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot, 'products');
                fwrite($file, $item);
            }
        }
        unset($products);
        $_SESSION['auth'] = $original_auth;
    }
    if (!empty($get_pages)) {
        $page_types = fn_get_page_object_by_type();
        unset($page_types[PAGE_TYPE_LINK]);
        list($pages) = fn_get_pages(array('simple' => true, 'status' => 'A', 'page_type' => array_keys($page_types)));
        fn_set_progress('step_scale', count($pages));
        //Add the all active pages
        foreach ($pages as $page) {
            $links = fn_google_sitemap_generate_link('page', $page['page_id'], $languages, $page);
            $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['pages_change'], $sitemap_settings['pages_priority']);
            fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot, 'pages');
            fwrite($file, $item);
        }
    }
    if (!empty($get_features)) {
        $vars = db_get_fields("SELECT ?:product_feature_variants.variant_id FROM ?:product_feature_variants " . "LEFT JOIN ?:product_features ON (?:product_feature_variants.feature_id = ?:product_features.feature_id) " . "WHERE ?:product_features.feature_type = ?s AND ?:product_features.status = 'A'", ProductFeatures::EXTENDED);
        fn_set_progress('step_scale', count($vars));
        //Add the all active extended features
        foreach ($vars as $var) {
            $links = fn_google_sitemap_generate_link('extended', $var, $languages);
            $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['extended_change'], $sitemap_settings['extended_priority']);
            fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot, 'features');
            fwrite($file, $item);
        }
    }
    if (!empty($get_companies)) {
        $companies = db_get_fields("SELECT company_id FROM ?:companies WHERE status = 'A' ?p", fn_get_google_sitemap_company_condition('?:companies.company_id'));
        fn_set_progress('step_scale', count($companies));
        if (!empty($companies)) {
            foreach ($companies as $company_id) {
                $links = fn_google_sitemap_generate_link('companies', $company_id, $languages);
                $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['companies_change'], $sitemap_settings['companies_priority']);
                fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot, 'companies');
                fwrite($file, $item);
            }
        }
    }
    fn_set_hook('sitemap_item', $sitemap_settings, $file, $lmod, $link_counter, $file_counter);
    fwrite($file, $simple_foot);
    fclose($file);
    if ($file_counter == 1) {
        fn_rename($sitemap_path . 'sitemap' . $file_counter . '.xml', $sitemap_path . 'sitemap.xml');
    } else {
        // Make a map index file
        $maps = '';
        $seo_enabled = Registry::get('addons.seo.status') == 'A' ? true : false;
        for ($i = 1; $i <= $file_counter; $i++) {
            if ($seo_enabled) {
                $name = $location . '/sitemap' . $i . '.xml';
            } else {
                $name = fn_url('xmlsitemap.view?page=' . $i, 'C', fn_get_storefront_protocol());
            }
            $name = htmlentities($name);
            $maps .= <<<MAP
    <sitemap>
        <loc>{$name}</loc>
        <lastmod>{$lmod}</lastmod>
    </sitemap>

MAP;
        }
        $index_map = <<<HEAD
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

{$maps}
</sitemapindex>
HEAD;
        $file = fopen($sitemap_path . 'sitemap.xml', "wb");
        fwrite($file, $index_map);
        fclose($file);
    }
    fn_set_notification('N', __('notice'), __('google_sitemap.map_generated'));
    exit;
}