From: <vb...@us...> - 2002-09-19 22:50:41
|
Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv26969/core Modified Files: link_api.php note_api.php page_api.php Log Message: - Added prev_id and next_id to the pages table. - Handled prev/next from theme - Auto setting prev/next if specific in the call to webnotes. - Added XHTML example, to demonstrate the prev / prev-next / next. There is still a problem with pages that have no notes. Index: link_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/link_api.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- link_api.php 19 Sep 2002 04:15:48 -0000 1.4 +++ link_api.php 19 Sep 2002 22:50:38 -0000 1.5 @@ -13,6 +13,14 @@ ########################################################################### ### -------------------- + function link_create( $p_url, $p_caption, $p_link_active, $p_prefix = '[ ', $p_suffix = ' ]' ) { + if ( !empty( $p_url ) || (false === p_link_active) ) { + return "$p_prefix<a href=\"$p_url\">$p_caption</a>$p_suffix"; + } else { + return "$p_prefix$p_caption$p_suffix"; + } + } + ### -------------------- function link_note_action( $p_note_id, $p_action, $p_url, $p_link_active = true, $p_caption = null ) { if ( null === $p_caption ) { $t_caption = lang_get( 'action_' . $p_action ); @@ -27,13 +35,9 @@ $c_action = urlencode( $p_action ); $c_url = urlencode( $p_url ); $t_action = config_get( 'web_directory') . 'action.php'; + $t_link = "$t_action?f_action=$c_action&f_note_id=$c_note_id&f_url=$c_url"; - if ( $p_link_active ) { - $t_link = "$t_action?f_action=$c_action&f_note_id=$c_note_id&f_url=$c_url"; - return $t_before . "<a href=\"$t_link\">$t_caption</a>" . $t_after; - } else { - return $t_before . $t_caption . $t_after; - } + return( link_create( $t_link, $t_caption, $p_link_active, $t_before, $t_after ) ); } ### -------------------- # $p_page = $p_page_id if action is unindex @@ -52,12 +56,8 @@ $c_action = urlencode( $p_action ); $c_url = urlencode( $p_url ); $t_action = config_get( 'web_directory' ) . 'action.php'; + $t_link = "$t_action?f_action=$c_action&f_page_id=$c_page_id&f_url=$c_url"; - if ( $p_link_active ) { - $t_link = "$t_action?f_action=$c_action&f_page_id=$c_page_id&f_url=$c_url"; - return $t_before . "<a href=\"$t_link\">$t_caption</a>" . $t_after; - } else { - return $t_before . "$t_caption" . $t_after; - } + return( link_create( $t_link, $t_caption, $p_link_active, $t_before, $t_after ) ); } ?> Index: note_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/note_api.php,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- note_api.php 19 Sep 2002 21:51:01 -0000 1.19 +++ note_api.php 19 Sep 2002 22:50:38 -0000 1.20 @@ -112,8 +112,6 @@ return; } - page_update_url( $c_id, $p_url ); - $c_page_name = db_prepare_string( $p_page_name ); $query = "SELECT * @@ -253,26 +251,29 @@ } } ### -------------------- - function print_web_notes( $p_file, $p_url ) { + function print_web_notes( $p_page, $p_url, $p_prev_page = null, $p_next_page = null ) { echo '<br />'; - $t_page_id = page_get_id( $p_file ); + $t_page_id = page_get_id( $p_page ); if ( !page_valid_id( $t_page_id ) ) { if ( ON === config_get( 'auto_index_pages' ) ) { - if ( page_add( $p_file ) ) { - print_web_notes( $p_file, $p_url ); + if ( page_add( $p_page ) ) { + print_web_notes( $p_page, $p_url, $p_prev_page, $p_next_page ); return; } } - theme_not_indexed( $p_file, $p_url ); + theme_not_indexed( $p_page, $p_url ); } else { + page_update_url( $t_page_id, $p_url ); + page_update_neighbours( $t_page_id, $p_prev_page, $p_next_page ); + if ( page_visible_notes_count ( $t_page_id ) > 0 ) { - theme_notes_start( $p_file, $p_url ); - note_print_all( $p_file, $p_url ); - theme_notes_end( $p_file, $p_url ); + theme_notes_start( $p_page, $p_url ); + note_print_all( $p_page, $p_url ); + theme_notes_end( $p_page, $p_url ); } else { - theme_notes_none( $p_file, $p_url ); + theme_notes_none( $p_page, $p_url ); } } } Index: page_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/page_api.php,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- page_api.php 19 Sep 2002 21:51:02 -0000 1.11 +++ page_api.php 19 Sep 2002 22:50:38 -0000 1.12 @@ -135,6 +135,42 @@ $result = db_query( $query ); } ### -------------------- + function page_update_neighbours( $p_page_id, $p_prev, $p_next ) { + if ( ( null === $p_prev ) && ( null === $p_next ) ) { + return; + } + + $t_page_info = page_get_info( page_where_id_equals( $p_page_id ) ); + if ( false === $t_page_info ) { + return; + } + + if ( null === $p_prev ) { + $t_prev_id = 0; + } else { + $t_prev_id = page_get_id( $p_prev ); + #if ( false === page_valid_id( $t_prev_id ) ) { + # $t_prev_id = 0; + #} + } + + if ( null === $p_next ) { + $t_next_id = 0; + } else { + $t_next_id = page_get_id( $p_next ); + if ( false === page_valid_id( $t_next_id ) ) { + $t_next_id = 0; + } + } + + $c_page_id = db_prepare_int( $p_page_id ); + + $query = "UPDATE " . config_get( 'phpWN_page_table' ) . " + SET prev_id='$t_prev_id', next_id='$t_next_id' + WHERE id='$c_page_id' LIMIT 1"; + $result = db_query( $query ); + } + ### -------------------- ### Allows for path navigation to choose base dir function print_dirs( $p_path, $p_php_self ) { global $g_admin_index_files; |