Index: openacs-4/packages/ecommerce/lib/product-files-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/lib/product-files-list.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/lib/product-files-list.adp 8 Aug 2008 12:12:30 -0000 1.1 @@ -0,0 +1,4 @@ + +

Downloadable product file@pretty_files@

+@product_files_list;noquote@ +
Index: openacs-4/packages/ecommerce/lib/product-files-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/lib/product-files-list.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ecommerce/lib/product-files-list.tcl 8 Aug 2008 12:12:30 -0000 1.1 @@ -0,0 +1,57 @@ +# requires: product_id + +# shows a product's supporting files, blank if there are none + + set product_files_list "" + set file_count 0 + set pretty_files "" + set product_files "" + set adobe_reader_blurb 0 + set dirname [db_string dirname_select "select dirname from ec_products where product_id=$product_id"] + + # make sure there are no /'s in dirname + if { [regexp {/} $dirname] } { + ns_log Error "ecommerce/lib/product-files-list: Invalid dirname: $dirname" + } + + if { ![empty_string_p $dirname] } { + set subdirectory [ec_product_file_directory $product_id] + + set full_dirname "[ec_data_directory][ec_product_directory]$subdirectory/$dirname" + + # see what's in that directory + set file_list [glob -nocomplain -directory $full_dirname *] + + foreach file_name $file_list { + set file_size [file size $file_name] + set file_size_kb [format "%6.1f" [expr { $file_size / 1024 }]] + set file [lindex [file split $file_name] end] + if { [string match {product.[jg][pi][gf]} $file] } { + # do not show it + } elseif { [string match {product-*.jpg} $file] } { + # do not show it + } else { + append product_files "
  • $file (${file_size_kb}kb " + incr file_count + if { [string match -nocase {*.pdf} $file] } { + append product_files "Acrobat file" + set adobe_reader_blurb 1 + } + + append product_files ")
  • " + } + } + } + + if { $file_count > 1 } { + set pretty_files "s" + } + if { [string length ${product_files}] > 0 } { + set product_files_list "" + if { $adobe_reader_blurb eq 1 } { + append product_files_list "

    After downloading, Acrobat (.pdf) files can + be viewed and printed using the free Adobe Acrobat Reader. If you do not have it, + .

    " + } + } +