if ($mode == 'view') { fn_add_breadcrumb(__('tags')); $tag = ''; if (!empty($_REQUEST['tag'])) { if (Registry::get('addons.tags.tags_for_products') == 'Y') { $params = $_REQUEST; $params['extend'] = array('description'); list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page')); fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true)); $selected_layout = fn_get_products_layout($params); Registry::get('view')->assign('selected_layout', $selected_layout); Registry::get('view')->assign('products', $products); Registry::get('view')->assign('search', $search); } if (Registry::get('addons.tags.tags_for_pages') == 'Y') { $page_types = fn_get_page_object_by_type(); $params = $_REQUEST; $params['page_type'] = array_keys($page_types); $params['status'] = array('A'); $params['simple'] = true; list($pages, $params) = fn_get_pages($params); Registry::get('view')->assign('pages', $pages); Registry::get('view')->assign('page_types', $page_types); } $tag = $_REQUEST['tag']; } $title = __('items_marked_by_tag', array('[tag]' => $tag)); Registry::get('view')->assign('page_title', $title); fn_add_breadcrumb($title); if (!empty($products) || !empty($pages)) { Registry::get('view')->assign('tag_objects_exist', true);
/** * Gets page data * * @param mixed $page_id Page identifier * @param string $lang_code 2 letters language code * @param bool $preview Page data for preview (ignore cahce) * @return array|bool Page data on success, false otherwise */ function fn_get_page_data($page_id, $lang_code = CART_LANGUAGE, $preview = false, $area = AREA) { static $cache = array(); if (empty($page_id)) { return false; } fn_set_hook('get_page_data_pre', $page_id, $lang_code, $preview, $area); if (empty($cache[$page_id])) { $condition = fn_get_company_condition('?:pages.company_id'); if ($area != 'A' && !$preview) { $condition .= " AND (" . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:pages.usergroup_ids', true) . ")"; } $field_list = "?:pages.*, ?:page_descriptions.*"; $join = " INNER JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id"; $condition .= db_quote(" AND ?:pages.page_type IN (?a)", array_keys(fn_get_page_object_by_type())); fn_set_hook('pre_get_page_data', $field_list, $join, $condition, $lang_code); $page_data = db_get_row("SELECT {$field_list} FROM ?:pages ?p WHERE ?:pages.page_id = ?i AND ?:page_descriptions.lang_code = ?s ?p", $join, $page_id, $lang_code, $condition); if (empty($page_data) || $area != 'A' && ($page_data['status'] == 'D' || $page_data['use_avail_period'] == 'Y' && ($page_data['avail_from_timestamp'] > TIME || $page_data['avail_till_timestamp'] < TIME)) && empty($preview)) { return false; } fn_set_hook('get_page_data', $page_data, $lang_code, $preview, $area); // Generate meta description automatically if (empty($page_data['meta_description']) && defined('AUTO_META_DESCRIPTION') && $area != 'A') { $page_data['meta_description'] = fn_generate_meta_description($page_data['description']); } $cache[$page_id] = $page_data; } return !empty($cache[$page_id]) ? $cache[$page_id] : false; }
$view->assign('hide_header', true); } $view->assign('hide_show_all', true); } if ($total < PAGE_SHOW_ALL) { $view->assign('expand_all', true); } } else { // search page $params['paginate'] = true; } $params['add_root'] = !empty($_REQUEST['root']) ? $_REQUEST['root'] : ''; list($pages, $params) = fn_get_pages($params, Registry::get('settings.Appearance.admin_pages_per_page')); $view->assign('pages_tree', $pages); $view->assign('search', $params); $view->assign('page_types', fn_get_page_object_by_type()); if (!empty($_REQUEST['except_id'])) { $view->assign('except_id', $_REQUEST['except_id']); } if ($mode == 'picker') { $view->display('pickers/pages_picker_contents.tpl'); exit; } } $view->assign('usergroups', fn_get_usergroups('C', DESCR_SL)); /* /Preparing page data for templates and performing simple actions*/ /** /Body **/ /* -------------------------------------- Related functions -------------------------------- */ // // update by id or create new page //
if ($total < PAGE_SHOW_ALL) { Registry::get('view')->assign('expand_all', true); } } else { // search page $items_per_page = Registry::get('settings.Appearance.admin_pages_per_page'); } $params['add_root'] = !empty($_REQUEST['root']) ? $_REQUEST['root'] : ''; $params['simple'] = true; list($pages, $params) = fn_get_pages($params, $items_per_page); Registry::get('view')->assign('pages_tree', $pages); Registry::get('view')->assign('search', $params); if (empty($params['full_search'])) { Registry::get('view')->assign('page_types', fn_get_page_type_filter($page_type)); } else { Registry::get('view')->assign('page_types', fn_get_page_object_by_type()); } Registry::get('view')->assign('is_exclusive_page_type', fn_is_exclusive_page_type($page_type)); if (!empty($_REQUEST['except_id'])) { Registry::get('view')->assign('except_id', $_REQUEST['except_id']); } if (fn_show_picker('pages', PAGE_THRESHOLD) == false) { $params = array('page_type' => fn_is_exclusive_page_type($page_type) ? $page_type : ''); Registry::get('view')->assign('parent_pages', fn_get_pages_plain_list($params)); } if ($mode == 'picker') { if (!empty($_REQUEST['combination_suffix'])) { Registry::get('view')->assign('combination_suffix', $_REQUEST['combination_suffix']); } Registry::get('view')->display('pickers/pages/picker_contents.tpl'); exit;
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; }
if ($total < PAGE_SHOW_ALL) { Tygh::$app['view']->assign('expand_all', true); } } else { // search page $items_per_page = Registry::get('settings.Appearance.admin_pages_per_page'); } $params['add_root'] = !empty($_REQUEST['root']) ? $_REQUEST['root'] : ''; $params['simple'] = true; list($pages, $params) = fn_get_pages($params, $items_per_page); Tygh::$app['view']->assign('pages_tree', $pages); Tygh::$app['view']->assign('search', $params); if (empty($params['full_search'])) { Tygh::$app['view']->assign('page_types', fn_get_page_type_filter($page_type)); } else { Tygh::$app['view']->assign('page_types', fn_get_page_object_by_type()); } Tygh::$app['view']->assign('is_exclusive_page_type', fn_is_exclusive_page_type($page_type)); if (!empty($_REQUEST['except_id'])) { Tygh::$app['view']->assign('except_id', $_REQUEST['except_id']); } if (fn_show_picker('pages', PAGE_THRESHOLD) == false) { $params = array('page_type' => fn_is_exclusive_page_type($page_type) ? $page_type : ''); Tygh::$app['view']->assign('parent_pages', fn_get_pages_plain_list($params)); } if ($mode == 'picker') { if (!empty($_REQUEST['combination_suffix'])) { Tygh::$app['view']->assign('combination_suffix', $_REQUEST['combination_suffix']); } Tygh::$app['view']->display('pickers/pages/picker_contents.tpl'); exit;