Index: openacs-4/packages/ecommerce/tcl/ecommerce-utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/tcl/ecommerce-utilities-procs.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/ecommerce/tcl/ecommerce-utilities-procs.tcl 15 Mar 2004 04:28:01 -0000 1.14 +++ openacs-4/packages/ecommerce/tcl/ecommerce-utilities-procs.tcl 13 Jan 2005 13:57:56 -0000 1.15 @@ -141,13 +141,18 @@ } { Get Custom Form Element. } { - if { $column_type == "integer" || $column_type == "number"} { + if { [string equal $column_type "integer"] || [string equal $column_type "number"] } { return "" - } elseif { $column_type == "date" } { - return [ad_dateentrywidget ec_custom_fields.$field_identifier $default_value] - } elseif { $column_type == "varchar(200)" } { + } elseif { [string equal $column_type "date"] } { + return "[ad_dateentrywidget ec_custom_fields.$field_identifier $default_value]" + } elseif { [string equal $column_type "timestamp"] } { + # timestamp is in form yyyy-mm-dd hh:mm:ss + # so ec_timeentrywidget could be added here for lindex default_values 1 + set default_values [split $default_value " "] + return "[ad_dateentrywidget ec_custom_fields.$field_identifier [lindex $default_values 0]]" + } elseif { [string equal $column_type "varchar(200)"] } { return "" - } elseif { $column_type == "varchar(4000)" } { + } elseif { [string equal $column_type "varchar(4000)"] } { return "" } else { @@ -302,7 +307,7 @@ set linked_thumbnail "" if { $border_p == "f" } { - set border_part_of_img_tag " border=0 " + set border_part_of_img_tag " border=\"0\" " } else { set border_part_of_img_tag "" } @@ -326,20 +331,14 @@ if { [file exists "$full_dirname/product.jpg"] } { set linked_thumbnail " - - \"Product - " + \"Product" } elseif { [file exists "$full_dirname/product.gif"] } { set linked_thumbnail " - - \"Product - " + \"Product" } } else { set linked_thumbnail " - - \"Product - " + \"Product" } } return $linked_thumbnail @@ -489,7 +488,7 @@ if { ![empty_string_p $user_id] } { set user_name [db_string get_user_name " - select first_names || ' ' || last_name + select first_names || ' ' || last_name from cc_users where user_id=:user_id"] return "Registered user: $user_name." @@ -564,6 +563,9 @@ be in the format YYYY-MM-DD HH24:MI:SS-TZ. } { + # temporary cludge to get this to work with postgresql timestamp with microseconds + # eventually all ecommerce dates should use lc_time_fmt for i8ln + set ugly_date [lc_time_fmt $ugly_date "%F %T"] # Remove the timezone (-TZ) from ugly_date or clock scan will # choke on it. @@ -587,6 +589,10 @@ } { + # temporary cludge to get this to work with postgresql timestamp with microseconds + # eventually all ecommerce dates should use lc_time_fmt for i8ln + set ugly_date [lc_time_fmt $ugly_date "%F %T"] + # Remove the timezone information (-TZ) that PostgresSQL can # return or the Tcl command 'clock scan' will choke on it. @@ -608,9 +614,12 @@ } { set sql " - select state_code, city_name, county_name - from zip_codes - where zip_code=:zip_code" + select s.abbrev as state_code, z.name as city_name, c.name as county_name + from us_zipcodes z, us_states s, us_counties c + where z.fips_state_code = s.fips_state_code and + z.fips_county_code = c.fips_county_code and + z.fips_state_code = c.fips_state_code and + z.zipcode=:zip_code" set city_list [list] if { [catch { @@ -1102,3 +1111,55 @@ } return $product_link } +ad_proc ec_capitalize_words { + string_of_words +} { + Capitalizes first letter of each word, makes rest lowercase +} { + set word_list [split $string_of_words] + set entitled_list "" + foreach word $word_list { + lappend entitled_list [string totitle $word] + } + set entitled_words [join $entitled_list] + return $entitled_words +} + +ad_proc ec_thumbnail_if_it_exists { + dirname + {border_p "t"} + {image_title "item view"} +} { + + This looks at dirname to see if the thumbnail is there and if + so returns an html fragment to show thumbnail + Otherwise it returns the empty string. + +} { + + set thumbnail "" + + if { $border_p == "f" } { + set border_part_of_img_tag " border=\"0\" " + } else { + set border_part_of_img_tag "" + } + + # See if there's an image file (and thumbnail) + # Get the directory where dirname is stored + + regsub -all {[a-zA-Z]} $dirname "" product_id + set subdirectory [ec_product_file_directory $product_id] + set file_path "$subdirectory/$dirname" + set product_data_directory "[ec_data_directory][ec_product_directory]" + + set full_dirname "$product_data_directory$file_path" + + if { [file exists "$full_dirname/product-thumbnail.jpg"] } { + set thumbnail_size [ns_jpegsize "$full_dirname/product-thumbnail.jpg"] + + set thumbnail "" + + } + return $thumbnail +}