Index: openacs-4/packages/acs-admin/www/apm/file-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/Attic/file-add.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-admin/www/apm/file-add.tcl 10 Sep 2002 22:21:59 -0000 1.4 +++ openacs-4/packages/acs-admin/www/apm/file-add.tcl 19 Dec 2002 16:06:59 -0000 1.5 @@ -1,106 +1,105 @@ -ad_page_contract { - Allows the user to add files to a package. - @param version_id The identifier for the package. - @author Jon Salz (jsalz@arsdigita.com) - @creation-date 17 April 2000 +ad_page_contract { + Allows the user to add files to a package. + @param version_id The identifier for the package. + @author Jon Salz (jsalz@arsdigita.com) + @creation-date 17 April 2000 @cvs-id $Id$ -} { - {version_id:integer} - {verbose:integer 0} -} - -apm_version_info $version_id - -doc_body_append "[apm_header -form "method=post action=\"file-add-2\"" [list "version-view?version_id=$version_id" "$pretty_name $version_name"] [list "version-files?version_id=$version_id" "Files"] "Add Files"] - -[export_form_vars version_id] - -
- -" - -doc_body_flush - -# Obtain a list of all files registered to the package already. -array set registered_files [list] -foreach file [db_list apm_file_paths { - select path from apm_package_files where version_id = :version_id -}] { - set registered_files($file) 1 -} - -db_release_unused_handles - -# processed_files is a list of sublists, each of which contains -# the path of a file and its file type. -set processed_files [list] -set counter 0 -set registered 0 - -foreach file [lsort [ad_find_all_files -check_file_func apm_include_file_p [acs_package_root_dir $package_key]]] { - set relative_path [ad_make_relative_path $file] - - # Now kill "packages" and the package_key from the path. - set components [split $relative_path "/"] - set relative_path [join [lrange $components 2 [llength $components]] "/"] - - if { [info exists registered_files($relative_path)] } { - incr registered - if { $verbose } { - doc_body_append "\n" - } - } else { - set type [apm_guess_file_type $package_key $relative_path] - set db_type [apm_guess_db_type $package_key $relative_path] - doc_body_append "\n" - lappend processed_files [list $relative_path $type $db_type] - } - incr counter -} - -db_release_unused_handles -# Transport the list of files to the next page. -doc_body_append [export_form_vars processed_files] - -if { $counter == 0 } { - doc_body_append "
$relative_path (already registered to this package)
 $relative_path: [apm_pretty_name_for_file_type $type]" - if { ![empty_string_p $db_type] } { - doc_body_append " ([apm_pretty_name_for_db_type $db_type])" - } - doc_body_append "
There are no files in the packages/$package_key directory.
" -} elseif { [llength $processed_files] > 0 } { - doc_body_append " - -
-\[ check all | -uncheck all \] -
- -
- -" -} else { - doc_body_append "
There are no additional files to add to the package." -} - -if { $registered < 1 } { - doc_body_append "

No registered files exist" -} else { - if { $verbose } { - doc_body_append "

$registered registered files hide them" - } else { - doc_body_append "

$registered registered files hidden display them" - } -} - -doc_body_append "

\n[ad_footer]\n" - +} { + {version_id:integer} + {verbose:integer 0} +} + +apm_version_info $version_id + +doc_body_append "[apm_header -form "method=post action=\"file-add-2\"" [list "version-view?version_id=$version_id" "$pretty_name $version_name"] [list "version-files?version_id=$version_id" "Files"] "Add Files"] + +[export_form_vars version_id] + +
+ +" + +doc_body_flush + +# Obtain a list of all files registered to the package already. +array set registered_files [list] +foreach file [db_list apm_file_paths { + select path from apm_package_files where version_id = :version_id +}] { + set registered_files($file) 1 +} + +db_release_unused_handles + +# processed_files is a list of sublists, each of which contains +# the path of a file and its file type. +set processed_files [list] +set counter 0 +set registered 0 + +foreach file [lsort [ad_find_all_files -check_file_func apm_include_file_p [acs_package_root_dir $package_key]]] { + set relative_path [ad_make_relative_path $file] + + # Now kill "packages" and the package_key from the path. + set components [split $relative_path "/"] + set relative_path [join [lrange $components 2 [llength $components]] "/"] + + if { [info exists registered_files($relative_path)] } { + incr registered + if { $verbose } { + doc_body_append "\n" + } + } else { + set type [apm_guess_file_type $package_key $relative_path] + set db_type [apm_guess_db_type $package_key $relative_path] + doc_body_append "\n" + lappend processed_files [list $relative_path $type $db_type] + } + incr counter +} + +db_release_unused_handles +# Transport the list of files to the next page. +doc_body_append [export_form_vars processed_files] + +if { $counter == 0 } { + doc_body_append "
$relative_path (already registered to this package)
 $relative_path: [apm_pretty_name_for_file_type $type]" + if { ![empty_string_p $db_type] } { + doc_body_append " ([apm_pretty_name_for_db_type $db_type])" + } + doc_body_append "
