0) {return true;} else {return false;} } //************************************************ //************************************************ function page_is_catalog_owner($page_id) { $is_owner = false; $page_id = intval($page_id); $res_query = mysql_query("SELECT page_id FROM site_pages WHERE page_menu_owner = ".$page_id." AND page_specialization = 'catalog' AND page_visible = 1"); if(mysql_num_rows($res_query) > 0) { $is_owner = true; } @mysql_free_result($res_query); return $is_owner; } //************************************************ //************************************************ function get_page_full_child_arr($page_id,$res_arr=array()) { $res = mysql_query("SELECT page_id FROM site_pages WHERE page_menu_owner = ".intval($page_id)." AND page_visible = 1 AND page_menu_visible = 1 ORDER BY page_num_view ASC"); check_mysql_error(); // from libraries/general.php if(mysql_num_rows($res) > 0) { while ($row = mysql_fetch_row($res)) { if (!pages_is_children($row[0]) || !page_empty($row[0])) { $res_arr[] = $row[0]; } $res_arr += get_page_full_child_arr($row[0], $res_arr); } } return $res_arr; } //************************************************ //************************************************ function get_page_first_full_child($page_id) { $result = $page_id; $res_arr = get_page_full_child_arr($page_id); if(!empty($res_arr)) { $result = $res_arr[0]; } return $result; } //************************************************ //************************************************ function pages_in_this_branch($cur_menu, $menu_id) { while ($cur_menu != 0) { $res_branch = mysql_query("SELECT page_menu_owner FROM site_pages WHERE page_id = '".$cur_menu."'"); check_mysql_error(); // from libraries/general.php $cur_menu = mysql_result($res_branch,0,0); if ($cur_menu == $menu_id) return true; } return false; } //************************************************ //************************************************ function get_pages_root_owner($page_id) { $cur_owner_query = mysql_query("SELECT page_menu_owner FROM site_pages WHERE page_id = '".$page_id."' "); check_mysql_error(); // from libraries/general.php $cur_owner = mysql_result($cur_owner_query,0,0); if ($cur_owner == 0) { return $page_id; } else { $owner_arr = array(); $owner = $page_id; while ($owner != 0) { $z=0; $res_owner = mysql_query("SELECT page_menu_owner FROM site_pages WHERE page_id = '".$owner."'"); check_mysql_error(); // from libraries/general.php $owner = mysql_result($res_owner,0,0); $owner_arr[] = mysql_result($res_owner,0,0); $z++; if ($z > 300) {exit;} } $owner_arr = array_reverse($owner_arr); return $owner_arr[1]; } } //************************************************ //************************************************ function root_pages_menu_items_build($curr_menu_pos,$lang,$tmpl_arr) { $curr_menu_pos = get_pages_root_owner($curr_menu_pos); $returned_string = ""; $res_menu = mysql_query("SELECT * FROM site_pages WHERE page_menu_owner = 0 AND page_visible = 1 AND page_menu_visible = 1 ORDER BY page_num_view"); $menu_array = array(); while ($menu = mysql_fetch_assoc($res_menu)) { $t_menu_it = ""; if ($curr_menu_pos == $menu["page_id"]) //Dannaja pozicija menu { $t_menu_it .= $tmpl_arr["pages_menu_selected_row"]; // selected items } else { $t_menu_it .= $tmpl_arr["pages_menu_row"] ; // unselected items } switch ($menu["page_specialization"]) { case "index": $pages_menu_link = "home/".$lang."/"; break; case "none": $pages_menu_link = "content/".$lang."/".$menu["page_id"]."/".in_url_replase($menu["page_name_".$lang]).".html"; break; case "news": $pages_menu_link = "news/".$lang."/"; break; case "gallery": $pages_menu_link = "gallery/".$lang."/"; break; case "catalog": $pages_menu_link = "catalog/".$lang."/".intval($menu["page_id"])."/page/1/".in_url_replase($menu["page_name_".$lang]).".html"; break; default: $pages_menu_link = "content/".$lang."/".$menu["page_id"]."/".in_url_replase($menu["page_name_".$lang]).".html"; } $t_menu_it = str_replace("%%page_id%%",$menu["page_id"], $t_menu_it); $t_menu_it = str_replace("%%menu_name%%",in_html_replase($menu["page_name_".$lang]), $t_menu_it); $t_menu_it = str_replace("%%menu_link%%",$pages_menu_link, $t_menu_it); $menu_array[] = $t_menu_it; } if(!empty($menu_array) ){$returned_string = implode($tmpl_arr["separator_tmpl"],$menu_array);} return $returned_string; } //************************************************ //************************************************ function pages_root_menu($curr_menu_pos,$lang,$root_pages_menu_tmpl) { $tmpl_arr = array(); $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$root_pages_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$tmpl_arr["pages_menu_row"] = $preg_arr[1][0];} else {$tmpl_arr["pages_menu_row"] ="";} $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$root_pages_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$tmpl_arr["pages_menu_selected_row"] = $preg_arr[1][0];} else {$tmpl_arr["pages_menu_selected_row"] = $tmpl_arr["pages_menu_row"];} $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$root_pages_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$tmpl_arr["separator_tmpl"] = $preg_arr[1][0];} else {$tmpl_arr["separator_tmpl"] = "";} $root_menu_row_string = root_pages_menu_items_build($curr_menu_pos,$lang,$tmpl_arr); if($root_menu_row_string != "") { $root_menu_string = preg_replace("|([\s\S]+?)|i",$root_menu_row_string,$root_pages_menu_tmpl); return $root_menu_string; } else { return ""; } } //************************************************ //************************************************ function pages_submenu_items_build($curr_menu_pos,$curr_menu_owner, $menu_owner,$colaps, $lang, $tmpl_arr,$level = 0,$menu_padding, $site_menu_negative_indent, $level_limit) { $res_menu = mysql_query("SELECT * FROM site_pages WHERE page_menu_owner = '".$menu_owner."' AND page_visible = 1 AND page_menu_visible = 1 ORDER BY page_num_view"); check_mysql_error(); $i = $level; $level_padding = ($level * $menu_padding) - $site_menu_negative_indent; $t_menu_it = ""; while ($menu = mysql_fetch_assoc($res_menu)) { $in_this_branch = pages_in_this_branch($curr_menu_pos, $menu["page_id"]); $is_children = pages_is_children($menu["page_id"]); if ($curr_menu_pos == $menu["page_id"] || $in_this_branch) //Dannaja pozicija menu { $t_menu_it .= $tmpl_arr["submenu_selected_row"]; // selected subitems } else { $t_menu_it .= $tmpl_arr["submenu_row"];// subitems } switch ($menu["page_specialization"]) { case "index": $pages_menu_link = "home/".$lang."/"; break; case "none": $pages_menu_link = "content/".$lang."/".$menu["page_id"]."/".in_url_replase($menu["page_name_".$lang]).".html"; break; case "news": $pages_menu_link = "news/".$lang."/"; break; case "gallery": $pages_menu_link = "gallery/".$lang."/"; break; case "catalog": $pages_menu_link = "catalog/".$lang."/".$menu["page_id"]."/page/1/".in_url_replase($menu["page_name_".$lang]).".html"; break; default: $pages_menu_link = "content/".$lang."/".$menu["page_id"]."/".in_url_replase($menu["page_name_".$lang]).".html"; } $t_menu_it = str_replace("%%menu_name%%",in_html_replase($menu["page_name_".$lang]), $t_menu_it); $t_menu_it = str_replace("%%menu_link%%",$pages_menu_link, $t_menu_it); $t_menu_it = str_replace("%%level%%",$level_padding, $t_menu_it); if (($colaps && $i < $level_limit) or $in_this_branch or $curr_menu_pos == $menu["page_id"]) { $res_menu_child = mysql_query("SELECT page_id FROM site_pages WHERE page_menu_owner = ".$menu["page_id"]." AND page_visible = 1 AND page_menu_visible = 1 ORDER BY page_num_view"); if (mysql_num_rows($res_menu_child) > 0) { $i++; $t_menu_it .= pages_submenu_items_build($curr_menu_pos,$curr_menu_owner, $menu["page_id"],$colaps, $lang, $tmpl_arr, $i,$menu_padding,$site_menu_negative_indent,$level_limit); } $i = $level; } } return $t_menu_it; } //************************************************ //************************************************ function get_pages_submenu($curr_menu_pos,$lang,$colaps,$level_limit,$pages_menu_tmpl) { $menu_padding_query = mysql_query("SELECT menu_padding, site_menu_negative_indent FROM site_administrative_tools" ); check_mysql_error(); $menu_padding = mysql_result($menu_padding_query,0,0); $site_menu_negative_indent = mysql_result($menu_padding_query,0,1); $colaps_query = mysql_query("SELECT shared_menu_colaps, shared_menu_level_limit FROM site_shared_options" ); check_mysql_error(); if(mysql_num_rows($colaps_query) > 0) { switch (mysql_result($colaps_query,0,0)) { case 0: $colaps = false; break; case 1: $colaps = true; break; default: continue; } $level_limit = mysql_result($colaps_query,0,1); } $menu_owner = get_pages_root_owner($curr_menu_pos); $level = 0; if (pages_is_children($menu_owner)) { $tmpl_arr = array(); $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$pages_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$tmpl_arr["menu_row"] = $preg_arr[1][0];} else {$tmpl_arr["menu_row"] = "";} $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$pages_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$tmpl_arr["menu_selected_row"] = $preg_arr[1][0];} else {$tmpl_arr["menu_selected_row"] = $tmpl_arr["menu_row"];} $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$pages_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$tmpl_arr["submenu_row"] = $preg_arr[1][0];} else {$tmpl_arr["submenu_row"] = $tmpl_arr["menu_row"];} $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$pages_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$tmpl_arr["submenu_selected_row"] = $preg_arr[1][0];} else {$tmpl_arr["submenu_selected_row"] = $tmpl_arr["menu_selected_row"];} $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$pages_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$tmpl_arr["submenu_container"] = $preg_arr[1][0];} else {$tmpl_arr["submenu_container"] = "";} $res_menu = mysql_query("SELECT * FROM site_pages WHERE page_menu_owner = '".$menu_owner."' AND page_visible = 1 AND page_menu_visible = 1 ORDER BY page_num_view"); check_mysql_error(); $t_menu_it = ""; while ($menu = mysql_fetch_assoc($res_menu)) { $in_this_branch = pages_in_this_branch($curr_menu_pos, $menu["page_id"]); $is_children = pages_is_children($menu["page_id"]); if ($curr_menu_pos == $menu["page_id"] || $in_this_branch ) //Dannaja pozicija menu { $t_menu_it .= $tmpl_arr["menu_selected_row"]; // selected items } else { $t_menu_it .= $tmpl_arr["menu_row"] ; //items } switch ($menu["page_specialization"]) { case "index": $pages_menu_link = "home/".$lang."/"; break; case "none": $pages_menu_link = "content/".$lang."/".$menu["page_id"]."/".in_url_replase($menu["page_name_".$lang]).".html"; break; case "news": $pages_menu_link = "news/".$lang."/"; break; case "gallery": $pages_menu_link = "gallery/".$lang."/"; break; case "catalog": $pages_menu_link = "catalog/".$lang."/".$menu["page_id"]."/page/1/".in_url_replase($menu["page_name_".$lang]).".html"; break; default: $pages_menu_link = "content/".$lang."/".$menu["page_id"]."/".in_url_replase($menu["page_name_".$lang]).".html"; } $t_menu_it = str_replace("%%menu_name%%",in_html_replase($menu["page_name_".$lang]), $t_menu_it); $t_menu_it = str_replace("%%menu_link%%",$pages_menu_link, $t_menu_it); $t_menu_it = str_replace("%%level%%","0", $t_menu_it); $t_menu_it = str_replace("%%id%%",$menu["page_id"], $t_menu_it); $sumbenu_str = ""; if ($colaps or $in_this_branch or $curr_menu_pos == $menu["page_id"]) { if($is_children) { if($tmpl_arr["submenu_container"] == ""){$level = 1;} else {$level = 0;} $sumbenu_items = pages_submenu_items_build($curr_menu_pos, $menu_owner, $menu["page_id"],$colaps, $lang, $tmpl_arr,$level,$menu_padding,$site_menu_negative_indent,$level_limit); if($tmpl_arr["submenu_container"] != "") { $sumbenu_str = preg_replace("|([\w\W]+?)|i",$sumbenu_items,$tmpl_arr["submenu_container"]); } else { $sumbenu_str = $sumbenu_items; } $sumbenu_str = str_replace("%%id%%",$menu["page_id"], $sumbenu_str); } } $t_menu_it .= $sumbenu_str; } $verical_menu_string = preg_replace("|([\w\W]+?)|i",$t_menu_it,$pages_menu_tmpl); return $verical_menu_string; } else { return ""; } } //************************************************ //************************************************ function pages_flat_menu_builder($curr_menu_pos, $lang,$flat_menu_tmpl) { $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$flat_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$flat_menu_item_tmpl = $preg_arr[1][0];} else {$flat_menu_item_tmpl = "";} $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$flat_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$flat_menu_selected_item_tmpl = $preg_arr[1][0];} else {$flat_menu_selected_item_tmpl = $flat_menu_item_tmpl;} $preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$flat_menu_tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$flat_menu_separator_tmpl = $preg_arr[1][0];} else {$flat_menu_separator_tmpl = "->";} $owner_arr = array(); $owner = $curr_menu_pos; while ($owner != 0) { $z=0; //$res_owner = mysql_query("SELECT page_menu_owner, page_name_".$lang.", page_id, page_specialization FROM site_pages WHERE page_id = '".$owner."' AND page_visible = 1 AND page_menu_visible = 1 "); check_mysql_error(); $res_owner = mysql_query("SELECT page_menu_owner, page_name_".$lang.", page_id, page_specialization FROM site_pages WHERE page_id = '".$owner."' AND page_visible = 1"); check_mysql_error(); $result = mysql_fetch_assoc($res_owner); switch ($result["page_specialization"]) { case "index": $flat_menu_link = "home/".$lang."/"; break; case "none": $flat_menu_link = "content/".$lang."/".$result["page_id"]."/".in_url_replase($result["page_name_".$lang]).".html"; break; case "news": $flat_menu_link = "news/".$lang."/"; break; case "gallery": $flat_menu_link = "gallery/".$lang."/"; break; case "catalog": $flat_menu_link = "catalog/".$lang."/".$result["page_id"]."/page/1/".in_url_replase($result["page_name_".$lang]).".html"; break; break; default: $flat_menu_link = "content/".$lang."/".$result["page_id"]."/".in_url_replase($result["page_name_".$lang]).".html"; } $owner = $result["page_menu_owner"]; if ($curr_menu_pos == $result["page_id"]) { $item = $flat_menu_selected_item_tmpl; } else { $item = $flat_menu_item_tmpl; } $item = str_replace("%%menu_link%%",$flat_menu_link, $item); $item = str_replace("%%menu_name%%",in_html_replase($result["page_name_".$lang]), $item); $owner_arr[] = $item; //print_r($owner_arr); exit; $z++; if ($z > 1000) {exit;} } $owner_arr = array_reverse($owner_arr); $flat_menu_string = implode($flat_menu_separator_tmpl,$owner_arr); $returned_string = preg_replace("|([\w\W]+?)|i",$flat_menu_string,$flat_menu_tmpl); return $returned_string; } //************************************************ //************************************************ function get_one_page_submenu($page_id,$lang,$tmpl) { $preg_arr = array(); $row_tmpl = ""; preg_match_all("|([\w\W]+?)|i",$tmpl,$preg_arr); if(isset($preg_arr[1][0]) && !empty($preg_arr[1][0])){$row_tmpl = $preg_arr[1][0];} $row_array = array(); $output_string = ""; if (!empty($page_id)) { $query2 = mysql_query("SELECT * FROM site_pages WHERE page_menu_owner = '".$page_id."' AND page_visible = 1 AND page_menu_visible = 1 ORDER BY page_num_view ASC"); if(mysql_num_rows($query2) > 0) { while ($pages = mysql_fetch_assoc($query2)) { switch ($pages["page_specialization"]) { case "index": $pages_menu_link = "home/".$lang."/"; break; case "none": $pages_menu_link = "content/".$lang."/".$pages["page_id"]."/".in_url_replase($pages["page_name_".$lang]).".html"; break; case "news": $pages_menu_link = "news/".$lang."/"; break; case "gallery": $pages_menu_link = "gallery/".$lang."/"; break; case "catalog": $pages_menu_link = "catalog/".$lang."/".$pages["page_id"]."/page/1/".in_url_replase($pages["page_name_".$lang]).".html"; break; default: $pages_menu_link = "content/".$lang."/".$pages["page_id"]."/".in_url_replase($pages["page_name_".$lang]).".html"; } $row_str = $row_tmpl; $row_str = str_replace("%%menu_link%%",$pages_menu_link, $row_str); $row_str = str_replace("%%menu_name%%",in_html_replase($pages["page_name_".$lang]), $row_str); $row_array[] = $row_str; } if(!empty($row_array)){$row_output_string = implode("\n",$row_array);} } } if ($row_output_string != "") { $output_string = preg_replace("|([\w\W]+?)|i",$row_output_string,$tmpl); } return $output_string; } //************************************************ //************************************************ ?>template = $template; $this->lang = $lang; $this->menu_padding = 12; $this->site_menu_negative_indent = 0; $this->colaps = true; $this->tmpl_arr = array(); $this->preg_arr = array(); $this->shared_menu_items_arr = array(); $menu_padding_query = mysql_query("SELECT menu_padding, site_menu_negative_indent FROM site_administrative_tools" ); if(mysql_num_rows($menu_padding_query) > 0) { $this->menu_padding = mysql_result($menu_padding_query,0,0); $this->site_menu_negative_indent = mysql_result($menu_padding_query,0,1); } $colaps_query = mysql_query("SELECT shared_menu_colaps, shared_menu_level_limit FROM site_shared_options" ); if(mysql_num_rows($colaps_query) > 0) { switch (mysql_result($colaps_query,0,0)) { case 0: $this->colaps = false; break; case 1: $this->colaps = true; break; default: continue; ; } $this->level_limit = mysql_result($colaps_query,0,1); } $this->cur_page_id = 0; if(isset($page_id)){$this->cur_page_id = $page_id;} $this->cur_gallery_category_id = 0; if(isset($gallery_category_id)){$this->cur_gallery_category_id = $gallery_category_id;} $this->gallery_root_id = 0; $gallery_root_id_query = mysql_query("SELECT gallery_category_id FROM site_gallery_categories WHERE gallery_category_menu_owner = '0' AND gallery_category_visible = '1' ORDER BY gallery_category_id LIMIT 1"); check_mysql_error(); // from libraries/general.php if (mysql_num_rows($gallery_root_id_query) > 0){$this->gallery_root_id = mysql_result($gallery_root_id_query,0,0);} $this->tmpl_arr = array(); //########### $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["menu_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["menu_row"] = "";} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["menu_selected_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["menu_selected_row"] = $this->tmpl_arr["menu_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["menu_owner_open_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["menu_owner_open_row"] = $this->tmpl_arr["menu_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["menu_owner_closed_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["menu_owner_closed_row"] = $this->tmpl_arr["menu_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["menu_selected_owner_open_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["menu_selected_owner_open_row"] = $this->tmpl_arr["menu_selected_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["submenu_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["submenu_row"] = $this->tmpl_arr["menu_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["submenu_selected_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["submenu_selected_row"] = $this->tmpl_arr["submenu_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["submenu_owner_open_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["submenu_owner_open_row"] = $this->tmpl_arr["submenu_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["submenu_owner_closed_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["submenu_owner_closed_row"] = $this->tmpl_arr["submenu_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["submenu_selected_owner_open_row"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["submenu_selected_owner_open_row"] = $this->tmpl_arr["submenu_selected_row"];} $this->preg_arr = array(); preg_match_all("|([\w\W]+?)|i",$this->template,$this->preg_arr); if(isset($this->preg_arr[1][0]) && !empty($this->preg_arr[1][0])){$this->tmpl_arr["separator"] = $this->preg_arr[1][0];} else {$this->tmpl_arr["separator"] = "";} //print_r($this->tmpl_arr);exit; } //######################################################################################### //######################################################################################### //######################################################################################### //######################################################################################### //######################################################################################### //########## GALLERY ######################################################################### //######################################################################################### //************************************************************************************************************************************* private function gallery_is_children($menu_id) { $res_menu_parent = mysql_query("SELECT COUNT(gallery_category_id) FROM site_gallery_categories WHERE gallery_category_menu_owner = '".$menu_id."' AND gallery_category_visible = '1'"); check_mysql_error(); // from libraries/general.php if (mysql_result($res_menu_parent,0,0) > 0) {return true;} else {return false;} } //************************************************************************************************************************************* //************************************************************************************************************************************* //************************************************************************************************************************************* private function gallery_in_this_branch($cur_menu, $menu_id) { while ($cur_menu != 0) { $res_branch = mysql_query("SELECT gallery_category_menu_owner FROM site_gallery_categories WHERE gallery_category_id = '".$cur_menu."'"); check_mysql_error(); // from libraries/general.php $cur_menu = mysql_result($res_branch,0,0); if ($cur_menu == $menu_id) return true; } return false; } //************************************************************************************************************************************* //************************************************************************************************************************************* private function galley_menu_items_delay($menu_owner = 0, $level) { //********************************************** $res_menu = mysql_query("SELECT * FROM site_gallery_categories WHERE gallery_category_menu_owner = '".$menu_owner."' AND gallery_category_visible = '1' ORDER BY gallery_category_num_view"); check_mysql_error(); // from libraries/general.php // Glubina pozicii menu $i = $level; $level_padding = ($level * $this->menu_padding) - $this->site_menu_negative_indent; while ($menu = mysql_fetch_assoc($res_menu)) { $t_menu_it = ""; $in_this_branch = $this->gallery_in_this_branch($this->cur_gallery_category_id, $menu["gallery_category_id"]); $is_children = $this->gallery_is_children($menu["gallery_category_id"]); if ($this->cur_gallery_category_id == $menu["gallery_category_id"] or $in_this_branch) //Dannaja pozicija menu { if ($menu_owner == 0) { if ($is_children) {$t_menu_it = $this->tmpl_arr["menu_selected_owner_open_row"];} else {$t_menu_it = $this->tmpl_arr["menu_selected_row"];} } else { if ($is_children) {$t_menu_it = $this->tmpl_arr["submenu_selected_owner_open_row"];} else {$t_menu_it = $this->tmpl_arr["submenu_selected_row"];} } } else { if ($menu_owner == 0) { if ($is_children) { if ($this->colaps) { $t_menu_it = $this->tmpl_arr["menu_owner_open_row"]; } else { $t_menu_it = $this->tmpl_arr["menu_owner_closed_row"]; } } else {$t_menu_it = $this->tmpl_arr["menu_row"];} } else { if ($is_children) { if ($this->colaps) { $t_menu_it = $this->tmpl_arr["submenu_owner_closed_row"]; } else { $t_menu_it = $this->tmpl_arr["submenu_owner_open_row"]; } } else {$t_menu_it = $this->tmpl_arr["submenu_row"];} } } $menu_link = "gallery/".$this->lang."/".$menu["gallery_category_id"]."/page/1/".in_url_replase($menu["gallery_category_name_".$this->lang]).".html"; $t_menu_it = str_replace("%%menu_name%%",in_html_replase($menu["gallery_category_name_".$this->lang]), $t_menu_it); $t_menu_it = str_replace("%%menu_link%%",$menu_link, $t_menu_it); $t_menu_it = str_replace("%%level%%",$level_padding, $t_menu_it); $this->shared_menu_items_arr[] = $t_menu_it; if (($this->colaps && $i < $this->level_limit) || $in_this_branch || $this->cur_gallery_category_id == $menu["gallery_category_id"]) { $res_menu_child = mysql_query("SELECT gallery_category_id FROM site_gallery_categories WHERE gallery_category_menu_owner = ".$menu["gallery_category_id"]." AND gallery_category_visible = '1' ORDER BY gallery_category_num_view"); if (mysql_num_rows($res_menu_child) > 0) { $i++; $this->galley_menu_items_delay($menu["gallery_category_id"],$i); } $i = $level; } } } //######################################################################################### //######################################################################################### //######################################################################################### //######################################################################################### //######### SHARED ######################################################################### //######################################################################################### private function pages_is_children($menu_id) { $res_menu_parent = mysql_query("SELECT page_id FROM site_pages WHERE page_menu_owner = '".$menu_id."' AND page_visible = 1 AND page_menu_visible = 1"); if (mysql_num_rows($res_menu_parent) > 0) {return true;} else {return false;} } //************************************************************************************************************************************* private function in_this_pages_branch($cur_menu, $menu_id) { while ($cur_menu != 0) { $res_branch = mysql_query("SELECT page_menu_owner FROM site_pages WHERE page_id = '".$cur_menu."'"); check_mysql_error(); // from libraries/general.php $cur_menu = mysql_result($res_branch,0,0); if ($cur_menu == $menu_id) return true; } return false; } //************************************************************************************************************************************* function get_shared_menu_items_arr($page_menu_owner = 0, $level = 0) { $res_menu = mysql_query("SELECT * FROM site_pages WHERE page_menu_owner = ".$page_menu_owner." AND page_visible = 1 AND page_menu_visible = 1 ORDER BY page_num_view");check_mysql_error(); //from libraries/general.php $i = $level; $level_padding = ($level * $this->menu_padding) - $this->site_menu_negative_indent; while ($menu = mysql_fetch_assoc($res_menu)) { $t_menu_it = ""; $page_specialization = $menu["page_specialization"]; switch ($page_specialization) { // CASE INDEX BEGIN case "index": if ($this->cur_page_id == $menu["page_id"]) {$t_menu_it = $this->tmpl_arr["menu_selected_row"];} else {$t_menu_it = $this->tmpl_arr["menu_row"] ;} $pages_menu_link = "home/".$this->lang."/"; break; // CASE INDEX END // // CASE NONE BEGIN case "none": case "catalog": $in_this_branch = $this->in_this_pages_branch($this->cur_page_id, $menu["page_id"]); $is_children = $this->pages_is_children($menu["page_id"]); if ($this->cur_page_id == $menu["page_id"] or $in_this_branch) { if ($page_menu_owner == 0) { if ($is_children) {$t_menu_it = $this->tmpl_arr["menu_selected_owner_open_row"];} else {$t_menu_it = $this->tmpl_arr["menu_selected_row"];} } else { if ($is_children) {$t_menu_it = $this->tmpl_arr["submenu_selected_owner_open_row"];} else {$t_menu_it = $this->tmpl_arr["submenu_selected_row"];} } } else { if ($page_menu_owner == 0) { if ($is_children) { if ($this->colaps) { $t_menu_it = $this->tmpl_arr["menu_owner_open_row"]; } else { $t_menu_it = $this->tmpl_arr["menu_owner_closed_row"]; } } else {$t_menu_it = $this->tmpl_arr["menu_row"];} } else { if ($is_children) { if ($this->colaps) { $t_menu_it = $this->tmpl_arr["submenu_owner_open_row"]; } else { $t_menu_it = $this->tmpl_arr["submenu_owner_closed_row"]; } } else {$t_menu_it = $this->tmpl_arr["submenu_row"];} } } $pages_menu_link = "content/".$this->lang."/".$menu["page_id"]."/".in_url_replase($menu["page_name_".$this->lang]).".html"; if($page_specialization == "catalog") { $pages_menu_link = "catalog/".$this->lang."/".$menu["page_id"]."/page/1/".in_url_replase($menu["page_name_".$this->lang]).".html"; } break; // CASE NONE END // // CASE site_news BEGIN case "news": $in_this_branch = $this->in_this_pages_branch($this->cur_page_id, $menu["page_id"]); $is_children = $this->pages_is_children($menu["page_id"]); if ($this->cur_page_id == $menu["page_id"] or $in_this_branch) { if ($page_menu_owner == 0) { if ($is_children) {$t_menu_it = $this->tmpl_arr["menu_selected_owner_open_row"];} else {$t_menu_it = $this->tmpl_arr["menu_selected_row"];} } else { if ($is_children) {$t_menu_it = $this->tmpl_arr["submenu_selected_owner_open_row"];} else {$t_menu_it = $this->tmpl_arr["submenu_selected_row"];} } } else { if ($page_menu_owner == 0) { if ($is_children) {$t_menu_it = $this->tmpl_arr["menu_owner_closed_row"]; } else {$t_menu_it = $this->tmpl_arr["menu_row"];} } else { if ($is_children) {$t_menu_it = $this->tmpl_arr["submenu_owner_closed_row"];} else {$t_menu_it = $this->tmpl_arr["submenu_row"];} } } $pages_menu_link = "news/".$this->lang."/"; break; // CASE site_news END // // CASE GALLERY BEGIN case "gallery": $this->galley_menu_items_delay(0,0); break; // CASE GALLERY END break; // CASE CATALOG END // // DEFAULT START [contacts] default : $in_this_branch = $this->in_this_pages_branch($this->cur_page_id, $menu["page_id"]); $is_children = $this->pages_is_children($menu["page_id"]); if ($this->cur_page_id == $menu["page_id"] or $in_this_branch) { if ($page_menu_owner == 0) { if ($is_children) {$t_menu_it = $this->tmpl_arr["menu_selected_owner_open_row"];} else {$t_menu_it = $this->tmpl_arr["menu_selected_row"];} } else { if ($is_children) {$t_menu_it = $this->tmpl_arr["submenu_selected_owner_open_row"];} else {$t_menu_it = $this->tmpl_arr["submenu_selected_row"];} } } else { if ($page_menu_owner == 0) { if ($is_children) {$t_menu_it = $this->tmpl_arr["menu_owner_closed_row"]; } else {$t_menu_it = $this->tmpl_arr["menu_row"];} } else { if ($is_children) {$t_menu_it = $this->tmpl_arr["submenu_owner_closed_row"];} else {$t_menu_it = $this->tmpl_arr["submenu_row"];} } } $pages_menu_link = "content/".$this->lang."/".$menu["page_id"]."/".in_url_replase($menu["page_name_".$this->lang]).".html"; break; // DEFAULT END } $t_menu_it = str_replace("%%menu_name%%",in_html_replase($menu["page_name_".$this->lang]), $t_menu_it); $t_menu_it = str_replace("%%menu_link%%",$pages_menu_link, $t_menu_it); $t_menu_it = str_replace("%%level%%",$level_padding, $t_menu_it); $t_menu_it = str_replace("%%shared_menu_page_id%%",$menu["page_id"], $t_menu_it); $this->shared_menu_items_arr[] = $t_menu_it; if (($this->colaps && $i < $this->level_limit) || $in_this_branch || $this->cur_page_id == $menu["page_id"]) { $res_menu_child = mysql_query("SELECT page_id FROM site_pages WHERE page_menu_owner = ".$menu["page_id"]." AND page_visible = 1 AND page_menu_visible = 1 ORDER BY page_num_view");check_mysql_error(); //from libraries/general.php if (mysql_num_rows($res_menu_child)) { $i++; $this->get_shared_menu_items_arr( $menu["page_id"], $i); } $i = $level; } } //print_r($this->shared_menu_items_arr); exit; return $this->shared_menu_items_arr; } //************************************************************************************************************************************* public function get_shared_menu() { $string = implode($this->tmpl_arr["separator"],$this->get_shared_menu_items_arr()); $menu_string = preg_replace("|([\w\W]+?)|i",$string,$this->template); return $menu_string; } //************************************************************************************************************************************* //######################################################################################### //######################################################################################### //######################################################################################### //######################################################################################### //######################################################################################### //######################################################################################### //######################################################################################### } ?>