From: <vb...@us...> - 2002-10-01 06:51:49
|
Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv14883/core Modified Files: page_api.php pwn_api.php Log Message: - Fixed a problem with page_update_neighbours, where neighbours were only updated if both prev/next are changed, rather than if only one changed. - Added parent_id field to the page table in the database. - Update neighbours currently defaults the prev/next/parent to the database value if null is passed, rather than replacing it with 0. Any empty string should be used to highlight the fact that there is no prev/next/parent. Or if it was never set, then null would work. - Dropped a redundant index (id) in the pages table. - Dropped a redundant index (id) in the notes table. - Removed an extra </table> in case of pages without notes (phpnet theme). - Implemented the first version of the php-like manual and added the necessary. Index: page_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/page_api.php,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- page_api.php 26 Sep 2002 03:41:46 -0000 1.18 +++ page_api.php 1 Oct 2002 06:51:45 -0000 1.19 @@ -137,8 +137,8 @@ page_touch( $p_page_id ); } ### -------------------- - function page_update_neighbours( $p_page_id, $p_prev, $p_next ) { - if ( ( null === $p_prev ) && ( null === $p_next ) ) { + function page_update_neighbours( $p_page_id, $p_prev, $p_next, $p_parent ) { + if ( ( null === $p_prev ) && ( null === $p_next ) && ( null === $p_parent ) ) { return; } @@ -147,8 +147,17 @@ return; } + if ( null === $p_parent ) { + $t_parent_id = $t_page_info['parent_id']; + } else { + $t_parent_id = page_get_id( $p_parent ); + if ( false === page_valid_id( $t_parent_id ) ) { + $t_parent_id = 0; + } + } + if ( null === $p_prev ) { - $t_prev_id = 0; + $t_prev_id = $t_page_info['prev_id']; } else { $t_prev_id = page_get_id( $p_prev ); if ( false === page_valid_id( $t_prev_id ) ) { @@ -157,7 +166,7 @@ } if ( null === $p_next ) { - $t_next_id = 0; + $t_next_id = $t_page_info['next_id']; } else { $t_next_id = page_get_id( $p_next ); if ( false === page_valid_id( $t_next_id ) ) { @@ -166,14 +175,16 @@ } # If the information is the same, then don't update/touch. - if ( ( $t_prev_id == $t_page_info['prev_id'] ) || ( $t_next_id == $t_page_info['next_id'] ) ) { + if ( ( $t_parent_id == $t_page_info['parent_id'] ) && + ( $t_prev_id == $t_page_info['prev_id'] ) && + ( $t_next_id == $t_page_info['next_id'] ) ) { return; } $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 + SET parent_id=$t_parent_id, prev_id=$t_prev_id, next_id=$t_next_id WHERE id=$c_page_id LIMIT 1"; $result = db_query( $query ); page_touch( $p_page_id ); Index: pwn_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/pwn_api.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- pwn_api.php 22 Sep 2002 02:47:16 -0000 1.4 +++ pwn_api.php 1 Oct 2002 06:51:45 -0000 1.5 @@ -10,18 +10,17 @@ ### -------------------- function pwn_head() { - global $g_meta_inc_file, $g_css_inc_file; - print_meta_inc( $g_meta_inc_file ); - print_css( $g_css_inc_file ); + print_meta_inc( config_get( 'meta_inc_file' ) ); + print_css( config_get( 'css_inc_file' ) ); theme_head(); } ### -------------------- - function pwn_body( $p_page, $p_url, $p_prev_page = null, $p_next_page = null ) { + function pwn_body( $p_page, $p_url, $p_prev_page = null, $p_next_page = null, $p_parent_page = null ) { $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_page ) ) { - pwn_body( $p_page, $p_url, $p_prev_page, $p_next_page ); + pwn_body( $p_page, $p_url, $p_prev_page, $p_next_page, $p_parent_page ); return; } } @@ -29,10 +28,40 @@ theme_body ( false ); } else { page_update_url( $t_page_id, $p_url ); - page_update_neighbours( $t_page_id, $p_prev_page, $p_next_page ); + page_update_neighbours( $t_page_id, $p_prev_page, $p_next_page, $p_parent_page ); $page_data = page_prepare_theme_data( $t_page_id ); theme_body ( $page_data ); } + } + ### -------------------- + function pwn_page_get_link( $p_page ) { + return ( page_get_info( page_where_page_equals( $p_page ), 'url' ) ); + } + ### -------------------- + function pwn_page_get_siblings_array( $p_page ) { + $t_page_info = page_get_info( page_where_page_equals( $p_page ) ); + if ( false === $t_page_info ) { + return array(); + } + + $t_parent_id = $t_page_info['parent_id']; + if ( 0 == $t_parent_id ) { + return array(); + } + + $t_id = $t_page_info['id']; + + $query = "SELECT page + FROM " . config_get( 'phpWN_page_table' ) . " + WHERE ( parent_id = $t_parent_id ) AND ( id <> $t_id )"; + $result = db_query( $query ); + + $t_pages_array = array(); + while ( $row = db_fetch_array( $result ) ) { + $t_pages_array[] = $row['page']; + } + + return $t_pages_array; } ### -------------------- ?> |