Example #1
0
function build_levels($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $count, $div, $link_to)
{
    // this returns the level structure based on given arrays
    // it is special for browsing from root levels
    $nav_table_struct["linkimage_over_js"] = $nav_table_struct['array_struct'][$count]["linkimage_over_js"];
    $nav_table_struct["linkimage_norm"] = $nav_table_struct['array_struct'][$count]["linkimage_norm"];
    $nav_table_struct["linkimage_over"] = $nav_table_struct['array_struct'][$count]["linkimage_over"];
    $nav_table_struct["linkimage_active"] = $nav_table_struct['array_struct'][$count]["linkimage_active"];
    $nav_table_struct["row_norm_bgcolor"] = $nav_table_struct['array_struct'][$count]["row_norm_bgcolor"];
    $nav_table_struct["row_norm_class"] = $nav_table_struct['array_struct'][$count]["row_norm_class"];
    $nav_table_struct["row_over_bgcolor"] = $nav_table_struct['array_struct'][$count]["row_over_bgcolor"];
    $nav_table_struct["row_active_bgcolor"] = $nav_table_struct['array_struct'][$count]["row_active_bgcolor"];
    $nav_table_struct["row_active_class"] = $nav_table_struct['array_struct'][$count]["row_active_class"];
    $nav_table_struct["space_celltop"] = $nav_table_struct['array_struct'][$count]["space_celltop"];
    $nav_table_struct["space_cellbottom"] = $nav_table_struct['array_struct'][$count]["space_cellbottom"];
    $nav_table_struct["cell_height"] = $nav_table_struct['array_struct'][$count]["cell_height"];
    $nav_table_struct["cell_class"] = $nav_table_struct['array_struct'][$count]["cell_class"];
    $nav_table_struct["cell_active_height"] = $nav_table_struct['array_struct'][$count]["cell_active_height"];
    $nav_table_struct["cell_active_class"] = $nav_table_struct['array_struct'][$count]["cell_active_class"];
    $nav_table_struct["link_before"] = $nav_table_struct['array_struct'][$count]["link_before"];
    $nav_table_struct["link_after"] = $nav_table_struct['array_struct'][$count]["link_after"];
    $nav_table_struct["link_active_before"] = $nav_table_struct['array_struct'][$count]["link_active_before"];
    $nav_table_struct["link_active_after"] = $nav_table_struct['array_struct'][$count]["link_active_after"];
    $temp_menu = '';
    $js = '';
    $depth = count($temp_tree) - $div;
    $current_level = $count;
    $count++;
    $depth2 = $depth - $count + 2;
    $right_cell = '';
    $left_cell = '';
    $cell_top = '';
    $cell_bottom = '';
    $space_right = '';
    $space_cell = '';
    $space_row = '';
    $cell_height = $nav_table_struct["cell_height"] ? $nav_table_struct["cell_height"] : 1;
    if ($nav_table_struct["space_right"]) {
        $right_cell = "<td width=\"" . $nav_table_struct["space_left"] . "\">";
        $right_cell .= spacer($nav_table_struct["space_right"], $cell_height) . "</td>\n";
        $space_right = "<td>" . spacer(1, 1) . "</td>";
    }
    if ($nav_table_struct["space_left"]) {
        $colspan = $count > 1 ? " colspan=\"" . $count . "\"" : "";
        $left_cell = "<td width=\"" . $nav_table_struct["space_left"] . "\"" . $colspan . ">";
        $left_cell .= spacer($nav_table_struct["space_left"], $cell_height) . "</td>\n";
        $space_cell = "<td" . $colspan . ">" . spacer(1, 1) . "</td><td>" . spacer(1, 1) . "</td>";
    } else {
        if ($count > 1) {
            $colspan = $count > 2 ? " colspan=\"" . ($count - 1) . "\"" : "";
            $left_cell = "<td " . $colspan . ">" . spacer(1, 1) . "</td>\n";
            $space_cell = "<td" . $colspan . ">" . spacer(1, 1) . "</td><td>" . spacer(1, 1) . "</td>";
        }
    }
    if ($nav_table_struct["space_celltop"]) {
        $cell_top = spacer(1, $nav_table_struct["space_celltop"]) . "<br />";
    }
    if ($nav_table_struct["space_cellbottom"]) {
        $cell_bottom = "<br />" . spacer(1, $nav_table_struct["space_cellbottom"]);
    }
    $colspan = $depth2 > 1 ? ' colspan="' . $depth2 . '"' : '';
    foreach ($struct as $key => $value) {
        if (_getStructureLevelDisplayStatus($key, $level)) {
            $link_image_id = "linkid" . generic_string(6);
            $link_name_id = ' name="' . $link_image_id . '" id="' . $link_image_id . '"';
            if (!$struct[$key]["acat_redirect"]) {
                $link = 'index.php?';
                if ($struct[$key]["acat_alias"]) {
                    $link .= html_specialchars($struct[$key]["acat_alias"]);
                } else {
                    $link .= 'id=' . $key;
                    //',0,0,1,0,0';
                }
                $redirect['target'] = '';
            } else {
                $redirect = get_redirect_link($struct[$key]["acat_redirect"], ' ', '');
                $link = $redirect['link'];
            }
            $js = ' style="cursor:pointer;cursor:hand;"';
            //display:block;
            $js_act = $js;
            if ($nav_table_struct["js_over_effects"]) {
                if ($redirect['target'] != ' target="_blank"') {
                    $js .= " onclick=\"location.href='" . js_singlequote($link) . "';return false;\"";
                } else {
                    $js .= " onclick=\"window.open('" . js_singlequote($link) . "', 'phpwcmnewwin');return false;\"";
                }
                $js_act = $js;
                $js .= ' onmouseover="';
                if ($nav_table_struct["linkimage_over_js"]) {
                    $js .= "MM_swapImage('" . $link_image_id . "','','" . $nav_table_struct["linkimage_over_js"] . "',1);";
                }
                if ($nav_table_struct["row_over_bgcolor"]) {
                    $js .= "this.bgColor='" . $nav_table_struct["row_over_bgcolor"] . "';";
                }
                $js .= '" onmouseout="';
                if ($nav_table_struct["linkimage_over_js"]) {
                    $js .= "MM_swapImgRestore();";
                }
                if ($nav_table_struct["row_norm_bgcolor"]) {
                    $js .= "this.bgColor='" . $nav_table_struct["row_norm_bgcolor"] . "';";
                }
                $js .= '"';
            } else {
                $js = '';
            }
            // add structure level based classes
            if (!empty($struct[$key]["acat_class"])) {
                $nav_table_struct_temp = $nav_table_struct;
                $nav_table_struct["row_norm_class"] = trim($nav_table_struct["row_norm_class"] . ' ' . $struct[$key]["acat_class"]);
                $nav_table_struct["row_active_class"] = trim($nav_table_struct["row_active_class"] . ' ' . $struct[$key]["acat_class"]);
                $nav_table_struct["row_space_class"] = 'row_space ' . $struct[$key]["acat_class"];
            } else {
                $nav_table_struct_temp = NULL;
            }
            //spacer row
            if ($nav_table_struct["row_space"]) {
                $space_row = "<tr" . table_attributes($nav_table_struct, "row_space", 0, true) . ">\n" . $space_cell;
                $space_row .= "<td" . $colspan . ">" . spacer(1, $nav_table_struct["row_space"]) . "</td>";
                $space_row .= $space_right . "\n</tr>\n";
                $temp_menu .= $space_row;
            }
            if (!empty($temp_tree[$key])) {
                //if($act_cat_id == $key) {
                //check if inside active tree structure
                if ($act_cat_id == $key || !empty($nav_table_struct["all_nodes_active"]) && isset($GLOBALS['LEVEL_KEY'][$key])) {
                    $temp_menu .= "<tr" . table_attributes($nav_table_struct, "row_active", 0, true) . $js_act . ">\n" . $left_cell;
                    $temp_menu .= "<td valign=\"top\">" . str_replace('#', $link_name_id, $nav_table_struct["linkimage_active"]) . "</td>\n";
                    $temp_menu .= "<td" . table_attributes($nav_table_struct, "cell_active", 1, true) . $colspan . ">" . $cell_top;
                    $temp_menu .= '<a href="' . $link . '"' . $redirect['target'] . '>';
                    $temp_menu .= $nav_table_struct["link_active_before"];
                    $temp_menu .= html_specialchars($struct[$key]["acat_name"]);
                    $temp_menu .= $nav_table_struct["link_active_after"] . '</a>';
                } else {
                    $temp_menu .= "<tr" . table_attributes($nav_table_struct, "row_norm", 0, true) . $js . ">\n" . $left_cell;
                    $temp_menu .= "<td valign=\"top\">" . str_replace('#', $link_name_id, $nav_table_struct["linkimage_norm"]) . "</td>\n";
                    $temp_menu .= "<td" . table_attributes($nav_table_struct, "cell", 1, true) . $colspan . ">" . $cell_top;
                    $temp_menu .= '<a href="' . $link . '"' . $redirect['target'] . '>';
                    $temp_menu .= $nav_table_struct["link_before"];
                    $temp_menu .= html_specialchars($struct[$key]["acat_name"]);
                    $temp_menu .= $nav_table_struct["link_after"] . '</a>';
                }
                $temp_menu .= $cell_bottom . "</td>\n" . $right_cell . "</tr>\n";
                $temp_menu .= build_levels($struct, $key, $temp_tree, $act_cat_id, $nav_table_struct, $count, $div, $link_to);
            } else {
                $temp_menu .= "<tr" . table_attributes($nav_table_struct, "row_norm", 0, true) . $js . ">\n" . $left_cell;
                $temp_menu .= "<td valign=\"top\">" . str_replace('#', $link_name_id, $nav_table_struct["linkimage_norm"]) . "</td>\n";
                $temp_menu .= "<td" . table_attributes($nav_table_struct, "cell", 1, true) . $colspan . ">" . $cell_top;
                $temp_menu .= '<a href="' . $link . '"' . $redirect['target'] . '>';
                $temp_menu .= $nav_table_struct["link_before"];
                $temp_menu .= html_specialchars($struct[$key]["acat_name"]);
                $temp_menu .= $nav_table_struct["link_after"] . '</a>';
                $temp_menu .= $cell_bottom . "</td>\n" . $right_cell . "</tr>\n";
            }
            // reset table structure attributes
            if ($nav_table_struct_temp !== NULL) {
                $nav_table_struct = $nav_table_struct_temp;
            }
        }
    }
    if ($nav_table_struct["row_space"] && $count == 1) {
        $temp_menu .= $space_row;
    }
    return $temp_menu;
}
Example #2
0
function nav_table_struct(&$struct, $act_cat_id, $level, $nav_table_struct, $link_to = "index.php")
{
    // start with home directory for the listing = top nav structure
    // 1. Build the recursive tree for given actual article category ID
    // return the tree starting with given start_id (like breadcrumb)
    // if the $start_id = 0 then this stops because 0 = top level
    $level = intval($level);
    $start_id = $act_cat_id;
    $data = array();
    $c = 0;
    $total_levels = 0;
    $level_depth = 0;
    //$start_level 	= $level;
    while ($start_id) {
        $data[$start_id] = 1;
        $start_id = $struct[$start_id]["acat_struct"];
        $total_levels++;
    }
    if (is_array($data) && count($data)) {
        $temp_tree = array_reverse($data, 1);
    } else {
        $temp_tree = false;
    }
    foreach ($struct as $key => $value) {
        if ($struct[$key]["acat_struct"] == $act_cat_id && $key && (!$struct[$key]["acat_hidden"] || isset($GLOBALS['LEVEL_KEY'][$key]))) {
            $c++;
        }
    }
    $c = !$c ? 1 : 0;
    //build image src path and real image tag
    $nav_table_struct["linkimage_over_js"] = get_real_imgsrc($nav_table_struct["linkimage_over"]);
    $nav_table_struct["linkimage_norm"] = add_linkid($nav_table_struct["linkimage_norm"], '#');
    $nav_table_struct["linkimage_over"] = add_linkid($nav_table_struct["linkimage_over"], '#');
    $nav_table_struct["linkimage_active"] = add_linkid($nav_table_struct["linkimage_active"], '#');
    $lc = count($temp_tree);
    $ld = false;
    for ($l = 0; $l <= $lc; $l++) {
        if (isset($GLOBALS['LEVEL_ID'][$l])) {
            $curStructID = $GLOBALS['LEVEL_ID'][$l];
            // now all deeper levels can be deleted
            if ($ld) {
                unset($temp_tree[$curStructID]);
            }
            if (!isset($nav_table_struct['array_struct'][$l])) {
                $nav_table_struct['array_struct'][$l]["linkimage_over_js"] = $nav_table_struct["linkimage_over_js"];
                $nav_table_struct['array_struct'][$l]["linkimage_norm"] = $nav_table_struct["linkimage_norm"];
                $nav_table_struct['array_struct'][$l]["linkimage_over"] = $nav_table_struct["linkimage_over"];
                $nav_table_struct['array_struct'][$l]["linkimage_active"] = $nav_table_struct["linkimage_active"];
                $nav_table_struct['array_struct'][$l]["link_before"] = $nav_table_struct["link_before"];
                $nav_table_struct['array_struct'][$l]["link_after"] = $nav_table_struct["link_after"];
                $nav_table_struct['array_struct'][$l]["link_active_before"] = $nav_table_struct["link_active_before"];
                $nav_table_struct['array_struct'][$l]["link_active_after"] = $nav_table_struct["link_active_after"];
                $nav_table_struct['array_struct'][$l]["row_norm_bgcolor"] = $nav_table_struct["row_norm_bgcolor"];
                $nav_table_struct['array_struct'][$l]["row_norm_class"] = $nav_table_struct["row_norm_class"];
                $nav_table_struct['array_struct'][$l]["row_over_bgcolor"] = $nav_table_struct["row_over_bgcolor"];
                $nav_table_struct['array_struct'][$l]["row_active_bgcolor"] = $nav_table_struct["row_active_bgcolor"];
                $nav_table_struct['array_struct'][$l]["row_active_class"] = $nav_table_struct["row_active_class"];
                $nav_table_struct['array_struct'][$l]["space_celltop"] = $nav_table_struct["space_celltop"];
                $nav_table_struct['array_struct'][$l]["space_cellbottom"] = $nav_table_struct["space_cellbottom"];
                $nav_table_struct['array_struct'][$l]["cell_height"] = $nav_table_struct["cell_height"];
                $nav_table_struct['array_struct'][$l]["cell_class"] = $nav_table_struct["cell_class"];
                $nav_table_struct['array_struct'][$l]["cell_active_height"] = $nav_table_struct["cell_active_height"];
                $nav_table_struct['array_struct'][$l]["cell_active_class"] = $nav_table_struct["cell_active_class"];
            } else {
                $nav_table_struct['array_struct'][$l]["linkimage_over_js"] = get_real_imgsrc($nav_table_struct['array_struct'][$l]["linkimage_over"]);
                $nav_table_struct['array_struct'][$l]["linkimage_norm"] = add_linkid($nav_table_struct['array_struct'][$l]["linkimage_norm"], '#');
                $nav_table_struct['array_struct'][$l]["linkimage_over"] = add_linkid($nav_table_struct['array_struct'][$l]["linkimage_over"], '#');
                $nav_table_struct['array_struct'][$l]["linkimage_active"] = add_linkid($nav_table_struct['array_struct'][$l]["linkimage_active"], '#');
            }
            if ($struct[$curStructID]['acat_hidden'] == 1) {
                unset($temp_tree[$curStructID]);
                $ld = true;
            }
        }
    }
    $temp_menu = build_levels($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $level_depth, $c, $link_to);
    //starts at root level
    if ($temp_menu) {
        initFrontendJS();
        return "<table" . table_attributes($nav_table_struct, "table", 0) . " summary=\"\">\n" . $temp_menu . "</table>";
    }
    return '';
}