Index: dotlrn_packages/lams2int/tcl/lams2int-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/dotlrn_packages/lams2int/tcl/lams2int-procs.tcl,v diff -u -r1.1 -r1.2 --- dotlrn_packages/lams2int/tcl/lams2int-procs.tcl 12 Sep 2007 06:37:02 -0000 1.1 +++ dotlrn_packages/lams2int/tcl/lams2int-procs.tcl 13 Aug 2008 00:32:29 -0000 1.2 @@ -6,7 +6,7 @@ @author Ernie Ghiglione (ErnieG@melcoe.mq.edu.au) @creation-date 2007-04-16 - @cvs-id $Id$ + @cvs-id lams2int-procs.tcl,v 1.1 2007/09/12 06:37:02 ernieg Exp } # @@ -136,4 +136,74 @@ set lams2conf_package_id [db_string pack_id_lams_conf {select package_id from apm_packages where package_key = 'lams2conf'}] return [parameter::get -parameter request_source -package_id $lams2conf_package_id] -} \ No newline at end of file +} + +ad_proc -public lams2int::process_sequence_xml { + -xml:required +} { + Gets the XML with the sequences and folder and process it. + +} { + + encoding convertfrom utf-8 $xml + set doc [dom parse $xml] + set content [$doc documentElement] + + set sequence_list [concat [lams2int::process_node -node $content] " \] "] + +} + +ad_proc -private lams2int::process_node { + -node:required + +} { + Process the XML nodes + +} { + + if {[string equal [$node nodeName] "Folder"]} { + + regsub -all {'} [$node getAttribute name] {\\'} folder_name + + append output "\[ '$folder_name', null , " + + if {[$node hasChildNodes]} { + + foreach child [$node childNodes] { + + append output [lams2int::process_node -node $child] + + if {[string equal [$child nodeName] "Folder"]} { + + if {![empty_string_p [$child nextSibling]]} { + append output " \], " + } else { + append output " \]" + } + } + + } + + } else { + + append output "\['', null\]" + + } + } else { + # the node is a LearningDesign + + regsub -all {'} [$node getAttribute name] {\\'} design_name + + append output "\[ '$design_name', 'javascript:selectSequence([$node getAttribute resourceId])' \] " + + if {![empty_string_p [$node nextSibling]]} { + append output ", " + } else { + append output "" + } + + } + + return $output +} + Index: dotlrn_packages/lams2int/www/admin/add.tcl =================================================================== RCS file: /usr/local/cvsroot/dotlrn_packages/lams2int/www/admin/add.tcl,v diff -u -r1.3 -r1.4 --- dotlrn_packages/lams2int/www/admin/add.tcl 6 Aug 2008 08:00:34 -0000 1.3 +++ dotlrn_packages/lams2int/www/admin/add.tcl 13 Aug 2008 00:32:29 -0000 1.4 @@ -47,64 +47,12 @@ ns_log Notice "URL requested $get_sequences_url" - -set xml [lindex [ad_httpget -url $get_sequences_url -timeout 30] 1] - -set xml [encoding convertfrom utf-8 $xml] -set doc [dom parse $xml] -set content [$doc documentElement] - -proc process_node { node } { - - if {[string equal [$node nodeName] "Folder"]} { - - regsub -all {'} [$node getAttribute name] {\\'} folder_name - - append output "\[ '$folder_name', null , " - - if {[$node hasChildNodes]} { - - foreach child [$node childNodes] { - - append output [process_node $child] - - if {[string equal [$child nodeName] "Folder"]} { - - if {![empty_string_p [$child nextSibling]]} { - append output " \], " - } else { - append output " \]" - } - } - - } - - } else { - - append output "\['', null\]" - - } - } else { - # the node is a LearningDesign - - regsub -all {'} [$node getAttribute name] {\\'} design_name - - append output "\[ '$design_name', 'javascript:selectSequence([$node getAttribute resourceId])' \] " - - if {![empty_string_p [$node nextSibling]]} { - append output ", " - } else { - append output "" - } - - } - - return $output +if {[catch {set return_string [ad_httpget -url $get_sequences_url -timeout 30] } ] } { + ad_return_complaint 0 "It seems that the LAMS server you are trying to connect is down or there's a problem with the configuration. Please verify the connection setting or contact your system administrator." + ad_script_abort } +set xml [lindex $return_string 1] +set sequence_list [lams2int::process_sequence_xml -xml $xml] -set sequence_list [concat [process_node $content] " \] "] - -#regsub -all {'} $sequence_list {\\'} sequence_list -