From: <vb...@us...> - 2002-09-10 13:58:39
|
Update of /cvsroot/webnotes/webnotes/core In directory usw-pr-cvs1:/tmp/cvs-serv5632/core Modified Files: link_api.php page_api.php Log Message: - Clean up work in admin_index_files.php - Added the possibility of indexing / unindexing single pages. Index: link_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/link_api.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- link_api.php 6 Sep 2002 17:03:37 -0000 1.1 +++ link_api.php 10 Sep 2002 13:58:34 -0000 1.2 @@ -14,12 +14,34 @@ ########################################################################### ### -------------------- - function link_note_action( $p_note_id, $p_action, $p_url ) { + function link_note_action( $p_note_id, $p_action, $p_url, $p_link_active = true ) { $t_caption = lang_get( 'action_' . $p_action ); $c_note_id = db_prepare_int( $p_note_id ); $c_action = urlencode( $p_action ); $c_url = urlencode( $p_url ); $t_action = config_get( 'web_directory') . 'action.php'; - return "[ <a href=\"$t_action?f_action=$c_action&f_note_id=$c_note_id&f_url=$c_url\">$t_caption</a> ]"; + + if ( $p_link_active ) { + return "[ <a href=\"$t_action?f_action=$c_action&f_note_id=$c_note_id&f_url=$c_url\">$t_caption</a> ]"; + } else { + return "[ $t_caption ]"; + } + } + ### -------------------- + # $p_page = $p_page_id if action is unindex + # $p_page = $p_page_name if action is index + function link_page_action( $p_page, $p_action, $p_url, $p_link_active = true ) { + $t_caption = lang_get( 'action_' . $p_action ); + + $c_page_id = urlencode( $p_page ); + $c_action = urlencode( $p_action ); + $c_url = urlencode( $p_url ); + $t_action = config_get( 'web_directory') . 'action.php'; + + if ( $p_link_active ) { + return "[ <a href=\"$t_action?f_action=$c_action&f_page_id=$c_page_id&f_url=$c_url\">$t_caption</a> ]"; + } else { + return "[ $t_caption ]"; + } } ?> Index: page_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/page_api.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- page_api.php 10 Sep 2002 10:34:14 -0000 1.6 +++ page_api.php 10 Sep 2002 13:58:34 -0000 1.7 @@ -28,8 +28,12 @@ return false; } ### -------------------- + function page_valid_ip( $p_page_id ) { + return ( false !== $p_page_id ); + } + ### -------------------- function page_is_indexed( $p_file ) { - return ( false !== page_get_id( $p_file ) ); + return ( page_valid_ip( page_get_id( $p_file ) ) ); } ### -------------------- function page_visible_notes_count( $p_page_id ) { @@ -75,8 +79,10 @@ } ### -------------------- ### Allows for path navigation to choose base dir - function print_dirs( $p_path ) { + function print_dirs( $p_path, $p_php_self ) { global $g_admin_index_files; + + echo '<table>'; $handle = opendir( $p_path ); while ( $file = readdir( $handle ) ) { @@ -87,10 +93,30 @@ $t_dir = $p_path . $file; } $t_dir = urlencode( $t_dir ); - echo "<a href=\"$g_admin_index_files?f_dir=$t_dir\">$file</a><br />"; + echo "<tr><td></td><td><a href=\"$g_admin_index_files?f_dir=$t_dir\">[$file]</a></td></tr>"; + } + } + closedir( $handle ); + + $handle = opendir( $p_path ); + while ( $file = readdir( $handle ) ) { + if ( !is_dir( $p_path . $file ) ) { + $t_filename = $p_path . $file; + $t_id = page_get_id( $t_filename ); + #echo "<a href=\"$g_admin_index_files?f_dir=$t_file\">$file</a><br />"; + $t_add = !page_valid_ip( $t_id ); + if ( !$t_add ) { + $t_count = '(' . page_visible_notes_count( $t_id ) . ')'; + } else { + $t_count = ''; + } + + echo "<tr><td>" . link_page_action( $t_filename, 'index', $p_php_self, $t_add ) . ' ' . link_page_action( $t_id, 'unindex', $p_php_self, !$t_add ). "</td><td><tt>$file$t_count</tt></td></tr>"; } } closedir( $handle ); + + echo '</table>'; } ### -------------------- function page_add( $p_page_name ) { @@ -135,9 +161,7 @@ foreach ( $files as $file ) { $t_filename = $p_path . $file; - if ( page_add( $t_filename ) ) { - echo "$t_filename<br />"; - } + page_add( $t_filename ); } # if not recursive return before processing sub-directories @@ -150,6 +174,17 @@ } } ### -------------------- + function page_delete_notes( $p_page_id ) { + global $g_phpWN_note_table; + + $c_page_id = db_prepare_int( $p_page_id ); + + $query = "DELETE FROM $g_phpWN_note_table + WHERE page_id='$c_page_id'"; + + return true; + } + ### -------------------- function page_delete( $p_page_id ) { global $g_phpWN_page_table; @@ -160,11 +195,12 @@ LIMIT 1"; $result = db_query( $query ); - if ( db_num_rows( $result) > 0 ) { - return true; - } - return false; + if ( !page_delete_notes( $p_page_id ) ) { + return false; + }; + + return true; } ### -------------------- ?> |