Index: openacs-4/packages/lorsm/www/delivery/view/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/view/index.vuh,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lorsm/www/delivery/view/index.vuh 4 Sep 2004 14:51:26 -0000 1.1 +++ openacs-4/packages/lorsm/www/delivery/view/index.vuh 17 May 2005 17:03:40 -0000 1.2 @@ -1,55 +1,81 @@ -################################################# ad_page_contract { - @author Unknown @creation-date Unknown @cvs-id $Id$ } { - { imsitem_id "" } + { ims_item_id "" } } - + # check if the nsv variable exists if {![nsv_exists delivery_vars [ad_conn session_id]]} { ad_returnredirect [dotlrn_community::get_community_url [dotlrn_community::get_community_id -package_id [ad_conn package_id]]] } - -# -if {[info exists imsitem_id]} { - lorsm::set_ims_item_id $imsitem_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 imsitem_id [lorsm::get_ims_item_id] +set ns_item_id [lindex [nsv_get delivery_vars [ad_conn session_id]] 1] +set ims_item_id [lorsm::get_ims_item_id] -#ad_script_abort +set the_url [join [lrange [split $the_url "/"] 1 end] "/"] set template_root [db_string template_root ""] # Serve the page - # DRB: Note that content::init modifies the local variable the_root, which is treated # as though it's been passed by reference. This requires that the redirect treat the # path as an absolute path within the filesystem. -if { [lorsm::init the_url the_root $content_root $template_root public "" $content_type] } { +# 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 +} + +ad_script_abort +if { [lorsm::init the_url the_root $content_root $template_root public "" $content_type] } { # we introduced our own template rp_internal_redirect -absolute_path [acs_root_dir]/templates/lorsm-default } else { - # ns_returnnotfound - set page "[ad_header {Content Item Not Found}]" - append page "