Example #1
0
            $sub_menus[$submenu_id]["menu_image_active"] = $submenu_image_active;
            $sub_menus[$submenu_id]["menu_path"] = $db->f("submenu_path");
            $sub_menus[$submenu_id]["submenu_style_name"] = $db->f("submenu_style_name");
            $sub_menus[$submenu_id]["match_type"] = $db->f("match_type");
            $sub_menus[$parent_menu_id]["subs"][] = $submenu_id;
        }
    }
    set_session("session_last_menu_id", $active_menu_id);
    $submenu_style_name = "";
    if (isset($menus[$active_menu_id])) {
        $submenu_style_name = $menus[$active_menu_id]["submenu_style_name"];
    }
    if (!$submenu_style_name) {
        $submenu_style_name = "secondary";
    }
    set_menus($sub_menus, 0, 0, $active_submenu_id, $top_menu_type, "secondary_", $submenu_style_name);
}
$t->set_var("index_href", get_custom_friendly_url("index.php"));
$t->set_var("products_href", get_custom_friendly_url("products.php"));
$t->set_var("basket_href", get_custom_friendly_url("basket.php"));
$t->set_var("user_profile_href", get_custom_friendly_url("user_profile.php"));
$t->set_var("admin_href", "admin.php");
$t->set_var("help_href", get_custom_friendly_url("page.php") . "?page=help");
$t->set_var("about_href", get_custom_friendly_url("page.php") . "?page=about");
if (!isset($header_title)) {
    $header_title = "";
}
$t->set_var("header_title", $header_title);
$block_parsed = true;
$t->parse("block_body", false);
// clear previous block body content
Example #2
0
function set_menus(&$menus, $parent_id, $level, $active_menu_id, $top_menu_type = 0, $template_prefix = "", $submenu_style_name = "")
{
    global $t, $current_page, $language_code;
    $subs = isset($menus[$parent_id]) && isset($menus[$parent_id]["subs"]) ? $menus[$parent_id]["subs"] : array();
    $request_uri_path = get_request_path();
    $request_page = get_request_page();
    if (!isset($current_page)) {
        $current_page = $request_page;
    }
    $t->set_var("secondary_table_class", $submenu_style_name . "Menu");
    $t->set_var("secondary_begin_id", $submenu_style_name . "Begin");
    $t->set_var("secondary_end_id", $submenu_style_name . "End");
    for ($i = 0, $ic = count($subs); $i < $ic; $i++) {
        $show_menu_id = $subs[$i];
        $menu_url = $menus[$show_menu_id]["menu_url"];
        $menu_target = $menus[$show_menu_id]["menu_target"];
        $menu_title = $menus[$show_menu_id]["menu_title"];
        $menu_image = $menus[$show_menu_id]["menu_image"];
        $menu_image_active = $menus[$show_menu_id]["menu_image_active"];
        $menu_submenu_style = $menus[$show_menu_id]["submenu_style_name"];
        $menu_path = $menus[$show_menu_id]["menu_path"];
        $menu_path_id = str_replace(",", "_", $menu_path) . $show_menu_id;
        $has_nested = isset($menus[$show_menu_id]["subs"]) ? is_array($menus[$show_menu_id]["subs"]) : false;
        $is_last = $i == $ic - 1;
        $is_first = $i == 0;
        if ($has_nested) {
            set_menus($menus, $show_menu_id, $level + 1, $active_menu_id, $top_menu_type, $template_prefix, $submenu_style_name);
        }
        $t->set_var($template_prefix . "menu_path_id", $menu_path_id);
        $is_active = false;
        if ($show_menu_id == $active_menu_id) {
            $is_active = true;
        } elseif (isset($menus[$show_menu_id]["match_type"])) {
            $menu_page = $menus[$show_menu_id]["menu_page"];
            $match_type = $menus[$show_menu_id]["match_type"];
            if ($menu_page == $request_page || $menu_page == $current_page || $menu_page == $request_uri_path) {
                if ($match_type == 1) {
                    $is_active = true;
                } else {
                    if ($match_type == 2) {
                        $is_active = true;
                        $menu_request_uri = preg_replace("/\\#.*\$/", "", $menu_url);
                        $menu_request_uri = preg_replace("/^.*\\?/", "", $menu_request_uri);
                        if ($menu_request_uri) {
                            $menu_params = explode("&", $menu_request_uri);
                            for ($s = 0; $s < sizeof($menu_params); $s++) {
                                if (preg_match("/^(.+)=(.+)\$/", $menu_params[$s], $matches)) {
                                    $param_name = $matches[1];
                                    $menu_param_value = $matches[2];
                                    $request_param_value = get_param($param_name);
                                    if (strval($menu_param_value) != strval($request_param_value)) {
                                        $is_active = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        $menu_style = $submenu_style_name ? $submenu_style_name . "Menu" : "menu";
        if ($is_active) {
            $menu_style .= "Active";
            $menu_image = $menu_image_active;
            if ($is_active && $template_prefix) {
                set_session("session_last_submenu_id", $show_menu_id);
            }
        }
        $t->set_var($template_prefix . "menu_href", htmlspecialchars($menu_url));
        if ($menu_target) {
            $t->set_var($template_prefix . "menu_target", "target=\"" . htmlspecialchars($menu_target) . "\"");
        } else {
            $t->set_var($template_prefix . "menu_target", "");
        }
        $t->set_var($template_prefix . "menu_style", $menu_style);
        $t->set_var($template_prefix . "menu_title", $menu_title);
        if ($top_menu_type) {
            if ($menu_image && file_exists($menu_image) && ($top_menu_type != 2 || !strlen($menu_title))) {
                $is_menu_image = true;
                // check image translation
                $slash_pos = strrpos($menu_image, "/");
                if ($slash_pos === false) {
                    $menu_image_translation = $language_code . "/" . $menu_image;
                } else {
                    $menu_image_translation = substr($menu_image, 0, $slash_pos) . "/" . $language_code . substr($menu_image, $slash_pos);
                }
                if (file_exists($menu_image_translation)) {
                    $menu_image = $menu_image_translation;
                }
                $image_size = @GetImageSize($menu_image);
                $t->set_var("alt", htmlspecialchars($menu_title));
                $t->set_var("src", htmlspecialchars($menu_image));
                if (is_array($image_size)) {
                    $t->set_var("width", "width=\"" . $image_size[0] . "\"");
                    $t->set_var("height", "height=\"" . $image_size[1] . "\"");
                } else {
                    $t->set_var("width", "");
                    $t->set_var("height", "");
                }
                $t->sparse($template_prefix . "menu_image", false);
            } else {
                $is_menu_image = false;
                $t->set_var($template_prefix . "menu_image", "");
            }
            if ($top_menu_type != 1 || !$is_menu_image) {
                $t->sparse($template_prefix . "menu_text", false);
            } else {
                $t->set_var($template_prefix . "menu_text", "");
            }
        } else {
            $t->set_var($template_prefix . "menu_image", "");
            $t->set_var($template_prefix . "menu_text", "");
        }
        if ($has_nested) {
            $t->set_var($template_prefix . "submenus", $t->get_var($template_prefix . "submenus_" . ($level + 1)));
            $t->parse($template_prefix . "submenus_rows");
            $t->set_var($template_prefix . "submenus_" . ($level + 1), "");
            $t->set_var($template_prefix . "submenus", "");
        } else {
            $t->set_var($template_prefix . "submenus_rows", "");
        }
        if ($level > 0) {
            $t->parse_to($template_prefix . "menus", $template_prefix . "submenus_" . $level);
        } else {
            $t->parse($template_prefix . "menus");
        }
        if ($has_nested) {
            $t->set_var($template_prefix . "submenus_rows", "");
        }
        if ($is_last && $level == 0) {
            $t->parse($template_prefix . "menus_rows");
            $t->set_var($template_prefix . "menus", "");
        }
    }
}