}
if ($mode == 'delete') {
    if (!empty($_REQUEST['store_location_id'])) {
        if (fn_delete_store_location($_REQUEST['store_location_id'])) {
            $count = db_get_field("SELECT COUNT(*) FROM ?:store_locations");
            if (empty($count)) {
                Registry::get('view')->display('addons/store_locator/views/store_locator/manage.tpl');
            }
        }
    }
    exit;
} elseif ($mode == 'manage') {
    list($store_locations, $search) = fn_get_store_locations($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'), DESCR_SL);
    Registry::get('view')->assign('sl_settings', fn_get_store_locator_settings());
    Registry::get('view')->assign('store_locations', $store_locations);
    Registry::get('view')->assign('search', $search);
} elseif ($mode == 'add') {
    // [Page sections]
    Registry::set('navigation.tabs', array('detailed' => array('title' => __('general'), 'js' => true), 'addons' => array('title' => __('addons'), 'js' => true)));
    // [/Page sections]
} elseif ($mode == 'update') {
    $store_location = fn_get_store_location($_REQUEST['store_location_id'], DESCR_SL);
    if (empty($store_location)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    Registry::get('view')->assign('store_location', $store_location);
    // [Page sections]
    $tabs = array('detailed' => array('title' => __('general'), 'js' => true), 'addons' => array('title' => __('addons'), 'js' => true));
    Registry::set('navigation.tabs', $tabs);
    // [/Page sections]
}
****************************************************************************/
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($mode == 'search') {
    fn_add_breadcrumb(__('store_locator'));
    list($store_locations, $search) = fn_get_store_locations($_REQUEST);
    Registry::get('view')->assign('sl_settings', fn_get_store_locator_settings());
    Registry::get('view')->assign('store_locations', $store_locations);
    Registry::get('view')->assign('store_locator_search', $search);
}
if ($mode == "show_store") {
    fn_add_breadcrumb(__('store_locator'));
    if (intval($_REQUEST['store_location_id'])) {
        $store_locations[0] = fn_get_store_location(intval($_REQUEST['store_location_id']));
        Registry::get('view')->assign('sl_settings', fn_get_store_locator_settings());
        Registry::get('view')->assign('store_locations', $store_locations);
    }
}
if ($mode == "show_all_stores") {
    fn_add_breadcrumb(__('store_locator'));
    $aviable_cities = array();
    $store_locations_params = array();
    $params = $_REQUEST;
    $fields = array('?:store_locations.*', '?:store_location_descriptions.*', '?:country_descriptions.country as country_title');
    $join = db_quote(" LEFT JOIN ?:store_location_descriptions ON ?:store_locations.store_location_id = ?:store_location_descriptions.store_location_id AND ?:store_location_descriptions.lang_code = ?s", CART_LANGUAGE);
    $join .= db_quote(" LEFT JOIN ?:country_descriptions ON ?:store_locations.country = ?:country_descriptions.code AND ?:country_descriptions.lang_code = ?s", CART_LANGUAGE);
    $condition = 1;
    if (AREA == 'C') {
        $condition .= " AND status = 'A'";