dbh = $db_link; // including verify $include = DIR_FUNCTIONS . 'verify.php'; include(INCLUDER); // ------------------------------------------------------------------------ // -- ustal GET['id'] // ------------------------------------------------------------------------ if (!$_SESSION['category_id']) $_SESSION['category_id'] = NO_INDEX+1; if ($_GET['id']) $_SESSION['category_id'] = $_GET['id']; $_GET['id'] = $_SESSION['category_id']; // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ // -- buduj drzewo // ------------------------------------------------------------------------ $db_result = db_query("select * from sites_". LANG ." order by sites_next"); while ($result = db_fetch_array($db_result, MYSQL_ASSOC)) { if (isset($_GET['id']) && ($_GET['id']==$result['sites_id'])) { $id = $result['sites_id']; $title = $result['sites_title']; $subtitle = $result['sites_subtitle']; $content = $result['sites_content']; $parent_id = $result['sites_parent_id']; $link = $result['sites_link']; $link_inc = $result['sites_link']; $linkout = $result['sites_linkout']; if (GALLERY==1) { $gallery_id = $result['sites_gallery_id']; } $meta = $result['sites_meta']; $meta_title = $result['sites_meta_title']; $meta_description = $result['sites_meta_description']; $meta_keywords = $result['sites_meta_keywords']; define('SUBTITLE', $subtitle); } $date_sites[] = $result['sites_date']; $all_parents[] = $result['sites_parent_id']; $items[$result['sites_id']] = $result; $tree[$result['sites_parent_id']] [] = &$items[$result['sites_id']]; if ($result['sites_inmenu']==1 ) { $xitems[$result['sites_id']] = $result; $xtree[$result['sites_parent_id']] [] = &$xitems[$result['sites_id']]; } } // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ // catalog if (CATALOG==1) { //$db_result = db_query('SELECT * FROM categories_'.LANG.' ORDER BY pc_id ASC, `order` ASC'); $db_result = db_query('SELECT * FROM categories_pl WHERE `visible`=1 ORDER BY pc_id ASC, `order` ASC'); while ($result = db_fetch_array($db_result)) { if (isset($_GET['cid']) && ($_GET['cid']==$result['c_id'])) { $xcat_id = $result['c_id']; $xcat_parent_id = $result['pc_id']; $xcat_visible = $result['visible']; $xcat_name = $result['name']; define('CAT_NAME', $xcat_name); } $xcat_all_parents[] = $result['pc_id']; if ($result['visible']==1) { $xcat_items[$result['c_id']] = $result; } $xcat_tree[$result['pc_id']] [] = &$xcat_items[$result['c_id']]; unset($result); } } // ------------------------------------------------------------------------ // -- ustal MOD (ostatnia modyfikacja) // ------------------------------------------------------------------------ /* $db_result = db_query("select * from news_". LANG); while ($result = db_fetch_array($db_result, MYSQL_ASSOC)) { $date_news[] = $result['news_date']; } unset($result); $dates = array_merge($date_sites, $date_news); unset($date_sites); unset($date_sites); asort($dates); end($dates); define('MOD', current($dates)); unset($dates); */ // ------------------------------------------------------------------------ /* parenty * =======================================================================*/ function showPath($itemt, $indeks) { $tmp = db_query('SELECT `'.$itemt.'` FROM `sites_'.$_GET['l'].'` WHERE `sites_id` = '.$indeks); $showpath = mysql_fetch_array($tmp); $showpath = $showpath[0]; return $showpath; } // function showPath function parents() { //if ($_GET['id'] != "2" ) { //if (showPath('sites_inmenu', $_GET['id']) != 0) { $child = $_GET['id']; while ($child !=1) { $parent = showPath('sites_parent_id', $child); $id_link = showPath('sites_id', $child); $path_array[] = $id_link; $child = $parent; } return $path_array; //} //} } $parents_bread = parents(); $last_id = count($parents_bread) -1; $parentid = ($parents_bread[1] != '') ? $parents_bread[1] : false; $grandParentid = ($parentid) ? $parents_bread[$last_id] : false; // ------------------------------------------------------------------------ // -- buduj tablice parentow kliknietego itema (parentow $_GET['id']) // ------------------------------------------------------------------------ $sel_id = $_GET['id']; if(NAV_HORIZONTAL) $parents = $all_parents; else $parents = array(0); while($sel_id) { $parents[] = $sel_id; $sel_id = $items[$sel_id]['sites_parent_id']; } // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ // cat if (CATALOG==1) { $xcat_sel_id = $_GET['cid']; if(NAV_HORIZONTAL) $xcat_parents = $xcat_all_parents; else $xcat_parents = array(0,1); while($xcat_sel_id) { $xcat_parents[] = $xcat_sel_id; $xcat_sel_id = $xcat_items[$xcat_sel_id]['pc_id']; } } // ------------------------------------------------------------------------ /*function print_tab($tab) { if (!is_array($tab)) echo gettype($tab); else foreach($tab as $value) echo $value.', '; echo '
'; }*/ // ------------------------------------------------------------------------ function print_tree($parent_id, &$parent_node, $level=0){ global $tree, $items, $parents; if (!in_array($parent_id, $parents)) return false; if (is_array($tree[$parent_id])) { foreach ($tree[$parent_id] as $item){ $node = print_item($item, $parent_node, $level); print_tree($item['sites_id'], $node, $level+1); } } } // ------------------------------------------------------------------------ function print_item(&$item, &$parent_node, $level=0) { global $tree, $treec; $class = ($item['sites_id'] == $_GET['id'])?"class='act_menu'":"class='menu'"; $lang = (LANG==F_LANG)?"":"&l=".LANG; if ($item['sites_inmenu']!='0') { if ($item['sites_linkout']!='0') { $linkto = $item['sites_link']; $targetto = '_blank'; } else { $url = eregi("http://([a-zA-Z0-9_-])", $item['sites_link']); if ($url) { $linkto = $item['sites_link']; } else { $linkto = HTTP_WWW.'/'.MAIN.'?id='. $item['sites_id']; } $targetto = '_self'; } $exists_subitems = (is_array($tree[$item['sites_id']])); if ($exists_subitems) { if ($item['sites_id'] == '1') { echo "". $item['sites_title'] ."

