if ($action == 'delete' && !empty($delete_breadcrumb)) {
    foreach ($delete_breadcrumb as $breadcrumb_id => $_v) {
        cw_breadcrumbs_delete_breadcrumb($breadcrumb_id);
    }
    $top_message = array('content' => cw_get_langvar_by_name('txt_selected_breadcrumbs_deleted'), 'type' => 'I');
    cw_header_location("index.php?target={$controller_target}&action=process");
}
if ($action == 'add_breadcrumb' || $action == 'edit_breadcrumb') {
    $b_link = trim($breadcrumb_new['link']);
    $b_title = trim($breadcrumb_new['title']);
    $b_uniting = isset($breadcrumb_new['uniting']) ? 1 : 0;
    $b_parent_id = trim($breadcrumb_new['parent_id']);
    if (!empty($b_parent_id) && !empty($b_link) && !empty($b_title)) {
        $b_link = '/' . ltrim($b_link, '/');
        $b_breadcrumb_id = trim($breadcrumb_new['breadcrumb_id']);
        if (cw_breadcrumbs_is_unique_link($b_link, $action, $b_breadcrumb_id)) {
            if ($action == 'add_breadcrumb') {
                cw_array2insert('breadcrumbs', array('link' => $b_link, 'title' => $b_title, 'uniting' => $b_uniting, 'parent_id' => $b_parent_id));
                $top_message = array('content' => cw_get_langvar_by_name('msg_breadcrumb_added'), 'type' => 'I');
            } else {
                cw_array2update('breadcrumbs', array('link' => $b_link, 'title' => $b_title, 'uniting' => $b_uniting, 'parent_id' => $b_parent_id), "breadcrumb_id = {$b_breadcrumb_id}");
            }
            $top_message = array('content' => cw_get_langvar_by_name('msg_breadcrumb_updated'), 'type' => 'I');
        } else {
            $top_message = array('content' => cw_get_langvar_by_name('msg_err_link_already_exists'), 'type' => 'E');
        }
    } else {
        $top_message = array('content' => cw_get_langvar_by_name('lbl_please_fill_required_fields'), 'type' => 'E');
    }
    cw_header_location("index.php?target={$controller_target}&action=process");
}
            $test_link .= '?' . preg_replace('/[0-9]+/', '[[ANY]]', $url['query']);
        }
        $breadcrumbs = cw_breadcrumbs_get_breadcrumbs($test_link, $url['query']);
        if (!empty($breadcrumbs)) {
            global $tables, $current_language, $config, $smarty;
            $lang = !empty($current_language) ? $current_language : $config['default_customer_language'];
            if (count($breadcrumbs) == 1) {
                $query = "\n                    SELECT value\n                    FROM {$tables['languages']}\n                    WHERE code = '{$lang}' and name = '" . $breadcrumbs[0]['title'] . "'\n                ";
                if (cw_query_first_cell($query)) {
                    $breadcrumbs[0]['title'] = cw_get_langvar_by_name($breadcrumbs[0]['title']);
                }
            } else {
                for ($bkey = 0; $bkey < count($breadcrumbs); $bkey++) {
                    $query = "\n                        SELECT value\n                        FROM {$tables['languages']}\n                        WHERE code = '{$lang}' and name = '" . $breadcrumbs[$bkey]['title'] . "'\n                    ";
                    if (cw_query_first_cell($query)) {
                        $breadcrumbs[$bkey]['title'] = cw_get_langvar_by_name($breadcrumbs[$bkey]['title']);
                    }
                }
            }
        } else {
            $breadcrumbs = array();
            $breadcrumbs[] = array('link' => '/index.php', 'title' => cw_get_langvar_by_name('lbl_area_admin'));
            if (!empty($test_link) && cw_breadcrumbs_is_unique_link($test_link, 'add_breadcrumb', 0)) {
                cw_array2insert('breadcrumbs', array('link' => $test_link, 'title' => 'Unknown', 'parent_id' => -1));
            }
        }
        $smarty->assign('location_breadcrumbs', $breadcrumbs);
        $last_breadcrumb = array_pop($breadcrumbs);
        $smarty->assign('title_breadcrumb', $last_breadcrumb['title']);
    }
}