# $Id: theme.itcl,v 1.2 2005/08/03 06:02:46 davidlallen Exp $ # Updated to save to update the confguration file proc action_gallery {chan path env} { global source_dir if {[string index $path 0] == "/"} { set parsedPath [split $path {/}] set fsid [lindex $parsedPath 1] if { $fsid == "import" } { puts $chan [html_start "JPG Imported"] gallery_import $chan [join [lrange $parsedPath 2 end] {/}] $env puts $chan [html_end] return } } set style { } puts $chan [html_start "Gallery Browser" "" $style] puts $chan {
" puts $chan "

" puts $chan [html_link "/gallery/import" "Load a new image"] puts $chan [html_end] } proc gallery_import {chan path env} { global source_dir set submit "" eval $env if {$submit == "Import"} { if {$file == ""} { puts $chan "Error: No File Specified" } else { set filepath "$source_dir/uploads/$file" if { [catch { set fsize [file size $filepath] }] == 1} { puts $chan "Error Opening File" } elseif {[string tolower [file extension $filepath]] != ".jpg"} { puts $chan "Error: File must end in .jpg" file delete $filepath } elseif {$fsize == 0} { puts $chan "Error: File Empty" file delete $filepath } else { if {[file extension $filepath] == ".JPG"} { set oldpath $filepath set filepath "[file rootname $oldpath].jpg" if {[catch {file rename $oldpath $filepath}]} { puts $chan "Error Renaming File

" file delete $oldpath } } if { [catch {file rename $filepath "$source_dir/images/Gallery"}] == 1} { puts $chan "Error Moving File

" file delete $filepath } else { puts $chan "Successfully Loaded Image

" } } } } else { puts $chan [html_form_start "POST" "/gallery/import/" "enctype='multipart/form-data'"] puts $chan "Images must be in JPEG format with a .jpg extension.
" puts $chan [html_table_start "" "" ""] puts $chan [tr "" [td "Image File"] [td [html_form_input {file" accept="image/jpeg" size="48} "file" ""]]] puts $chan [html_table_end] puts $chan [html_form_input "submit" "submit" "Import"] puts $chan [html_form_end] } puts $chan "
" puts $chan [html_link "/gallery" "Back to Gallery"] } register_module "gallery" "Gallery" "View the image gallery"