Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.adp,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.adp 17 Oct 2006 23:21:50 -0000 1.8 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.adp 21 Dec 2006 15:12:39 -0000 1.9 @@ -1,4 +1,4 @@ - + #acs-templating.HTMLArea_InsertFileTitle# @@ -90,14 +90,15 @@ -
+ - + - +
+ +
@@ -106,7 +107,7 @@
- Choose File + #acs-templating.Choose_File#
@formgroup.widget;noquote@ @formgroup.label;noquote@ @@ -119,6 +120,7 @@
@@ -127,7 +129,7 @@
- or Upload a New File + #acs-templating.Upload_a_New_File# #acs-templating.Link_Title#
@@ -144,6 +146,7 @@
[i] #acs-templating.This_file_can_be_reused_help# +
@formerror.share@
Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl 20 Oct 2006 17:47:57 -0000 1.9 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl 21 Dec 2006 15:12:39 -0000 1.10 @@ -8,9 +8,13 @@ @cvs-id $Id$ } { {parent_id:integer} + {package_id:integer} {selector_type "file"} } +#HAM : ajax sources +set js_source [ah::js_sources] + set user_id [ad_conn user_id] # if user has write permission, create image upload form, set write_p [permission::permission_p \ @@ -21,7 +25,7 @@ # item might not exist! set write_p [permission::permission_p \ -party_id $user_id \ - -object_id [ad_conn package_id] \ + -object_id $package_id \ -privilege "write"] } if {$write_p} { @@ -54,11 +58,12 @@ -html { enctype multipart/form-data } \ -form { item_id:key + {package_id:text(hidden)} {f_title:text,optional {label "[_ acs-templating.Link_Text]"} {html {size 50 id f_title} } } {choose_file:text(radio),optional {options $recent_files_options}} {upload_file:file(file) {html {size 30}} } {share:text(radio),optional {label "[_ acs-templating.This_file_can_be_reused_by]"} {options $share_options} {help_text "[_ acs-templating.This_file_can_be_reused_help]"}} - {select_btn:text(submit) {label "Select"}} + {select_btn:text(submit) {label "[_ acs-templating.Add_the_selected_file]"}} {ok_btn:text(submit) {label "[_ acs-templating.HTMLArea_SelectUploadBtn]"} } } \ @@ -165,6 +170,8 @@ } else { set item_id $choose_file set file_name [lindex [lindex $recent_files_options [util_search_list_of_lists $recent_files_options $item_id 1]] 0] + # we have to get rid of the icon from the form. + set file_name [regsub -all {<.*?>} $file_name {}] } if {$f_title eq ""} { Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.adp,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.adp 10 Oct 2006 14:27:00 -0000 1.5 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.adp 21 Dec 2006 15:12:39 -0000 1.6 @@ -1,12 +1,11 @@ - + - #acs-templating.HTMLArea_InsertImageTitle# +#acs-templating.HTMLArea_InsertImageTitle# - - - + + +@js_source;noquote@ + +
- + +
-
+ @HTML_UploadTitle@ - - +
+ - @@ -181,8 +286,9 @@
+ + + + + +
- Choose Image - -
- - @formgroup.widget;noquote@ -
-
-   + #acs-templating.Choose_Image# + + + + +
+
+ +
+ + +
+ +
+ + +
+   +
- or Upload a New Image + #acs-templating.Upload_a_New_Image# +
@formerror.upload_file@
@@ -197,7 +303,7 @@
@formerror.share@
  -
+
Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.tcl 10 Oct 2006 14:27:00 -0000 1.6 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.tcl 21 Dec 2006 15:12:39 -0000 1.7 @@ -8,19 +8,35 @@ @cvs-id $Id$ } { {parent_id:integer} + {package_id:integer} {selector_type "image"} } +#HAM : ajax sources +set js_source [ah::js_sources] + set f_url "" set user_id [ad_conn user_id] + # if user has write permission, create image upload form, -if {[permission::permission_p -party_id $user_id -object_id $parent_id \ - -privilege "write"]} { - set write_p 1 +set write_p [permission::permission_p \ + -party_id $user_id \ + -object_id $parent_id \ + -privilege "write"] +if {!$write_p} { + # item might not exist! + set write_p [permission::permission_p \ + -party_id $user_id \ + -object_id $package_id \ + -privilege "write"] +} - set recent_images_options [list] +set recent_images_options [list] + +if {$write_p} { + # set recent images db_multirow -unclobber recent_images recent_images \ { select ci.item_id, ci.name @@ -38,23 +54,27 @@ } + set share_options [list [list "[_ acs-templating.Only_myself]" private] [list "[_ acs-templating.This_Group]" group] [list "[_ acs-templating.Anyone_on_this_system]" site] [list "[_ acs-templating.Anyone_on_the_internet]" public]] + ad_form \ -name upload_form \ -mode edit \ -export {selector_type file_types parent_id} \ -html { enctype multipart/form-data } \ -form { item_id:key + {package_id:text(hidden)} {choose_file:text(radio),optional {options $recent_images_options}} {upload_file:file(file),optional {html {size 30}} } {share:text(radio),optional {label "[_ acs-templating.This_image_can_be_reused_by]"} {options $share_options} {help_text "[_ acs-templating.This_image_can_be_reused_help]"}} - {select_btn:text(submit) {label "Select"}} + {select_btn:text(submit) {label "[_ acs-templating.Add_the_selected_image]"}} {upload_btn:text(submit) {label "[_ acs-templating.HTMLArea_SelectUploadBtn]"} } } \ -on_request { set share site + set package_id $package_id } \ -on_submit { # check file name @@ -111,7 +131,6 @@ -party_id $user_id \ -privilege admin - set f_url "/image/${item_id}/${file_name}" switch -- $share { private { permission::set_not_inherit -object_id $item_id @@ -144,15 +163,14 @@ } else { # user chose an existing file set item_id $choose_file - set file_name "" + set file_name [lindex [lindex $recent_images_options [util_search_list_of_lists $recent_images_options $item_id 1]] 0] } - - + set f_url "/image/${item_id}/${file_name}" } } else { set write_p 0 } set HTML_Preview "Preview" -set HTML_UploadTitle "" \ No newline at end of file +set HTML_UploadTitle ""