Index: openacs-4/packages/ref-unspsc/www/edit-localized-message.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ref-unspsc/www/edit-localized-message.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ref-unspsc/www/edit-localized-message.tcl 7 Oct 2005 05:41:07 -0000 1.1 +++ openacs-4/packages/ref-unspsc/www/edit-localized-message.tcl 19 Apr 2018 08:00:46 -0000 1.2 @@ -49,7 +49,7 @@ {label "Message Key"} {value "$package_key.$message_key"} } -} +} if { ![string equal $default_locale $current_locale] } { ad_form -extend -name message -form { @@ -58,7 +58,7 @@ } } } - + ad_form -extend -name message -form { {message:text(textarea) {label "$locale_label Message"} @@ -103,7 +103,7 @@ if { [exists_and_not_null message] } { set message $message } else { - set message $original_message + set message $original_message } @@ -135,9 +135,9 @@ where lm2.package_key = :package_key and lm2.message_key = :message_key and lm2.locale = :current_locale - ) + ) } - } + } set first_translated_message "
- We wrap it because at the end of this proc, we must set - sp_sync_cr_with_filesystem_times($package_id) back to empty string. - But if we hit some random untrapped error partway through, we'll - never get there. Therefore, we wrap this proc inside another, and - have the wrapper proc catch any errors thrown by this proc, set the - var back to empty string, then re-throw the error. -
- This procedure takes the exact same arguments as its - sp_sync_cr_with_filesystem wrapper proc, except for the addition of - return_mesg_var. -
- You should never call this procedure, except from - sp_sync_cr_with_filesystem. + This procedure was originally named sp_sync_cr_with_filesystem + procedure, but has been renamed and modified so that it can be + wrapped inside the new sp_sync_cr_with_filesystem, to support the + mutex locking. +
+ We wrap it because at the end of this proc, we must set + sp_sync_cr_with_filesystem_times($package_id) back to empty string. + But if we hit some random untrapped error partway through, we'll + never get there. Therefore, we wrap this proc inside another, and + have the wrapper proc catch any errors thrown by this proc, set the + var back to empty string, then re-throw the error. +
+ This procedure takes the exact same arguments as its + sp_sync_cr_with_filesystem wrapper proc, except for the addition of + return_mesg_var. +
+ You should never call this procedure, except from + sp_sync_cr_with_filesystem. - @param return_mesg_var Name of variable in which to return text - message, for presentation on a web page to the user. + @param return_mesg_var Name of variable in which to return text + message, for presentation on a web page to the user. - @param package_id Must be passed in, for this internal - version of the proc. + @param package_id Must be passed in, for this internal + version of the proc. - @author Brandoch Calef (bcalef@arsdigita.com) - @author Andrew Piskorski (atp@piskorski.com) - @creation-date 2001-02-07 + @author Brandoch Calef (bcalef@arsdigita.com) + @author Andrew Piskorski (atp@piskorski.com) + @creation-date 2001-02-07 } { set proc_name {sp_sync_cr_with_filesystem_internal} - if { [empty_string_p $package_id] } { + if { $package_id eq "" } { error "package_id '$package_id' is not valid." } upvar $return_mesg_var return_mesg @@ -254,7 +254,7 @@ set other_start_time [nsv_get sp_sync_cr_fs_times $package_id] } - if { [empty_string_p $other_start_time] } { + if { $other_start_time eq "" } { # We're ok, no other copy is running. nsv_set $nsv $package_id [ns_time] set run_p 1 @@ -275,9 +275,9 @@ ns_log Warning $mesg set return_mesg "Another copy of this procedure is already running for - this package instance. It started running $time_diff seconds - ago, at $other_time_pretty. Only one copy may run at a time. - Please wait and then try again." + this package instance. It started running $time_diff seconds + ago, at $other_time_pretty. Only one copy may run at a time. + Please wait and then try again." # Whether you actually see this happen depends whether the # second thread running this proc gets scheduled or not before @@ -305,67 +305,66 @@ # --atp@piskorski.com, 2002/09/15 10:03 EDT foreach file [ad_find_all_files $fs_root] { - if { [regexp -nocase $static_page_regexp $file match] } { - # Chop the starting path off of the full pathname and split it up: - set path [split [string range $file $fs_trimmed_length end] "/"] - # Throw away the first entry (empty) and the last entry (which is the filename): - set path [lrange $path 1 [expr [llength $path]-2]] + if { [regexp -nocase $static_page_regexp $file match] } { + # Chop the starting path off of the full pathname and split it up: + set path [split [string range $file $fs_trimmed_length end] "/"] + # Throw away the first entry (empty) and the last entry (which is the filename): + set path [lrange $path 1 [expr [llength $path]-2]] - set cumulative_path "" - set parent_folder_id $root_folder_id - foreach directory $path { - append cumulative_path "$directory/" - if (![info exists path_exists($cumulative_path)]) { - # check db - set folder_id [db_string get_folder_id { - select nvl(content_item.get_id(:cumulative_path,:root_folder_id),0) - from dual - }] - # If the folder doesn't exist, create it. - if { $folder_id == 0} { - set folder_id [db_exec_plsql create_new_folder {}] - if { [string length $folder_add_proc] > 0 } { - uplevel $stack_depth "$folder_add_proc $cumulative_path $folder_id" - } - } else { - if { [string length $folder_unchanged_proc] > 0 } { - uplevel $stack_depth "$folder_unchanged_proc $cumulative_path $folder_id" - } - } - set path_exists($cumulative_path) $folder_id - db_dml insert_path { - insert into sp_extant_folders (session_id,folder_id) - values (:sync_session_id,:folder_id) - } + set cumulative_path "" + set parent_folder_id $root_folder_id + foreach directory $path { + append cumulative_path "$directory/" + if (![info exists path_exists($cumulative_path)]) { + # check db + set folder_id [db_string get_folder_id { + select nvl(content_item.get_id(:cumulative_path,:root_folder_id),0) + from dual + }] + # If the folder doesn't exist, create it. + if { $folder_id == 0} { + set folder_id [db_exec_plsql create_new_folder {}] + if { [string length $folder_add_proc] > 0 } { + uplevel $stack_depth "$folder_add_proc $cumulative_path $folder_id" + } + } else { + if { [string length $folder_unchanged_proc] > 0 } { + uplevel $stack_depth "$folder_unchanged_proc $cumulative_path $folder_id" + } + } + set path_exists($cumulative_path) $folder_id + db_dml insert_path { + insert into sp_extant_folders (session_id,folder_id) + values (:sync_session_id,:folder_id) + } - } else { - set folder_id $path_exists($cumulative_path) - } - set parent_folder_id $folder_id - } + } else { + set folder_id $path_exists($cumulative_path) + } + set parent_folder_id $folder_id + } - # If the file is already in the db: - # Fetch it from the db and load the file from the filesystem - # If they differ: - # Insert the filesystem version into the db. - # If the file isn't in the db: - # Insert it. + # If the file is already in the db: + # Fetch it from the db and load the file from the filesystem + # If they differ: + # Insert the filesystem version into the db. + # If the file isn't in the db: + # Insert it. - # set sp_filename to the file path relative to the OpenACS - # install dir, this is what gets inserted into the db - DaveB - set sp_filename [sp_get_relative_file_path $file] - set mtime_from_fs [file mtime $file] + # set sp_filename to the file path relative to the OpenACS + # install dir, this is what gets inserted into the db - DaveB + set sp_filename [sp_get_relative_file_path $file] + set mtime_from_fs [file mtime $file] - if [db_0or1row check_db_for_page { - select static_page_id, mtime as mtime_from_db from static_pages - where filename = :sp_filename - }] { - - if { [catch { - set fp [open $file r] - set file_from_fs [read $fp] - close $fp - } errmsg]} { + if [db_0or1row check_db_for_page { + select static_page_id, mtime as mtime_from_db from static_pages + where filename = :sp_filename + }] { + if { [catch { + set fp [open $file r] + set file_from_fs [read $fp] + close $fp + } errmsg]} { # Log and return an appropriate message, then # continue on trying to process the other files. # We do NOT want to abort the whole scan just @@ -374,69 +373,67 @@ set mesg "$proc_name: Error reading file: '$file': [ns_quotehtml $errmsg]" ns_log Error $mesg - if { ![empty_string_p $file_read_error_proc] } { + if { $file_read_error_proc ne "" } { uplevel $stack_depth [list $file_read_error_proc $file $static_page_id $mesg] } continue - } - - set file_updated 0 + } - set storage_type [db_string get_storage_type ""] + set file_updated 0 - switch $storage_type { - "file" { - if {$mtime_from_fs != $mtime_from_db} { - set file_updated 1 - } - } - - "lob" { - db_1row get_db_page { - select content as file_from_db from cr_revisions - where revision_id = content_item.get_live_revision(:static_page_id) - } - if {$file_from_db != $file_from_fs} { - set file_updated 1 - } - } - } - - if {$file_updated == 1} { - db_dml update_db_file { - update cr_revisions set content = empty_blob() - where revision_id = content_item.get_live_revision(:static_page_id) - returning content into :1 - } -blob_files [list $file] - if {$storage_type=="file"} { + set storage_type [db_string get_storage_type ""] - db_dml update_static_page { - update static_pages set mtime = :mtime_from_fs - where static_page_id = :static_page_id - } - } - if { [string length $file_change_proc] > 0 } { - uplevel $stack_depth "$file_change_proc $file $static_page_id" - } - } else { - if { [string length $file_unchanged_proc] > 0 } { - uplevel $stack_depth "$file_unchanged_proc $file $static_page_id" - } - } - db_dml insert_file { - insert into sp_extant_files (session_id,static_page_id) - values (:sync_session_id,:static_page_id) - } - } else { + switch $storage_type { + "file" { + if {$mtime_from_fs != $mtime_from_db} { + set file_updated 1 + } + } + "lob" { + db_1row get_db_page { + select content as file_from_db from cr_revisions + where revision_id = content_item.get_live_revision(:static_page_id) + } + if {$file_from_db != $file_from_fs} { + set file_updated 1 + } + } + } + + if {$file_updated == 1} { + db_dml update_db_file { + update cr_revisions set content = empty_blob() + where revision_id = content_item.get_live_revision(:static_page_id) + returning content into :1 + } -blob_files [list $file] + if {$storage_type=="file"} { + db_dml update_static_page { + update static_pages set mtime = :mtime_from_fs + where static_page_id = :static_page_id + } + } + if { [string length $file_change_proc] > 0 } { + uplevel $stack_depth "$file_change_proc $file $static_page_id" + } + } else { + if { [string length $file_unchanged_proc] > 0 } { + uplevel $stack_depth "$file_unchanged_proc $file $static_page_id" + } + } + db_dml insert_file { + insert into sp_extant_files (session_id,static_page_id) + values (:sync_session_id,:static_page_id) + } + } else { # The file is NOT in the db yet at all: set static_page_id {} - # Try to extract a title: - if { [catch { - set fp [open $file r] - set file_contents [read $fp] - close $fp - } errmsg]} { + # Try to extract a title: + if { [catch { + set fp [open $file r] + set file_contents [read $fp] + close $fp + } errmsg]} { # Log and return an appropriate message, then # continue on trying to process the other files. # We do NOT want to abort the whole scan just @@ -445,24 +442,24 @@ set mesg "$proc_name: Error reading file: '$file': [ns_quotehtml $errmsg]" ns_log Error $mesg - if { ![empty_string_p $file_read_error_proc] } { + if { $file_read_error_proc ne "" } { uplevel $stack_depth [list $file_read_error_proc $file $static_page_id $mesg] } continue - } + } # TODO: This is very HTML specific: --atp@piskorski.com, 2001/08/13 21:58 EDT - if { ![regexp -nocase {
Given a package key, return a URL of a mounted
- package instance. If there is more than one instance
- of the package mounted, the one with the lowest
- package_id
will be returned. If the
- package is not instantiated or not mounted anywhere,
- an error is raised. The proc is meant to be memoized.
-
Given a package key, return a URL of a mounted
+ package instance. If there is more than one instance
+ of the package mounted, the one with the lowest
+ package_id
will be returned. If the
+ package is not instantiated or not mounted anywhere,
+ an error is raised. The proc is meant to be memoized.
+