Index: openacs-4/packages/lors-central/lib/content-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/lib/content-edit.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors-central/lib/content-edit.adp 17 May 2005 16:21:17 -0000 1.1 +++ openacs-4/packages/lors-central/lib/content-edit.adp 13 Apr 2007 23:26:24 -0000 1.2 @@ -1,4 +1,2 @@ - - - -@content_body@ \ No newline at end of file + + @content_body@ Index: openacs-4/packages/lors-central/lib/content-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/lib/content-edit.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors-central/lib/content-edit.tcl 17 May 2005 16:21:17 -0000 1.1 +++ openacs-4/packages/lors-central/lib/content-edit.tcl 13 Apr 2007 23:26:24 -0000 1.2 @@ -43,13 +43,32 @@ ad_form \ -name file_form \ - -export {res_id man_id file_id return_url} \ + -export {res_id man_id file_id return_url edit_p} \ + -html {enctype multipart/form-data} \ -form { {title:text(inform) {label "Title"}} {version_notes:text(inform) {label "Current Version Notes"}} {description:text(text),optional {label "Version Notes"}} - {content:richtext(richtext),optional {label "Content"} {html {rows 20 cols 60}} {htmlarea_p 1}} - {submission_p:text(hidden) {value 1}} + } + +if {$edit_p} { + ad_form \ + -extend -name file_form \ + -form { + {upload_file:file,optional {label "Upload a file:"} {html "size 30"} {after_html "

Or"}} + {content:richtext(richtext),optional {label "Edit the current content"} {html {rows 20 cols 60}} {htmlarea_p 1}} + } +} else { + ad_form \ + -extend -name file_form \ + -form { + {upload_file:file {label "File:"} {html "size 30"}} + } +} + +ad_form -extend -name file_form \ + -form { + {submission_p:text(hidden) {value 1}} } \ -on_request { set title $fs_object_info(name) @@ -59,54 +78,86 @@ set content [list [string trim $fs_object_info(content)] $fs_object_info(mime_type)] set return_url $return_url } -on_submit { - set content_body [template::util::richtext::get_property contents $content] - # Rebuild HTML if necessary - if { [regexp -nocase {^(.*<\s*?body[^>]*?>).*(.*)$} $fs_object_info(content) match header footer] } { - set content_body "${header}${content_body}${footer}" - } - - foreach {link id} [regexp -inline -all {.*?} $content_body] { - # ns_log notice "DAVEB link '${link}' id '${id}" - # find out if its an image - - if {[db_0or1row mime "select mime_type as this_mime_type, title as this_title from cr_revisions, cr_items where cr_items.item_id=:id and revision_id=live_revision"]} { - # ns_log notice "DAVEB mime_type '${this_mime_type}'" - if {[string match "image/*" $this_mime_type]} { - - regsub -all $link $content_body "" content_body - } else { - # FIXME for now just throw away non image links until we can do something intelligent with them! - regsub -all $link $content_body {} content_body - } - } - - } - - set mime_type [template::util::richtext::get_property format $content] set file_item_id [lors_central::get_item_id -revision_id $file_id] - # this is 99% the same as new-file, it _is_ a new file except its not uploaded set new_res_id [lors_central::add_resource_revision \ -res_id $res_id \ -name $title \ -user_id [ad_conn user_id] \ -man_id $man_id] - set new_file_id [lors_central::add_file_revision \ - -file_content $content_body \ - -mime_type $mime_type \ - -name $title \ - -title $title \ - -res_id $new_res_id \ - -man_id $man_id \ - -item_id $file_item_id] - + + if {$edit_p} { + if {$upload_file ne ""} { + set tmp_filename [template::util::file::get_property tmp_filename $upload_file] + set mime_type [template::util::file::get_property mime_type $upload_file] + + set fp [open $tmp_filename r] + set content_body [read $fp] + close $fp + + } else { + set content_body [template::util::richtext::get_property contents $content] + set mime_type [template::util::richtext::get_property format $content] + } + # Rebuild HTML if necessary + if { [regexp -nocase {^(.*<\s*?body[^>]*?>).*(.*)$} $fs_object_info(content) match header footer] } { + set content_body "${header}${content_body}${footer}" + } + foreach {link id} [regexp -inline -all {.*?} $content_body] { + # ns_log notice "DAVEB link '${link}' id '${id}" + # find out if its an image + + if {[db_0or1row mime "select mime_type as this_mime_type, title as this_title from cr_revisions, cr_items where cr_items.item_id=:id and revision_id=live_revision"]} { + # ns_log notice "DAVEB mime_type '${this_mime_type}'" + if {[string match "image/*" $this_mime_type]} { + + regsub -all $link $content_body "" content_body + } else { + # FIXME for now just throw away non image links until we can do something intelligent with them! + regsub -all $link $content_body {} content_body + } + } + + } + + # this is 99% the same as new-file, it _is_ a new file except its not uploaded + + set new_file_id [lors_central::add_file_revision \ + -file_content $content_body \ + -mime_type $mime_type \ + -name $title \ + -title $title \ + -res_id $new_res_id \ + -man_id $man_id \ + -item_id $file_item_id \ + -description $description] + } else { + + #Getting file info + set tmp_filename [template::util::file::get_property tmp_filename $upload_file] + set mime_type [template::util::file::get_property mime_type $upload_file] + + set new_file_id [lors_central::add_file_revision \ + -tmp_filename $tmp_filename \ + -mime_type $mime_type \ + -name $title \ + -title $title \ + -res_id $new_res_id \ + -man_id $man_id \ + -item_id $file_item_id \ + -description $description] + } + set exclude [db_list get_exclude "select revision_id from cr_revisions where item_id=:file_item_id"] - + lors_central::resource_carry_forward_files -old_res_id $res_id -new_res_id $new_res_id -exclude $exclude lors_central::res_update_items \ -old_res_id $res_id \ -new_res_id $new_res_id \ -user_id [ad_conn user_id] - + + #Updating version notes + + } -after_submit { ad_returnredirect $return_url Index: openacs-4/packages/lors-central/tcl/lors-central-cr-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/tcl/lors-central-cr-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors-central/tcl/lors-central-cr-procs.tcl 17 May 2005 16:21:18 -0000 1.1 +++ openacs-4/packages/lors-central/tcl/lors-central-cr-procs.tcl 13 Apr 2007 23:26:25 -0000 1.2 @@ -35,7 +35,7 @@ # insert file into the CR db_transaction { - set description "uploaded using LORs" + set description "uploaded using LORS-CENTRAL" # add file set file_id [content::item::new -name $title -parent_id $parent_id -creation_user $user_id \ Index: openacs-4/packages/lors-central/tcl/lors-central-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/tcl/lors-central-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/lors-central/tcl/lors-central-procs.tcl 31 May 2005 22:57:22 -0000 1.2 +++ openacs-4/packages/lors-central/tcl/lors-central-procs.tcl 13 Apr 2007 23:26:25 -0000 1.3 @@ -803,13 +803,14 @@ -item_id -man_id {-user_id ""} + {-description ""} } { - + } { - + set new_file_id [content::revision::new -item_id $item_id -title $title -creation_user $user_id \ - -mime_type $mime_type -is_live "f"] - + -mime_type $mime_type -is_live "f" -description $description] + # Now we store the content in the CR if {[exists_and_not_null tmp_filename]} { set cr_file [cr_create_content_file $item_id $new_file_id $tmp_filename] Index: openacs-4/packages/lors-central/www/edit-item-name.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/www/edit-item-name.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors-central/www/edit-item-name.adp 13 Apr 2007 23:26:25 -0000 1.1 @@ -0,0 +1,6 @@ + + @title@ + @context@ + + + Index: openacs-4/packages/lors-central/www/edit-item-name.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/www/edit-item-name.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors-central/www/edit-item-name.tcl 13 Apr 2007 23:26:25 -0000 1.1 @@ -0,0 +1,41 @@ +# + +ad_page_contract { + + Edit the name of a given ims_item_id + + @author Victor Guerra (guerra@galileo.edu) + @creation-date 2007-02-26 + @arch-tag: 96877018-3fb2-4faa-bba7-3b91f22b0d71 + @cvs-id $Id: edit-item-name.tcl,v 1.1 2007/04/13 23:26:25 victorg Exp $ +} { + {ims_item_id:integer,notnull} + {name ""} + {return_url:notnull} + {man_id:notnull} +} -properties { +} -validate { +} -errors { +} + +set title "" +set context [list $title] + +set return_url [export_vars -base $return_url {ims_item_id man_id}] + +ad_form -name edit_name -export { return_url man_id} -cancel_url "$return_url" -form { + {ims_item_id:key + {value $ims_item_id} + } + {name:text(text) + {label "Name:"} + {value $name} + } +} -edit_request { +} -on_submit { + #update name + db_dml update_name { *SQL* } + +} -after_submit { + ad_returnredirect $return_url +} \ No newline at end of file Index: openacs-4/packages/lors-central/www/edit-item-name.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/www/edit-item-name.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors-central/www/edit-item-name.xql 13 Apr 2007 23:26:25 -0000 1.1 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + update ims_cp_items set item_title = :name + where ims_item_id = :ims_item_id + + + + \ No newline at end of file Index: openacs-4/packages/lors-central/www/one-file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/www/one-file.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/lors-central/www/one-file.tcl 22 Jan 2007 08:09:25 -0000 1.4 +++ openacs-4/packages/lors-central/www/one-file.tcl 13 Apr 2007 23:26:25 -0000 1.5 @@ -44,6 +44,9 @@ -bulk_action_export_vars { } \ -row_pretty_plural "[_ lors-central.item_files]" \ -elements { + version_number { + label "[_ lors-central.version_number]" + } filename { label "[_ lors-central.filename]" display_template { @@ -55,6 +58,9 @@ } } + version_notes { + label "Notes" + } preview { display_template { @@ -67,9 +73,13 @@ } } -db_multirow -extend { mime_type prev_url } files get_file_info { } { +db_multirow -extend { mime_type prev_url version_notes version_number} files get_file_info { } { + set version_number [lors_central::get_revision_count -revision_id ] set mime_type [db_string get_mime_type { }] set prev_url [export_vars -base one-file {{file_id $fileid} res_id man_id ims_item_id}] + array set fs_object_info [lors_central::get_object_info -file_id $fileid] + set version_notes $fs_object_info(version_notes) + array unset fs_object_info } Index: openacs-4/packages/lors-central/www/one-learning-object.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/www/one-learning-object.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors-central/www/one-learning-object.adp 17 May 2005 16:21:19 -0000 1.1 +++ openacs-4/packages/lors-central/www/one-learning-object.adp 13 Apr 2007 23:26:25 -0000 1.2 @@ -3,7 +3,7 @@ @context;noquote@ @displayed_object_id@ -

@name@

+

@name@

#lors-central.All_views# Edit Metadata All Resources Index: openacs-4/packages/lors-central/www/one-learning-object.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors-central/www/one-learning-object.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/lors-central/www/one-learning-object.tcl 31 May 2005 22:57:22 -0000 1.2 +++ openacs-4/packages/lors-central/www/one-learning-object.tcl 13 Apr 2007 23:26:25 -0000 1.3 @@ -44,6 +44,9 @@ set name [db_string get_name { }] } +set return_url "[ad_conn url]" +set edit_name_url [export_vars -base edit-item-name {{ims_item_id $last_version} name return_url man_id}] + if { [string equal $file_revision 0] } { # The items is probably an URL so we are going to get it set item_file_revision [lors_central::get_item_url -ims_item_id $ims_item_id -man_id $man_id]