There are no files in the packages/$package_key directory.
" +} elseif { [llength $processed_files] > 0 } { + doc_body_append " + +
+\[ check all | +uncheck all \] +
+ +
+ +" +} else { + doc_body_append "
There are no additional files to add to the package." +} + +if { $registered < 1 } { + doc_body_append "

No registered files exist" +} else { + if { $verbose } { + doc_body_append "

$registered registered files hide them" + } else { + doc_body_append "

$registered registered files hidden display them" + } +} + +doc_body_append "

\n[ad_footer]\n" Index: openacs-4/packages/acs-admin/www/apm/packages-install-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/packages-install-3.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-admin/www/apm/packages-install-3.tcl 18 Sep 2002 15:47:15 -0000 1.4 +++ openacs-4/packages/acs-admin/www/apm/packages-install-3.tcl 19 Dec 2002 16:06:59 -0000 1.5 @@ -20,7 +20,8 @@
" -set file_list [list] +set sql_file_list [list] +set catalog_file_list [list] set file_count 0 foreach pkg_info $pkg_install_list { @@ -48,7 +49,7 @@ set table_rows "" set data_model_files [apm_data_model_scripts_find -upgrade_from_version_name \ $initial_version_name -upgrade_to_version_name $final_version_name $package_key $version(files)] - set file_list [concat $file_list $data_model_files] + set sql_file_list [concat $sql_file_list $data_model_files] if {![empty_string_p $data_model_files]} { foreach file $data_model_files { set path [lindex $file 0] @@ -73,11 +74,16 @@ $table_rows

" } + + # I18N: Get the list of message catalog files to source + set catalog_file_list [concat $catalog_file_list [apm_message_catalog_files_find $package_key $version(files)]] } -ad_set_client_property -clob t apm sql_file_paths $file_list +ad_set_client_property -clob t apm sql_file_paths $sql_file_list -if {[empty_string_p $file_list]} { +ad_set_client_property -clob t apm catalog_file_paths $catalog_file_list + +if {[empty_string_p $sql_file_list]} { ad_returnredirect packages-install-4 ad_script_abort } Index: openacs-4/packages/acs-admin/www/apm/packages-install-4.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/packages-install-4.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-admin/www/apm/packages-install-4.tcl 13 Mar 2001 22:59:26 -0000 1.1 +++ openacs-4/packages/acs-admin/www/apm/packages-install-4.tcl 19 Dec 2002 16:06:59 -0000 1.2 @@ -12,6 +12,7 @@ set pkg_install_list [ad_get_client_property apm pkg_install_list] set pkg_enable_list [ad_get_client_property apm pkg_enable_list] set sql_file_paths [ad_get_client_property apm sql_file_paths] +set catalog_file_paths [ad_get_client_property apm catalog_file_paths] set install_path [ad_get_client_property apm install_path] set copy_files_p [ad_get_client_property apm copy_files_p] @@ -56,20 +57,31 @@ lappend data_model_files $file } } - + + set message_catalog_files [list] + # Find the message catalog files for the package + foreach file $catalog_file_paths { + if { [string equal [lindex $file 1] $package_key] } { + # We only need a list of file paths relative to package root + lappend message_catalog_files [lindex $file 0] + } + } + # Install the packages. ns_log Debug "APM: Installing packages from $install_path." if {$copy_files_p} { set version_id [apm_package_install -install_path $install_path \ -callback apm_ns_write_callback -copy_files -load_data_model \ - -data_model_files $data_model_files $spec_file] + -data_model_files $data_model_files -message_catalog_files $message_catalog_files \ + $spec_file] if {$version_id != 0} { file delete -force $install_path/$package_key } } else { set version_id [apm_package_install -install_path $install_path \ -callback apm_ns_write_callback -load_data_model \ - -data_model_files $data_model_files $spec_file] + -data_model_files $data_model_files -message_catalog_files $message_catalog_files \ + $spec_file] } if { ($version_id != 0) && ([lsearch -exact $pkg_enable_list $package_key] != -1) } { apm_version_enable -callback apm_ns_write_callback $version_id Index: openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/00-database-procs.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 30 Nov 2002 17:23:55 -0000 1.20 +++ openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 19 Dec 2002 16:09:50 -0000 1.21 @@ -441,6 +441,7 @@ -local:boolean -append:boolean {-extend {}} + {-upvar_level 1} var_name statement_name sql @@ -471,8 +472,9 @@

