cacho wrote:WHY this code have html embed with tables, etc...
Perhaps the Bold red word will clarify why???
{NAV_TABLE_COLUMN}
cacho wrote:Then I want to know where is the code that replace {NAV_TABLE_COLUMN}
"include/inc_front/content.func.inc.php" shows the replacement tag call to function that constructs the "
table-based" menu:
Code: Select all
// Left table based rollover navigation
if( ! ( strpos($content["all"],'{NAV_TABLE_COLUMN')===false ) ) {
$content["all"] = str_replace('{NAV_TABLE_COLUMN}', '{NAV_TABLE_COLUMN:0}', $content["all"]);
$replace = 'nav_table_struct($content["struct"],intval($content["cat_id"]),"$1",$template_default["nav_table_struct"]);';
$content["all"] = preg_replace('/\{NAV_TABLE_COLUMN:(\d+)\}/e', $replace, $content["all"]);
}
"include/inc_front/front.func.inc.php" shows actual build routine for the "
table-based" menu:
Code: Select all
// -------------------------------------------------------------
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;
while ($start_id) {
$data[$start_id] = 1;
$start_id = $struct[$start_id]["acat_struct"];
}
$temp_tree = (sizeof($data)) ? array_reverse($data, 1) : false;
foreach($struct as $key => $value) {
if($struct[$key]["acat_struct"] == $act_cat_id && $key && !$struct[$key]["acat_hidden"]) $c++;
}
$c = (!$c) ? 1 : 0;
//build image src path and real image tag
//$nav_table_struct["linkimage_norm_js"] = get_real_imgsrc($nav_table_struct["linkimage_norm"]);
$nav_table_struct["linkimage_over_js"] = get_real_imgsrc($nav_table_struct["linkimage_over"]);
//$nav_table_struct["linkimage_active_js"] = get_real_imgsrc($nav_table_struct["linkimage_active"]);
$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"], '#');
//get depth of level
$level_depth = 0; $start_level = $level;
while ($start_level) {
$start_level = $struct[$start_level]["acat_struct"];
$level_depth++;
}
$temp_menu = build_levels ($struct, $level, $temp_tree, $act_cat_id, $nav_table_struct, $level_depth, $c, $link_to); //starts at root level
return ($temp_menu) ? ("<table".table_attributes($nav_table_struct, "table", 0).">\n".$temp_menu."</table>") : "";
}
function get_real_imgsrc($img='') {
// strips real src attribute from image tag
if($img) {
$img = preg_replace('/.*src=["|\'](.*?)["|\'].*/i', "$1", $img);
}
return $img;
}
function add_linkid($img='', $linkid='') {
//used to add the link ID for js over functions
$img = preg_replace('/( \/>|>)$/', $linkid."$1", $img);
return $img;
}
// -------------------------------------------------------------
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
$depth = sizeof($temp_tree)-$div; $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"]);
$temp_menu = ""; $js = "";
$colspan = ($depth2 > 1) ? " colspan="".$depth2.""" : "";
foreach($struct as $key => $value) {
if($_SESSION["frontend_user_in"] && $struct[$key]["acat_regonly"]) $struct[$key]["acat_regonly"] = 0;
if($struct[$key]["acat_struct"] == $level && $key && !$struct[$key]["acat_hidden"] && !$struct[$key]["acat_regonly"]) {
$link_image_id = "linkid".randpassword(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 = '';
}
//spacer row
if($nav_table_struct["row_space"]) {
$space_row = "<tr".table_attributes($nav_table_struct, "row_space", 0).">\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($temp_tree[$key]) {
if($act_cat_id == $key) {
$temp_menu .= "<tr".table_attributes($nav_table_struct, "row_active", 0).$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).$colspan.">".$cell_top;
$temp_menu .= '<a href="'.$link.'"'.$redirect['target'].'>'.html_specialchars($struct[$key]["acat_name"]).'</a>';
} else {
$temp_menu .= "<tr".table_attributes($nav_table_struct, "row_norm", 0).$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).$colspan.">".$cell_top;
$temp_menu .= '<a href="'.$link.'"'.$redirect['target'].'>'.html_specialchars($struct[$key]["acat_name"])."</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).$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).$colspan.">".$cell_top;
$temp_menu .= '<a href="'.$link.'"'.$redirect['target'].'>'.html_specialchars($struct[$key]["acat_name"])."</a>";
$temp_menu .= $cell_bottom."</td>\n".$right_cell."</tr>\n";
}
}
}
if($nav_table_struct["row_space"] && $count == 1) $temp_menu .= $space_row;
return $temp_menu;
}