"; } else { if ($item['sites_parent_id'] != '1') { $level=(NO_INDEX)?$level:$level-1; echo "". $item['sites_title'] ."

"; } else { echo "". $item['sites_title'] ."

"; } } } else { if ($item['sites_parent_id'] != '1') { $level=(NO_INDEX)?$level:$level-1; echo "". $item['sites_title'] ."

"; } else { echo "". $item['sites_title'] ."

"; } } } } // ------------------------------------------------------------------------ // nowe menu // ------------------------------------------------------------------------ function print_tree_m($parent_id, &$parent_node, $level=0, $unlinks = array()){ global $tree, $items, $parents; if (!in_array($parent_id, $parents)) return false; if (is_array($tree[$parent_id])) { //echo ($parent_id==1)?''."\n"; echo ($level==0)?''."\n":''."\n"; } } function print_catalog_tree($parent_id, &$parent_node, $level=1){ global $xcat_tree, $xcat_items, $xcat_parents; if (!in_array($parent_id, $xcat_parents)) return false; if (is_array($xcat_tree[$parent_id])) { //echo ($parent_id==1)?"\n".''."\n"; echo ($level==1)?''."\n":''."\n"; } } function print_item_m(&$item, &$parent_node, $level=0, $unlinks = array()) { global $tree, $treec,$parents,$parents_bread; if ($item['sites_id'] == $_GET['id']) { $class = "class='level-".$level." current'"; $classlink = "class='level-".$level."-link current-link'"; $classParent = "class='level-".$level." parent current'"; $classParentCat = "class='level-".$level." parent catalog current'"; } else if(in_array($item['sites_id'], $parents_bread)) { $classParent = "class='level-".$level." parent current-parent'"; $classParentCat = "class='level-".$level." parent current-parent catalog'"; } else { $class = "class='level-".$level."'"; $classlink = "class='level-".$level."-link'"; $classParent = "class='level-".$level." parent'"; $classParentCat = "class='level-".$level." parent catalog'"; } //$lang = (LANG==F_LANG)?"":"&l=".LANG; if ($item['sites_inmenu']!='0') { if ($item['sites_linkout']!='0') { $flink = $item['sites_link']; $targetto = 'onclick="this.target=\'_blank\'"'; } else { $url = eregi("http://([a-zA-Z0-9_-])|javascript", $item['sites_link']); if ($url) { //$linkto = $item['sites_link']; $flink = $item['sites_link']; } else { //$linkto = HTTP_WWW.'/'.MAIN.'?id='. $item['sites_id']; //link bez polskich znaków, spacji itp $linkname = char_replace($item['sites_title']); $flink = $linkname.','.$item['sites_id'].','.LANG.'.html'; } $targetto = ''; } $exists_subitems = (is_array($tree[$item['sites_id']])); // unlinks - te ktore maja byc nieklikalne $link = (!in_array($item['sites_id'], $unlinks))?''. $item['sites_title'] .'':''.$item['sites_title'].''; if ($exists_subitems) { if ($item['sites_id']==CATALOGID) { echo "
  • ".$link.""."\n"; print_catalog_tree(1, $xcat_tree); }else { echo "
  • ".$link.""."\n"; } echo (in_array($item['sites_id'],$parents))?'