If the -local is passed, the variables defined by db_multirow will be set locally (useful if you're compiling dynamic templates - in a function or similar situations). - + in a function or similar situations). By default the multirow will be set + one level up but you can specify the number of levels up you want it set with the + upvar_level switch.

You may supply a code block, which will be executed for each row in @@ -526,7 +528,7 @@ set full_statement_name [db_qd_get_fullname $statement_name] if { $local_p } { - set level_up 1 + set level_up $upvar_level } else { set level_up \#[template::adp_level] } Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 4 Dec 2002 19:32:18 -0000 1.16 +++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.tcl 19 Dec 2002 16:09:50 -0000 1.17 @@ -288,18 +288,42 @@ return [list 1 $install_in] } +ad_proc -private apm_load_catalog_files { + -upgrade:boolean + package_key + message_catalog_files +} { + Load catalog files for a package that is either installed or upgraded. + If the package is upgraded message key upgrade status is reset before + loading the files. + @author Peter Marklund +} { + if { $upgrade_p } { + # Reset the upgrade status of message catalog keys before we load the catalog files + lang::catalog::reset_upgrade_status_message_keys $package_key + } + + # Load message catalog files + foreach catalog_rel_path $message_catalog_files { + lang::catalog::import_messages_from_file "[acs_package_root_dir $package_key]/${catalog_rel_path}" + } +} + + ad_proc -private apm_package_install { {-callback apm_dummy_callback} {-copy_files:boolean} {-load_data_model:boolean} {-data_model_files 0} + {-message_catalog_files {}} {-install_path ""} spec_file_path } { Registers a new package and/or version in the database, returning the version_id. If $callback is provided, periodically invokes this procedure with a single argument containing a human-readable (English) status message. + @param spec_file_path The path to an XML .info file relative to @return The version_id if successfully installed, 0 otherwise. } { @@ -339,11 +363,12 @@ set vendor_uri $version(vendor.url) set split_path [split $spec_file_path /] set relative_path [join [lreplace $split_path 0 [lsearch -exact $package_key $split_path]] /] + # Register the package if it is not already registered. if { ![apm_package_registered_p $package_key] } { apm_package_register $package_key $package_name $pretty_plural $package_uri $package_type $initial_install_p $singleton_p $relative_path } - + # If an older version already exists in apm_package_versions, update it; # otherwise, insert a new version. if { [db_0or1row version_exists_p { @@ -352,11 +377,22 @@ where package_key = :package_key and version_id = apm_package.highest_version(:package_key) } ]} { + # We are upgrading a package + + # Load catalog files with upgrade switch before package version is changed in db + apm_load_catalog_files -upgrade $package_key $message_catalog_files + set version_id [apm_package_install_version -callback $callback $package_key $version_name \ $version_uri $summary $description $description_format $vendor $vendor_uri $release_date] apm_version_upgrade $version_id apm_package_upgrade_parameters -callback $callback $version(parameters) $package_key + } else { + # We are installing a new package + + # Load catalog files without the upgrade switch before package version is changed in db + apm_load_catalog_files -upgrade $package_key $message_catalog_files + set version_id [apm_package_install_version -callback $callback $package_key $version_name \ $version_uri $summary $description $description_format $vendor $vendor_uri $release_date] @@ -369,6 +405,7 @@ # Install the paramters for the version. apm_package_install_parameters -callback $callback $version(parameters) $package_key } + # Update all other package information. apm_package_install_dependencies -callback $callback $version(provides) $version(requires) $version_id apm_package_install_owners -callback $callback $version(owners) $version_id @@ -1111,6 +1148,32 @@ } } +ad_proc -private apm_message_catalog_files_find { package_key file_list } { + Given a list of files belonging to a certain package, return those + files that are message catalog files. Note that the input list and the + list returned have items on different formats, see the parameter documentation. + + @param package_key The package_key of the files + @param file_list A list of file items on format [list path file_type file_db_type] + @return A list of message catalog file items on format [list path package_key] + + @see apm_data_model_scripts_find + @author Peter Marklund +} { + set catalog_file_list [list] + + foreach file_info $file_list { + + set file_path [lindex $file_info 0] + set file_type [lindex $file_info 1] + if { [string equal [apm_guess_file_type $package_key $file_path] "message_catalog"] } { + lappend catalog_file_list $file_info [list $file_path $package_key] + } + } + + return $catalog_file_list +} + ad_proc -private apm_data_model_scripts_find { {-upgrade_from_version_name ""} {-upgrade_to_version_name ""}