From: <vb...@us...> - 2002-09-20 04:17:45
|
Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv5624/core Modified Files: api.php css_inc.php html_api.php note_api.php page_api.php Added Files: pwn_api.php Log Message: - Fixed the preview to use the new theme interface. - Fixed a layout problem with the preview page (because of styles). - Added APIs for updating the last-modified of pages / notes (not supported by db yet). - Renamed theme_output() to theme_body() and changed it to handle the case where the page data is false (page not indexed and auto index off). - Added theme_head() to be called with the <head>...</head> tags. - Added pwn_api.php to act the the main interface to phpWebNotes (pwn_head() and pwn_body()). - Changed the samples to use the new pwn_* apis. - Added meta tags to disable caching for pages that has phpWebNotes linked to it. - Used include_once() in all html_apis to avoid styles and other includes from being included more than once. --- NEW FILE: pwn_api.php --- <?php # phpWebNotes - a php based note addition system # Copyright (C) 2000-2002 Webnotes Team - web...@so... # This program is distributed under the terms and conditions of the GPL # See the files README and LICENSE for details # -------------------------------------------------------- # $Id: pwn_api.php,v 1.1 2002/09/20 04:17:43 vboctor Exp $ # -------------------------------------------------------- ### -------------------- function pwn_head() { global $g_meta_inc_file; print_meta_inc( $g_meta_inc_file ); theme_head(); } ### -------------------- function pwn_body( $p_page, $p_url, $p_prev_page = null, $p_next_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 ) ) { print_web_notes( $p_page, $p_url, $p_prev_page, $p_next_page ); return; } } 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_data = page_prepare_theme_data( $t_page_id ); theme_body ( $page_data ); } } ### -------------------- ?> Index: api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/api.php,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- api.php 20 Sep 2002 03:16:30 -0000 1.26 +++ api.php 20 Sep 2002 04:17:43 -0000 1.27 @@ -69,6 +69,7 @@ require_once( $t_path_core . 'gpc_api.php' ); require_once( $t_path_core . 'email_api.php' ); require_once( $t_path_core . 'enum_api.php' ); + require_once( $t_path_core . 'pwn_api.php' ); require_once( $t_path_main . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $g_theme . DIRECTORY_SEPARATOR . 'theme_api.php' ); Index: css_inc.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/css_inc.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- css_inc.php 15 Sep 2002 13:20:56 -0000 1.7 +++ css_inc.php 20 Sep 2002 04:17:43 -0000 1.8 @@ -12,7 +12,7 @@ form { margin: 0px; display: inline; } body { background-color: #ffffff; font-family:Verdana, Arial; font-size: 10pt } -td { font-family:Verdana, Arial; font-size: 10pt; padding: 4px; text-align: left; } +td { font-family:Verdana, Arial; font-size: 10pt; padding: 4px; } p { font-family:Verdana, Arial; font-size: 10pt } h3 { font-family:Verdana, Arial; font-size: 13pt; font-weight: bold; text-align: center } address { font-family:Verdana, Arial; font-size: 8pt } Index: html_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/html_api.php,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- html_api.php 19 Sep 2002 21:51:01 -0000 1.8 +++ html_api.php 20 Sep 2002 04:17:43 -0000 1.9 @@ -23,13 +23,13 @@ ### -------------------- function print_css( $p_css = '' ) { if ( !empty( $p_css ) && file_exists( $p_css ) ) { - include( $p_css ); + include_once( $p_css ); } } ### -------------------- function print_meta_inc( $p_meta_inc = '' ) { if ( !empty( $p_meta_inc ) && file_exists( $p_meta_inc ) ) { - include( $p_meta_inc ); + include_once( $p_meta_inc ); } } ### -------------------- @@ -74,13 +74,13 @@ ### -------------------- function print_top_page( $p_page ) { if ( !empty( $p_page ) && file_exists( $p_page ) ) { - include( $p_page ); + include_once( $p_page ); } } ### -------------------- function print_bottom_page( $p_page ) { if ( !empty( $p_page ) && file_exists( $p_page ) ) { - include( $p_page ); + include_once( $p_page ); } } ### -------------------- Index: note_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/note_api.php,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- note_api.php 20 Sep 2002 03:16:30 -0000 1.22 +++ note_api.php 20 Sep 2002 04:17:43 -0000 1.23 @@ -34,11 +34,17 @@ $c_note = db_prepare_string( $p_note ); $c_remote_address = db_prepare_string( $p_remote_addr ); + # @@@@ Also set last-updated field + $query = "INSERT INTO " . config_get( 'phpWN_note_table' ) . " ( id, page_id, email, ip, date_submitted, note, visible ) VALUES ( null, '$c_page_id', '$c_email', '$c_remote_address', NOW(), '$c_note', '$t_visible' )"; - return db_query( $query ); + $result = db_query( $query ); + + page_touch( $p_page_id ); + + return ( $result ); } ### -------------------- function note_get_visibility_str( $p_visible ) { @@ -66,6 +72,8 @@ SET visible='$c_visibility' WHERE id='$c_id' LIMIT 1"; $result = db_query( $query ); + + note_touch( $p_id ); } ### -------------------- # Put back as pending if approved by default. @@ -104,6 +112,11 @@ SET email='$c_email', note='$c_note' WHERE id='$c_id' LIMIT 1"; $result = db_query( $query ); + + note_touch( $p_id ); + } + ### -------------------- + function note_touch( $p_note_id, $p_page_id = null ) { } ### -------------------- function note_get_all_visible( $p_page_id ) { @@ -173,29 +186,6 @@ } return db_query( $query ); - } - ### -------------------- - 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_page ); - if ( !page_valid_id( $t_page_id ) ) { - if ( ON === config_get( 'auto_index_pages' ) ) { - if ( page_add( $p_page ) ) { - print_web_notes( $p_page, $p_url, $p_prev_page, $p_next_page ); - return; - } - } - - 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 ); - $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.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- page_api.php 20 Sep 2002 03:16:30 -0000 1.14 +++ page_api.php 20 Sep 2002 04:17:43 -0000 1.15 @@ -126,6 +126,8 @@ return; } + # @@@@ If the information is the same, then don't update/touch. + $c_page_id = db_prepare_int( $p_page_id ); $c_url = db_prepare_string( $p_url ); @@ -133,6 +135,7 @@ SET url='$c_url' WHERE id='$c_page_id' LIMIT 1"; $result = db_query( $query ); + page_touch( $p_page_id ); } ### -------------------- function page_update_neighbours( $p_page_id, $p_prev, $p_next ) { @@ -163,12 +166,19 @@ } } + # @@@@ If the information is the same, then don't update/touch. + $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 ); + page_touch( $p_page_id ); + } + ### -------------------- + # Update the last modified time stamp for the page. + function page_touch( $p_page_id ) { } ### -------------------- ### Allows for path navigation to choose base dir |