Update of /cvsroot/webnotes/webnotes/core
In directory usw-pr-cvs1:/tmp/cvs-serv13329/core
Modified Files:
note_api.php string_api.php
Log Message:
- Changed the preserving of spaces to be only done when the spaces are at the
beginning of a line (string_preserve_spaces_at_bol()).
- Added string_prepare_note_for_viewing() to be used from viewing/previewing.
Index: note_api.php
===================================================================
RCS file: /cvsroot/webnotes/webnotes/core/note_api.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- note_api.php 22 Sep 2002 04:17:38 -0000 1.26
+++ note_api.php 24 Sep 2002 06:14:40 -0000 1.27
@@ -204,13 +204,13 @@
$info['visible'] = $v_visible;
$info['id'] = $v_id;
$info['email'] = $v_email;
- $info['note'] = string_add_note_links( $t_page_info['url'], string_preserve_spaces( string_disable_html( $v_note ) ) );
+ $info['note'] = string_prepare_note_for_viewing ( $v_note, $t_page_info['url'] );
$info['date'] = $v_date_submitted;
$notes[] = $info;
}
-
+
return( $notes );
}
### --------------------
Index: string_api.php
===================================================================
RCS file: /cvsroot/webnotes/webnotes/core/string_api.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- string_api.php 15 Sep 2002 02:25:58 -0000 1.5
+++ string_api.php 24 Sep 2002 06:14:40 -0000 1.6
@@ -40,6 +40,25 @@
return str_replace( " ", " ", $p_string );
}
### --------------------
+ # Preserve spaces at beginning of lines.
+ function string_preserve_spaces_at_bol( $p_string ) {
+ $lines = explode("\n", $p_string);
+ for ( $i = 0; $i < count( $lines ); $i++ ) {
+ $count = 0;
+ $prefix = '';
+ while ( substr($lines[$i], $count, 1) == ' ' ) {
+ $count++;
+ }
+ for ($j = 0; $j < $count; $j++) {
+ $prefix .= ' ';
+ }
+ $lines[$i] = $prefix . substr( $lines[$i], $count );
+
+ }
+ $result = implode( "\n", $lines );
+ return $result;
+ }
+ ### --------------------
function string_to_form( $p_string ) {
return htmlspecialchars( addslashes( $p_string ) );
}
@@ -50,6 +69,14 @@
### --------------------
function string_add_note_links( $p_page_url, $p_note ) {
return ( preg_replace( '/#([0-9]+)/', "<a href=\"$p_page_url#\\1\">#\\1</a>", $p_note ) );
+ }
+ ### --------------------
+ function string_prepare_note_for_viewing( $p_note_string, $p_url = null ) {
+ if ( null !== $p_url ) {
+ return( string_add_note_links( $p_url, string_preserve_spaces_at_bol( string_disable_html( $p_note_string ) ) ) );
+ } else {
+ return( string_preserve_spaces_at_bol( string_disable_html( $p_note_string ) ) );
+ }
}
### --------------------
?>
|