Index: openacs-4/packages/lorsm/tcl/lorsm-import-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/tcl/lorsm-import-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/lorsm/tcl/lorsm-import-procs.tcl 16 Feb 2009 00:24:54 -0000 1.7 +++ openacs-4/packages/lorsm/tcl/lorsm-import-procs.tcl 2 Nov 2010 11:06:58 -0000 1.8 @@ -146,12 +146,22 @@ ## Gets manifest title if { ![empty_string_p $metadata] } { # gets metadataschema - set MetadataSchema [lindex [lindex [lors::imsmd::getMDSchema $metadata] 0] 0] - set MetadataSchemaVersion [lindex [lors::imsmd::getMDSchema $metadata] 1] - set lom [lindex [lors::imsmd::getLOM $metadata $tmp_dir] 0] - set prefix [lindex [lors::imsmd::getLOM $metadata $tmp_dir] 1] + set md_results [lors::imsmd::getMDSchema $metadata] + set MetadataSchema [lindex [lindex $md_results 0] 0] + set MetadataSchemaVersion [lindex $md_results 1] - if { $lom != 0 } { + set lom_results [lors::imsmd::getLOM $metadata $tmp_dir] + + if { $lom_results ne 0 } { + set type [lindex $lom_results 0] + set prefix [lindex $lom_results 2] + if { $type eq "XML" } { + set doc [dom parse [lindex $lom_results 1]] + set lom [$doc documentElement] + } else { + set lom [lindex $lom_results 1] + } + # Get title set manifest_title_lang [lindex \ [lindex [lors::imsmd::mdGeneral \ @@ -449,9 +459,18 @@ ## Gets manifest title if { ![empty_string_p $metadata] } { - set lom [lindex [lors::imsmd::getLOM $metadata $tmp_dir] 0] - set prefix [lindex [lors::imsmd::getLOM $metadata $tmp_dir] 1] - if { $lom != 0 } { + set lom_results [lors::imsmd::getLOM $metadata $tmp_dir] + + if { $lom_results ne 0 } { + set type [lindex $lom_results 0] + set prefix [lindex $lom_results 2] + if { $type eq "XML" } { + set doc [dom parse [lindex $lom_results 1]] + set lom [$doc documentElement] + } else { + set lom [lindex $lom_results 1] + } + # Get title set manifest_title_lang [lindex \ [lindex \ Index: openacs-4/packages/lorsm/www/admin/course-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/admin/course-add-2.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/lorsm/www/admin/course-add-2.tcl 12 Dec 2008 14:25:35 -0000 1.4 +++ openacs-4/packages/lorsm/www/admin/course-add-2.tcl 2 Nov 2010 11:06:58 -0000 1.5 @@ -199,10 +199,19 @@ [lindex [lors::imsmd::getMDSchema $metadata] 0] 0] set MetadataSchemaVersion [lindex [lors::imsmd::getMDSchema $metadata] 1] - set lom [lindex [lors::imsmd::getLOM $metadata $tmp_dir] 0] - set prefix [lindex [lors::imsmd::getLOM $metadata $tmp_dir] 1] - if { $lom != 0 } { + set lom_results [lors::imsmd::getLOM $metadata $tmp_dir] + + if { $lom_results ne 0 } { + set type [lindex $lom_results 0] + set prefix [lindex $lom_results 2] + if { $type eq "XML" } { + set lom_doc [dom parse [lindex $lom_results 1]] + set lom [$lom_doc documentElement] + } else { + set lom [lindex $lom_results 1] + } + # Get title set manifest_title_lang [lindex \ [lindex [lors::imsmd::mdGeneral \ Index: openacs-4/packages/lorsm/www/admin/course-add-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/admin/course-add-3.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/lorsm/www/admin/course-add-3.tcl 3 Mar 2009 22:40:40 -0000 1.14 +++ openacs-4/packages/lorsm/www/admin/course-add-3.tcl 2 Nov 2010 11:06:58 -0000 1.15 @@ -210,10 +210,18 @@ ## Gets manifest title if { $metadata ne "" } { - set lom [lindex [lors::imsmd::getLOM $metadata $tmp_dir] 0] - set prefix [lindex [lors::imsmd::getLOM $metadata $tmp_dir] 1] + set lom_results [lors::imsmd::getLOM $metadata $tmp_dir] - if { $lom != 0 } { + if { $lom_results ne 0 } { + set type [lindex $lom_results 0] + set prefix [lindex $lom_results 2] + if { $type eq "XML" } { + set lom_doc [dom parse [lindex $lom_results 1]] + set lom [$lom_doc documentElement] + } else { + set lom [lindex $lom_results 1] + } + # Get title set manifest_title_lang [lindex \ [lindex [lors::imsmd::mdGeneral \ @@ -479,44 +487,41 @@ foreach file $l_files { + # filename = href of the resource file + set filename [lindex $file 0] - set found_file [lsearch -all -regexp $all_files $filename] - if {[llength $found_file] > 1} { - # we are suppose to get only one element back, so we have - # to refine the search a bit more. - set found_file [lsearch -all -regexp \ - -exact $all_files $tmp_dir/$filename] - } + # all_files list structure is: + # 0:tmp_filename 1:mime_type 2:folder_id? 3:file_id + # 4:revision_id 5:cr_file 6:file_size - if {![empty_string_p $found_file]} { + set found_file [lsearch -all -regexp $all_files $filename] + + if { $found_file ne "" } { set file_id [lindex [lindex $all_files $found_file] 3] set file_rev_id [content::item::get_live_revision -item_id $file_id] set res_id [lindex $file 1] - set file_hasmetadata [lindex $file 2] + set file_metadata_node [lindex $file 2] regexp {([^/\\]+)$} $filename match filex - if {$file_hasmetadata != 0} { - set hasmetadata 1 - } else { - set hasmetadata 0 - } + set hasmetadata_p [expr { $file_metadata_node ne "0" }] set fileadd [lors::imscp::file_add \ -file_id $file_rev_id \ -res_id $res_id \ -pathtofile $filename \ -filename $filex \ - -hasmetadata $hasmetadata] + -hasmetadata $hasmetadata_p] ns_write "[_ lorsm.Adding_file_filex]
" - if {$file_hasmetadata != 0} { + if { $hasmetadata_p } { set add_file_metadata [lors::imsmd::addMetadata \ - -acs_object $file_id \ - -node $file_hasmetadata \ - -dir $tmp_dir] + -acs_object $file_id \ + -node $file_metadata_node \ + -dir $tmp_dir] + ns_write "[_ lorsm.lt_Adding_file_filex_met_1]
" } } @@ -525,6 +530,7 @@ # Delete temporary directory ns_write "[_ lorsm.lt_Deleting_temporary_fo]
" ns_log Debug "Delete temporary folder $tmp_dir" + lors::imscp::deltmpdir $tmp_dir ns_write "[_ lorsm.Done]
"