|
From: Jon O. <jon...@us...> - 2008-05-03 19:11:28
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30222 Modified Files: Tag: core28x mx_functions.php Log Message: Added new feature to site navigation: parent id. Index: mx_functions.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions.php,v retrieving revision 1.72.2.4 retrieving revision 1.72.2.5 diff -C2 -d -r1.72.2.4 -r1.72.2.5 *** mx_functions.php 18 Feb 2008 18:36:20 -0000 1.72.2.4 --- mx_functions.php 3 May 2008 19:11:22 -0000 1.72.2.5 *************** *** 436,439 **** --- 436,524 ---- /** + * Jump menu function. + * + * @access public + * @param unknown_type $page_id to handle parent page_id + * @param unknown_type $depth related to function to generate tree + * @param unknown_type $default the page you wanted to be selected + * @return unknown + */ + function generate_page_jumpbox( $name_select, $page_id = 0, $depth = 0, $default = '' ) + { + global $db, $userdata, $portal_config, $lang; + + $sql = 'SELECT * + FROM ' . PAGE_TABLE . ' + ORDER BY page_parent, page_order ASC'; + + if ( !( $result = $db->sql_query( $sql ) ) ) + { + mx_message_die( GENERAL_ERROR, 'Couldnt Query pages info', '', __LINE__, __FILE__, $sql ); + } + + $page_rowset = $db->sql_fetchrowset( $result ); + $db->sql_freeresult( $result ); + + $pagesArray = array(); + for( $i = 0; $i < count( $page_rowset ); $i++ ) + { + $pagesArray[$page_rowset[$i]['page_id']] = $page_rowset[$i]; + } + + $page_list .= ''; + $pre = str_repeat( ' ', $depth ); + + if ( !empty( $pagesArray ) ) + { + foreach ( $pagesArray as $temp_page_id => $page ) + { + if ( $page['page_parent'] == $page_id ) + { + if ( $default == $page['page_id'] ) + { + $sel = ' selected="selected"'; + } + else + { + $sel = ''; + } + + $page_pre = '+ '; + $sub_page_id = $page['page_id']; + $page_class = ''; + $page_list .= '<option value="' . $sub_page_id . '"' . $sel . ' ' . $page_class . ' />' . $pre . $page_pre . $page['page_name'] . (!empty($page['page_desc']) ? ' (' . $page['page_desc'] . ')' : '') . '</option>'; + $page_list .= generate_page_jumpbox( $name_select, $page['page_id'], $depth + 1, $default ); + } + } + + if ($page_id == 0) + { + // Format Select + $pageList = '<select name="'. $name_select . '">'; + if ( !$pagesArray[$default]['page_parent'] ) + { + $pageList .= '<option value="0" selected>' . $lang['None'] . '</option>\n'; + } + else + { + $pageList .= '<option value="0">' . $lang['None'] . '</option>\n'; + } + $pageList .= $page_list; + $pageList .= '</select>'; + + return $pageList; + } + else + { + return $page_list; + } + } + else + { + return; + } + } + + /** * Generate mxBB URL, with arguments. * |