Index: openacs-4/packages/imsld/tcl/imsld-xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-xowiki-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/imsld/tcl/imsld-xowiki-procs.tcl 19 Dec 2008 18:57:01 -0000 1.3 +++ openacs-4/packages/imsld/tcl/imsld-xowiki-procs.tcl 17 Jun 2009 08:00:01 -0000 1.4 @@ -37,7 +37,37 @@ @error } { + upvar files_struct_list files_struct_list + # search the file and while doing so, create all the parent folders for that file (if they were not already creatd) + set found_p 0 + + # structx = directory loop, count_y and count_x are going to be used to update the files_structure_list + set structx $files_struct_list + set count_y 0 + while { [llength $structx] > 0 && $found_p == 0 } { + # for each directory + set dirx [lindex $structx 0] + set count_x 0 + # search in the dir contents + foreach contentsx [lindex $dirx 1] { + if { [lsearch -exact [string tolower $contentsx] [string tolower $complete_path]] >= 0 && [string eq [lindex $contentsx 1] $type] } { + # file found, see if the parent dir is created + set found_p 1 + # have we already created this file? + set found_id [lindex $contentsx 2] + set parent_id [lindex [lindex $dirx 0] 1] + break + } + incr count_x + } + if { !$found_p } { + # proceed only if the file hasn't been found, since we will use the counter later + incr count_y + set structx [lrange $structx 1 [expr [llength $structx] -1]] + } + } + set mime_type [cr_filename_to_mime_type $complete_path] set community_id [dotlrn_community::get_community_id] @@ -48,7 +78,7 @@ ::xowiki::Package initialize -package_id $package_id -url $xw_url -user_id [ad_conn user_id] - if { [string match "text/*" $mime_type] } { + if { $mime_type eq "text/html" || $mime_type eq "text/xml" } { set file [open $complete_path] set content [read $file] close $file @@ -93,6 +123,13 @@ $page save } } + # update file structure + if { $found_p } { + set file_list [list $complete_path file [$page item_id]] + set content_list [lreplace [lindex [lindex $files_struct_list $count_y] 1] $count_x $count_x $file_list] + set dir_list [list [lindex [lindex $files_struct_list $count_y] 0] $content_list] + set files_struct_list [lreplace $files_struct_list $count_y $count_y $dir_list] + } return [$page item_id] @@ -101,6 +138,7 @@ ad_proc -public imsld::xowiki::page_content { -item_id + -run_id } { @author Derick Leony (derick@inv.it.uc3m.es) @@ -113,8 +151,19 @@ @error } { set page [::xowiki::Package instantiate_page_from_id -item_id $item_id] - set result [$page render] + set result [$page render_content] + set manifest_identifier [db_string select_identifier { + select im.identifier + from imsld_cp_manifestsx im, imsld_cp_organizationsx io, imsld_imslds ii, imsld_runs ir + where ir.run_id = :run_id + and ir.imsld_id = ii.imsld_id + and ii.organization_id = io.item_id + and io.manifest_id = im.item_id + } -default ""] + + regsub {src="([^\"]*)"} $result "src=\"../xowiki/download/file/${manifest_identifier}/\\1\"" result + return $result }