function fn_update_location($data) { $disallow_properties = array('location'); $specific_settings = fn_get_block_specific_settings(); $location_properties = $specific_settings['properties']['location']; foreach ($data as $setting_name => $value) { if (!in_array($setting_name, $disallow_properties)) { if (isset($location_properties[$setting_name]['multilingual']) && $location_properties[$setting_name]['multilingual'] == true) { $_data = array('location' => $data['location'], 'property' => $setting_name, 'description' => $value, 'lang_code' => DESCR_SL); db_query("REPLACE INTO ?:block_location_descriptions ?e", $_data); } else { $_data = array('location' => $data['location'], 'property' => $setting_name, 'value' => $value); db_query("REPLACE INTO ?:block_location_properties ?e", $_data); } } } return true; }
/** * Get all block settings * * @return array block settings */ function fn_get_all_blocks($selected_section = '') { // Get core blocks $base_dir = DIR_SKINS . Registry::get('settings.skin_name_customer') . '/customer/'; $blocks = fn_get_dir_contents($base_dir . 'blocks', false, true, '.tpl', 'blocks/'); $wrappers = fn_get_dir_contents($base_dir . 'blocks/wrappers', false, true, '.tpl', 'blocks/wrappers/'); // Now get blocks from addons foreach (Registry::get('addons') as $addon => $v) { if ($v['status'] == 'A') { $_blocks = fn_get_dir_contents($base_dir . 'addons/' . $addon . '/blocks', false, true, '.tpl', 'addons/' . $addon . '/blocks/'); if (!empty($_blocks)) { $blocks = fn_array_merge($blocks, $_blocks, false); } $_wrappers = fn_get_dir_contents($base_dir . 'addons/' . $addon . '/blocks/wrappers', false, true, '.tpl', 'addons/' . $addon . '/blocks/wrappers/'); if (!empty($_wrappers)) { $wrappers = fn_array_merge($wrappers, $_wrappers, false); } } } // Convert array with blocks to key=>value form $blocks = fn_array_combine($blocks, true); // Get block options $_structure = fn_get_block_properties(); foreach ($_structure as $object => $data) { if (!empty($data['appearances'])) { foreach ($data['appearances'] as $tpl => $_data) { if (!empty($blocks[$tpl])) { unset($blocks[$tpl]); } if (isset($_data['conditions']['locations'])) { if (!in_array($selected_section, $_data['conditions']['locations'])) { unset($_structure[$object]['appearances'][$tpl]); } } } } } // Get blocks with the "settings" $specific_settings = fn_get_block_specific_settings(); $additional_sections = array(); if (!empty($specific_settings['list_object'])) { foreach ($specific_settings['list_object'] as $template => $block) { if (isset($block['settings'])) { if (!empty($blocks[$template])) { unset($blocks[$template]); } if (!empty($block['settings']['section'])) { if (isset($block['settings']['locations'])) { if (!in_array($selected_section, $block['settings']['locations'])) { continue; } } $additional_sections[$block['settings']['section']]['items'][] = array('name' => fn_get_block_template_description($template), 'template' => $template); } } } } $_blocks = array(); foreach ($blocks as $k => $v) { $_blocks[] = array('name' => fn_get_block_template_description($k), 'template' => $k); } $result = array('dynamic' => $_structure, 'static' => $_blocks, 'wrappers' => $wrappers); foreach ($additional_sections as $section => $data) { $result['additional'][$section]['items'] = $data['items']; } return $result; }