|
From: Jon O. <jon...@us...> - 2007-07-21 23:09:17
|
Update of /cvsroot/mxbb/core/modules/mx_navmenu/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25812/includes Modified Files: navmenu_functions.php Log Message: Index: navmenu_functions.php =================================================================== RCS file: /cvsroot/mxbb/core/modules/mx_navmenu/includes/navmenu_functions.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** navmenu_functions.php 5 May 2007 20:14:43 -0000 1.6 --- navmenu_functions.php 21 Jul 2007 23:09:03 -0000 1.7 *************** *** 201,203 **** --- 201,449 ---- return ( array('pagemapping' => $pageMapping, 'navcategory' => $navCategory) ); } + + /** + * Enter description here... + * + * @access public + * @param unknown_type $block_id + * @return unknown + */ + function mx_get_site_menu($block_id) + { + global $db; + + $sql = "SELECT * + FROM " . MENU_CAT_TABLE . " cat, + " . MENU_NAV_TABLE . " nav + WHERE cat.block_id = '" . $block_id . "' + AND cat.cat_id = nav.cat_id + ORDER BY cat.cat_order, nav.menu_order"; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt query Navigation Menu', '', __LINE__, __FILE__, $sql ); + } + + $mx_nav_data = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + $num_of_menus = count($mx_nav_data); + + // + // Generate Page to Menu Cat mapping + // + $cat_id = 0; + $num_of_cats = 0; + $navCategory = array(); + $pageMapping = array(); + for( $menu_count = 0; $menu_count < $num_of_menus; $menu_count++ ) + { + // + // New category + // + if ( $cat_id != $mx_nav_data[$menu_count]['cat_id'] ) + { + if ($mx_nav_data[$menu_count]['cat_url'] != '0' && !isset($pageMapping[$mx_nav_data[$menu_count]['cat_url']])) + { + $pageMapping[$mx_nav_data[$menu_count]['cat_url']] = $mx_nav_data[$menu_count]['cat_id']; + } + } + + $cat_id = $mx_nav_data[$menu_count]['cat_id']; + + // + // Menu Maps + // + if ($mx_nav_data[$menu_count]['page_id'] != '0' && !isset($pageMapping[$mx_nav_data[$menu_count]['page_id']])) + { + $pageMapping[$mx_nav_data[$menu_count]['page_id']] = $mx_nav_data[$menu_count]['cat_id']; + } + + // + // Group categories + // + $navCategory[$mx_nav_data[$menu_count]['cat_id']][] = $mx_nav_data[$menu_count]; + } + + unset($mx_nav_data); + + return ( array('pagemapping' => $pageMapping, 'navcategory' => $navCategory) ); + } + + /** + * Enter description here... + * + * @param unknown_type $cat_parent + * @param unknown_type $depth + */ + function generate_site_menu( $page_parent = 0, $depth = 0, $current_parent_page = false ) + { + global $mx_page, $template, $phpEx, $images, $block_id, $mx_root_path; + + if ( isset( $mx_page->subpage_rowset[$page_parent] ) ) + { + foreach( $mx_page->subpage_rowset[$page_parent] as $subpage_id => $page_data ) + { + // Auth check + $_auth_ary = $mx_page->auth($page_data['auth_view'], $page_data['auth_view_group'], $page_data['auth_moderator_group']); + if ($_auth_ary['auth_view'] && $page_data['menu_active']) + { + if ( $depth == 0 ) + { + $cat = $page_data['page_name']; + + // + // Is this category a custom link? If not, link to first menu page. + // + $cat_target = ( true ) ? '' : '_blank'; + $cat_url_tmp = mx_append_sid(PORTAL_URL . 'index.php?page=' . $page_data['page_id'] . '&cat_link=' . $page_data['page_id']); + $catt = ( true ) ? '<a class="nav" href="' . $cat_url_tmp . '" target="' . $cat_target . '" /><span class="nav">' . $cat . '</span></a>' : '<span class="nav">' . $cat . '</span>'; + $cat_url = ( true ) ? $cat_url_tmp : 'javascript:void(0)'; + + // + // Get menu icon + // + if (true) + { + $icon_tmp = ( file_exists($mx_root_path . $images['mx_graphics']['menu_icons'] . '/' . $page_data['menu_icon']) ? $page_data['menu_icon'] : 'icon_blank.gif' ); + $icon_url_hot = str_replace('.gif', '_hot.gif', $icon_tmp); + + if ( file_exists($mx_root_path . $images['mx_graphics']['menu_icons'] . '/' . $icon_url_hot) ) + { + $icon_url = ( $page_data['is_current'] ) ? $icon_url_hot : $icon_tmp; + $icon_style = ( $page_data['is_current'] ) ? 'mx_icon_hot' : 'mx_icon'; + } + else + { + $icon_url = $icon_tmp; + $icon_style = ''; + } + + $menu_icon = ( !empty($page_data['menu_icon']) && $page_data['menu_icon'] != 'none' ) ? '<img class="'.$icon_style.'" border="0" align="absmiddle" src="' . PORTAL_URL . $images['mx_graphics']['menu_icons'] . '/' . $icon_url . '" alt="' . $desc . '" /> ' : ''; + } + else + { + $icon_url = ( $is_current ) ? (!empty($page_data['menu_alt_icon_hot']) ? $page_data['menu_alt_icon_hot'] : $page_data['menu_alt_icon']) : $page_data['menu_alt_icon']; + $menu_icon = '<img border="0" align="absmiddle" src="' . $icon_url . '" alt="' . $desc . '" /> '; + } + + // + // For overall_header navigation + // - is this current page category? + $current_parent_page = ($mx_page->page_id == $page_data['page_id'] || has_active_subpage($subpage_id) || ( isset($_GET['cat_link']) ? intval($_GET['cat_link']) == $page_data['page_id'] : false) ) ? true : false; + + // + // Update cookie - if this was a cat link + // + if ( (isset($_GET['cat_link']) ? intval($_GET['cat_link']) == $page_data['page_id'] : false) || $current_parent_page) + { + setcookie('mxNavCat_' . intval($block_id) . intval($page_data['page_id']), true, (time()+21600), $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + $HTTP_COOKIE_VARS['mxNavCat_' . $block_id . $page_data['page_id']] = 1; + } + + // + // Generate the fold/unfold categories switches + // + $cat_on = $current_parent_page ? true : ( isset($HTTP_COOKIE_VARS['mxNavCat_' . $block_id . $page_data['page_id']]) ? $HTTP_COOKIE_VARS['mxNavCat_' . $block_id . $page_data['page_id']] == 1 : $catData[0]['cat_show'] == 1 ); + + $template->assign_block_vars('catrow', array( + 'CAT_ID' => intval($page_data['page_id']), + 'BLOCK_ID' => intval($block_id), + 'CATEGORY' => $catt, + 'CATEGORY_URL' => $cat_url, + 'CATEGORY_NAME' => $cat, + 'U_CAT_NAV_CONTRACT' => $images['mx_contract'], + 'U_CAT_NAV_EXPAND' => $images['mx_expand'], + 'U_CAT_NAV_DYNAMIC' => $cat_on ? $images['mx_contract'] : $images['mx_expand'], + 'CAT_SHOW' => $cat_on ? '' : 'none', + 'U_MENU_ICON' => $menu_icon, + 'CURRENT' => $current_parent_page ? '-current' : '' + )); + + generate_site_menu( $subpage_id, $depth + 1, $current_parent_page ); + } + else + { + $is_current = $mx_page->page_id == $page_data['page_id']; + $action = $page_data['page_name']; + $action = ( !empty($lang[$action]) ? $lang[$action] : $action ); + $style = $is_current ? 'cattitle' : 'genmed'; + + // + // Get menu icon + // + if (true) + { + $icon_tmp = ( file_exists($mx_root_path . $images['mx_graphics']['menu_icons'] . '/' . $page_data['menu_icon']) ? $page_data['menu_icon'] : 'icon_blank.gif' ); + $icon_url_hot = str_replace('.gif', '_hot.gif', $icon_tmp); + + if ( file_exists($mx_root_path . $images['mx_graphics']['menu_icons'] . '/' . $icon_url_hot) ) + { + $icon_url = ( $page_data['is_current'] ) ? $icon_url_hot : $icon_tmp; + $icon_style = ( $page_data['is_current'] ) ? 'mx_icon_hot' : 'mx_icon'; + } + else + { + $icon_url = $icon_tmp; + $icon_style = ''; + } + + $menu_icon = ( !empty($page_data['menu_icon']) && $page_data['menu_icon'] != 'none' ) ? '<img class="'.$icon_style.'" border="0" align="absmiddle" src="' . PORTAL_URL . $images['mx_graphics']['menu_icons'] . '/' . $icon_url . '" alt="' . $desc . '" /> ' : ''; + } + else + { + $icon_url = ( $is_current ) ? (!empty($page_data['menu_alt_icon_hot']) ? $page_data['menu_alt_icon_hot'] : $page_data['menu_alt_icon']) : $page_data['menu_alt_icon']; + $menu_icon = '<img border="0" align="absmiddle" src="' . $icon_url . '" alt="' . $desc . '" /> '; + } + + // + // Generate Links + // + $menu_link = mx_append_sid(PORTAL_URL . 'index.php?page=' . $page_data['page_id']); + + + $link_target = ( true ) ? '' : '_blank'; + $row_color_over = $theme['tr_color2']; + + $menu_array = array( + 'ROW_COLOR_OVER' => '#' . $row_color_over, + 'MENU_NAME' => $action, + 'MENU_STYLE' => $style, + 'MENU_DESC' => $desc, + 'U_MENU_MODULE' => $menu_link, + 'U_LINK_TARGET' => $link_target, + 'U_MENU_ICON' => $menu_icon + ); + + $template->assign_block_vars('catrow.modulerow', $menu_array); + + if ($current_parent_page) + { + $template->assign_block_vars('modulerow', $menu_array); + } + } + } // End Auth + } + return; + } + return; + } + + function has_active_subpage($page_parent = 0, $depth = 0) + { + global $mx_page; + + if ( isset( $mx_page->subpage_rowset[$page_parent] ) ) + { + foreach( $mx_page->subpage_rowset[$page_parent] as $subpage_id => $page_data ) + { + if ($mx_page->page_id == $subpage_id) + { + return true; + } + } + return has_active_subpage($subpage_id, $depth + 1);; + } + return false; + } ?> \ No newline at end of file |