// If the product is electronnicaly distributed, get the assigned files $view->assign('product_files', fn_get_product_files($_REQUEST['product_id'])); // [Page sections] Registry::set('navigation.tabs', array('detailed' => array('title' => fn_get_lang_var('general'), 'js' => true), 'images' => array('title' => fn_get_lang_var('images'), 'js' => true), 'categories' => array('title' => fn_get_lang_var('additional_categories'), 'js' => true), 'options' => array('title' => fn_get_lang_var('options'), 'js' => true), 'qty_discounts' => array('title' => fn_get_lang_var('qty_discounts'), 'js' => true), 'files' => array('title' => fn_get_lang_var('files'), 'js' => true), 'blocks' => array('title' => fn_get_lang_var('blocks'), 'js' => true), 'addons' => array('title' => fn_get_lang_var('addons'), 'js' => true), 'vendors' => array('title' => fn_get_lang_var('vendors'), 'js' => true))); // [/Page sections] // If we have some additional product fields, lets add a tab for them if (!empty($product_data['product_features'])) { Registry::set('navigation.tabs.features', array('title' => fn_get_lang_var('features'), 'js' => true)); } // [Block manager] $block_settings = fn_get_all_blocks('products'); $view->assign('block_settings', $block_settings); list($blocks, $object_id) = fn_get_blocks(array('location' => 'products', 'all' => true, 'product_id' => $_REQUEST['product_id']), false, DESCR_SL); list($all_blocks) = fn_get_blocks(array('location' => 'all_pages', 'all' => true, 'block_properties_location' => 'products'), false); $blocks = fn_array_merge($blocks, $all_blocks, true); $blocks = fn_sort_blocks($object_id, 'products', $blocks); $blocks = fn_check_blocks_availability($blocks, $block_settings); $view->assign('location', $selected_section); $view->assign('blocks', $blocks); $view->assign('avail_positions', fn_get_available_group('products', $_REQUEST['product_id'], DESCR_SL)); // [/Block manager] // // 'Mulitple products updating' page // } elseif ($mode == 'm_update') { if (empty($_SESSION['product_ids']) || empty($_SESSION['selected_fields']) || empty($_SESSION['selected_fields']['object']) || $_SESSION['selected_fields']['object'] != 'product') { return array(CONTROLLER_STATUS_REDIRECT, "products.manage"); } fn_add_breadcrumb(fn_get_lang_var('products'), "products.manage"); $product_ids = $_SESSION['product_ids']; $selected_fields = $_SESSION['selected_fields'];
$locations = fn_get_block_locations(); // [Page sections] if (!empty($locations)) { foreach ($locations as $location => $_location) { Registry::set("navigation.tabs.{$location}", array('title' => fn_get_lang_var($location), 'href' => "block_manager.manage?selected_section={$location}")); } } // [/Page sections] $selected_section = empty($_REQUEST['selected_section']) ? 'all_pages' : $_REQUEST['selected_section']; $view->assign('locations', $locations); list($blocks, $object_id) = fn_get_blocks(array('location' => $selected_section, 'all' => true), false, DESCR_SL); if ($selected_section !== 'all_pages') { list($all_blocks) = fn_get_blocks(array('location' => 'all_pages', 'all' => true, 'block_properties_location' => $selected_section), false); $blocks = fn_array_merge($blocks, $all_blocks, true); } $blocks = fn_sort_blocks($object_id, $selected_section, $blocks); $blocks = fn_check_blocks_availability($blocks, $view->get_var('block_settings')); $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'];
/** * The function returns the list of the blocks * * @param array $params * @param string $lang_code * @return array of blocks */ function fn_get_blocks($params = array(), $allow_sorting = true, $lang_code = CART_LANGUAGE) { $condition = ''; $_blocks = $block_ids = array(); $object_id = 0; $location_properties = fn_get_block_locations(); if (empty($params['all'])) { $condition .= " AND ?:blocks.status = 'A'"; } $fields = array('?:blocks.*', '?:block_descriptions.description', '?:block_links.item_ids', '?:block_links.enable AS assigned'); if (!empty($params)) { if (!empty($location_properties[$params['location']]) && !empty($params[$location_properties[$params['location']]])) { $object_id = (int) $params[$location_properties[$params['location']]]; } if (!empty($params['location']) && $params['location'] == 'checkout' && MODE == 'cart') { $params['location'] = 'cart'; } if (AREA == 'A') { $condition .= db_quote(" AND ?:blocks.location = ?s", $params['location']); } else { $condition .= db_quote(" AND ?:blocks.status = 'A'"); $condition .= db_quote(" AND NOT FIND_IN_SET(?s, ?:blocks.disabled_locations)", $params['location']); if (!empty($object_id)) { $condition .= db_quote(" AND ((?:blocks.block_type = 'B' AND ?:block_links.enable = 'Y' AND (?:block_links.location = 'all_pages' OR (?:block_links.location = ?s AND (?:block_links.object_id = ?i OR ?:block_links.object_id = '0')))) OR ?:blocks.block_type = 'G')", $params['location'], $object_id); } else { $condition .= db_quote(" AND ((?:blocks.block_type = 'B' AND ?:block_links.enable = 'Y' AND (?:block_links.location = 'all_pages' OR ?:block_links.location = ?s)) OR ?:blocks.block_type = 'G')", $params['location']); } } } if (!empty($params['block_type'])) { $condition .= db_quote(" AND ?:blocks.block_type = ?s", $params['block_type']); } $blocks = db_get_hash_array('SELECT ' . implode(',', $fields) . " FROM ?:blocks LEFT JOIN ?:block_links ON ?:block_links.block_id = ?:blocks.block_id AND (?:block_links.object_id = ?i OR ?:block_links.object_id = '0') LEFT JOIN ?:block_descriptions ON ?:block_descriptions.block_id = ?:blocks.block_id AND ?:block_descriptions.object_type = 'B' AND ?:block_descriptions.lang_code = ?s WHERE 1 ?p", 'block_id', $object_id, $lang_code, $condition); if (!empty($blocks)) { $block_ids = array_keys($blocks); } $specific_settings = fn_get_block_specific_settings(); if (!empty($blocks)) { foreach ($blocks as $block_id => $block) { if (!empty($block['properties'])) { $blocks[$block_id]['properties'] = fn_unserialize_block_properties($block['properties'], !empty($params['block_properties_location']) ? $params['block_properties_location'] : (!empty($params['location']) ? $params['location'] : $blocks[$block_id]['location']), $block['block_type'], $block['text_id']); } } if (AREA == 'A') { $assigned = db_get_hash_single_array("SELECT block_id, COUNT(*) as c FROM ?:block_links WHERE block_id IN (?n) AND enable = 'Y' GROUP BY block_id", array('block_id', 'c'), array_keys($blocks)); } foreach ($blocks as $block_id => $block) { if (!empty($location_properties[$block['location']])) { $blocks[$block_id]['object_id'] = $location_properties[$block['location']]; } if (isset($blocks[$block_id]['properties']['list_object']) && isset($specific_settings['list_object'][$blocks[$block_id]['properties']['list_object']]['settings'])) { foreach ($specific_settings['list_object'][$blocks[$block_id]['properties']['list_object']]['settings'] as $property => $value) { if (!is_array($value)) { $val = strtolower(str_replace('%', '', $value)); if (isset($blocks[$block_id][$val])) { if (isset($_REQUEST[$blocks[$block_id][$val]])) { $value = $_REQUEST[$blocks[$block_id][$val]]; } } } $blocks[$block_id]['properties'][$property] = $value; } } if (AREA == 'A') { if (!empty($blocks[$block_id]['properties']['list_object'])) { if (strpos($blocks[$block_id]['properties']['list_object'], '.tpl') === false) { $blocks[$block_id]['items_count'] = empty($block['item_ids']) ? 0 : substr_count($block['item_ids'], ',') + 1; $blocks[$block_id]['properties']['content_name'] = fn_get_lang_var($blocks[$block_id]['properties']['list_object']); } else { $blocks[$block_id]['properties']['content_name'] = fn_get_block_template_description($blocks[$block_id]['properties']['list_object']); } } if (!fn_check_static_location($block['location'])) { $blocks[$block_id]['assigned_to'] = !empty($assigned[$block_id]) ? $assigned[$block_id] : 0; } } } } fn_set_hook('get_blocks', $blocks, $params, $lang_code); if (AREA == 'A' || AREA != 'A' && !empty($params['product_id'])) { fn_get_product_tabs_blocks($object_id, $blocks, $params, $lang_code); } if (!empty($allow_sorting)) { $blocks = fn_sort_blocks($object_id, $params['location'], $blocks); } return array($blocks, $object_id); }