function smarty_function_block_output($_block_data, &$smarty) { $_tpl_vars = $smarty->_tpl_vars; // save state of original variables $display = true; if (!empty($_block_data['properties']['wrapper'])) { // if block is wrapped, display wrapper $display_tpl = $_block_data['properties']['wrapper']; } if (!empty($_block_data['text_id']) && $_block_data['text_id'] == 'central_content') { $block_content = $smarty->display($smarty->get_var('content_tpl'), false); if (!empty($display_tpl)) { if (!empty($smarty->_smarty_vars['capture']['hide_wrapper'])) { $smarty->assign('hide_wrapper', true); unset($smarty->_smarty_vars['capture']['hide_wrapper']); // remove this flag } $smarty->assign('title', !empty($smarty->_smarty_vars['capture']['mainbox_title']) ? $smarty->_smarty_vars['capture']['mainbox_title'] : '', false); $smarty->assign('content', $block_content, false); unset($block_content); } else { $display_tpl = $smarty->get_var('content_tpl'); } } else { $_template = !empty($_block_data['properties']['appearances']) ? $_block_data['properties']['appearances'] : (!empty($_block_data['properties']['list_object']) && strpos($_block_data['properties']['list_object'], '.tpl') !== false ? $_block_data['properties']['list_object'] : ''); if (empty($_template)) { return ''; } // This block is not static, so it is necessary to find its items if (strpos($_block_data['properties']['list_object'], '.tpl') === false || !empty($_block_data['properties']['items_function'])) { $items = fn_get_block_items($_block_data); if (empty($items)) { $display = false; } else { $smarty->assign('items', $items); } } if ($display == true) { if ($smarty->template_exists($_template)) { if (strpos($_template, 'addons/') !== false) { $a = explode('/', $_template); if (fn_load_addon($a[1]) == false) { // do not display template of disabled addon $display = false; } } } else { $display = false; } if ($display == true) { //unset($blocks[$params['id']], $params['id'], $params['template']); $smarty->assign('block', $_block_data, false); // Pass extra parameters to smarty $block_content = $smarty->display($_template, false); if (!empty($display_tpl)) { // if wrapper exists, get block content if (trim($block_content)) { if (!empty($smarty->_smarty_vars['capture']['hide_wrapper'])) { $smarty->assign('hide_wrapper', true); unset($smarty->_smarty_vars['capture']['hide_wrapper']); // remove this flag } $smarty->assign('title', $_block_data['description']); $smarty->assign('content', $block_content, false); unset($block_content); } else { $display = false; } } else { $display_tpl = $_template; } } } } if ($display == true) { $block_content = !empty($block_content) ? $block_content : $smarty->display($display_tpl, false); $smarty->_tpl_vars = $_tpl_vars; // restore original vars again return trim($block_content); } else { return ''; } }
function fn_get_selected_block_data($params, $blocks, $object_id = 0, $location = 'products') { if (empty($blocks)) { return false; } $block_ids = array_keys($blocks); if (empty($params['selected_block_id']) || in_array($params['selected_block_id'], $block_ids) == false) { $selected_block_id = $block_ids[0]; } else { $selected_block_id = $params['selected_block_id']; } if (!empty($object_id) || !empty($location)) { $link = db_get_row("SELECT link_id, item_ids, enable as assigned FROM ?:block_links WHERE block_id = ?i AND object_id = ?i AND location = ?s", $selected_block_id, $object_id, $location); // If now link found, cleanup existing data if (empty($link)) { $link = array('link_id' => '', 'item_ids' => '', 'enable' => 'N'); } $data = $blocks[$selected_block_id]; $data = array_merge($data, $link); if (!empty($data['properties']['fillings']) && $data['properties']['fillings'] == 'manually' && AREA == 'A') { if (!empty($data['item_ids'])) { $data['item_ids'] = explode(',', $data['item_ids']); } return $data; } $data['item_ids'] = fn_get_block_items($data); } return $data; }