From: <vb...@us...> - 2002-09-20 02:48:49
|
Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv20300/core Modified Files: note_api.php page_api.php Log Message: - Changed the way the schemes are structure to accept one array which has all information rather than header, note, footer. - Remove the handling of finding out the prev / next page names/urls from the theme to the core. - Added page_prepare_theme_data() which prepares all the information to be used by the scheme into one array. The theme should never need to access the database. - Removed the row which has the add / help icons from the footer when there is no notes in the page. - Added source forge logo to the XHTML sample. Index: note_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/note_api.php,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- note_api.php 19 Sep 2002 22:50:38 -0000 1.20 +++ note_api.php 20 Sep 2002 02:48:46 -0000 1.21 @@ -106,24 +106,23 @@ $result = db_query( $query ); } ### -------------------- - function note_print_all( $p_page_name, $p_url ) { - $c_id = page_get_id( $p_page_name ); - if ( false === page_valid_id( $c_id ) ) { - return; + function note_get_all_visible( $p_page_id ) { + $notes = array(); + + $t_page_info = page_get_info( page_where_id_equals( $p_page_id ) ); + if ( false === $t_page_info ) { + return false; } - $c_page_name = db_prepare_string( $p_page_name ); + $c_page_id = db_prepare_int( $p_page_id ); $query = "SELECT * - FROM " . config_get( 'phpWN_page_table' ) . " p, - " . config_get( 'phpWN_note_table' ) . " n - WHERE p.page='$c_page_name' AND n.page_id=p.id - ORDER BY n.date_submitted " . config_get( 'note_order' ); + FROM " . config_get( 'phpWN_note_table' ) . " + WHERE page_id='$c_page_id' + ORDER BY date_submitted " . config_get( 'note_order' ); $result = db_query( $query ); - $entry_count = db_num_rows( $result ); - for ( $i = 0; $i < $entry_count; $i++ ) { - $row = db_fetch_array( $result ); + while ( $row = db_fetch_array( $result ) ) { extract( $row, EXTR_PREFIX_ALL, 'v' ); if ( ( NOTE_VISIBLE_PENDING == $v_visible ) && ( access_check_action( ACTION_NOTES_VIEW_PENDING ) === false ) ) { @@ -149,14 +148,14 @@ $info['visible'] = $v_visible; $info['id'] = $v_id; $info['email'] = $v_email; - $info['note'] = string_add_note_links( $p_url, string_preserve_spaces( string_disable_html( $v_note ) ) ); + $info['note'] = string_add_note_links( $t_page_info['url'], string_preserve_spaces( string_disable_html( $v_note ) ) ); - #Removed by Remon tell we fix the problem in the sql_to_unix_time - #$info['date'] = date( 'M, d Y H:i', sql_to_unix_time( $v_date_submitted ) ); $info['date'] = $v_date_submitted; - theme_notes_echo( $p_page_name, $p_url, $info ); + $notes[] = $info; } + + return( $notes ); } ### -------------------- # @@@@ Should be obsolete soon! @@ -267,13 +266,9 @@ } 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_page, $p_url ); - note_print_all( $p_page, $p_url ); - theme_notes_end( $p_page, $p_url ); - } else { - theme_notes_none( $p_page, $p_url ); + $page_data = page_prepare_theme_data( $t_page_id ); + if ( false !== $page_data ) { + theme_output ( $page_data ); } } } Index: page_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/page_api.php,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- page_api.php 19 Sep 2002 22:50:38 -0000 1.12 +++ page_api.php 20 Sep 2002 02:48:46 -0000 1.13 @@ -291,4 +291,42 @@ return true; } ### -------------------- + function page_prepare_theme_data( $p_page_id ) { + $t_page_data = array(); + + $t_page_info = page_get_info( page_where_id_equals( $p_page_id ) ); + if ( false === $t_page_info ) { + return (false); + } + + $t_page_data['id'] = $t_page_info['id']; + $t_page_data['page'] = $t_page_info['page']; + $t_page_data['url'] = $t_page_info['url']; + $t_page_data['last_modified'] = 0; + $t_page_data['preview'] = false; + + $t_prev_page = page_get_info( page_where_id_equals( $t_page_info['prev_id'] ) ); + $t_next_page = page_get_info( page_where_id_equals( $t_page_info['next_id'] ) ); + + if ( false === $t_prev_page ) { + $t_page_data['prev_page'] = ''; + $t_page_data['prev_url'] = ''; + } else { + $t_page_data['prev_page'] = $t_prev_page['page']; + $t_page_data['prev_url'] = $t_prev_page['url']; + } + + if ( false === $t_next_page ) { + $t_page_data['next_page'] = ''; + $t_page_data['next_url'] = ''; + } else { + $t_page_data['next_page'] = $t_next_page['page']; + $t_page_data['next_url'] = $t_next_page['url']; + } + + $t_page_data['notes'] = note_get_all_visible( $p_page_id ); + + return( $t_page_data ); + } + ### -------------------- ?> |