Index: openacs-4/packages/lorsm/www/delivery-no-index/view/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery-no-index/view/index.vuh,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lorsm/www/delivery-no-index/view/index.vuh 22 Apr 2005 09:10:55 -0000 1.1 +++ openacs-4/packages/lorsm/www/delivery-no-index/view/index.vuh 17 May 2005 21:48:05 -0000 1.2 @@ -12,14 +12,22 @@ ad_returnredirect [dotlrn_community::get_community_url [dotlrn_community::get_community_id -package_id [ad_conn package_id]]] } +if {[info exists ims_item_id]} { + lorsm::set_ims_item_id $ims_item_id +} + # Get the paths set the_root [ns_info pageroot] set the_url [ad_conn path_info] set content_type "content_revision" set content_root [lindex [nsv_get delivery_vars [ad_conn session_id]] 0] +set ns_item_id [lindex [nsv_get delivery_vars [ad_conn session_id]] 1] +set ims_item_id [lorsm::get_ims_item_id] +set the_url [join [lrange [split $the_url "/"] 1 end] "/"] + set template_root [db_string template_root ""] # Serve the page @@ -28,6 +36,36 @@ # as though it's been passed by reference. This requires that the redirect treat the # path as an absolute path within the filesystem. +# MIGUELM: we need a way to use other content root not only the one for the course since we can have +# items from other courses + +set item_id [content::item::get_id -item_path $the_url -root_folder_id $content_root -resolve_index "f"] + +if { [empty_string_p $item_id] } { + # This item was probably added. We need to check if the item exist on other folder. + # So we will get the first part of the URL + set item_id [lorsm::delivery::get_item_other_folder -url $the_url] +} + +# To get the revision_id (file_id) we need to show here we have to items here +# one is the item_id that is recived on record-view page from the menu +# and the other one is the one that holds all the revisions for one file +set revision_id [lorsm::delivery::get_file_id_from_ims_item_id -ims_item_id $ns_item_id -item_id $item_id] + +if { [empty_string_p $revision_id] } { + # Is a reference to an image or some other resource inside the page, this items don't + # have an entry in ims_cp_files table + set revision_id [item::get_best_revision $item_id] +} + +if { ![empty_string_p $revision_id] } { + # We catch the revision id using the_url and content root + cr_write_content -revision_id $revision_id +} else { + # Write the ims_item_id that we recieve on the page since this is the one that holds the content + cr_write_content -revision_id $ims_item_id +} + if { [lorsm::init the_url the_root $content_root $template_root public "" $content_type] } { # we introduced our own template