Class Relations
- class: ::xowiki::Object
::xowiki::Object create ::xowiki::exporter
Methods (to be applied on the object)
export (scripted)
set item_ids [:include_needed_objects $item_ids]
ns_set put [ns_conn outputheaders] "Content-Type" "text/plain"
ns_set put [ns_conn outputheaders] "Content-Disposition" "attachment;filename=export.xotcl"
ad_return_top_of_page ""
foreach item_id $item_ids {
ns_log notice "--exporting $item_id [::$item_id name]"
set pretty_link [expr {[::$item_id package_id] ne "" ? [::$item_id pretty_link] : "(not visible)"}]
ns_write "# exporting $item_id [::$item_id name] $pretty_link\n"
ad_try {
set obj [::$item_id marshall]
} on error {errorMsg} {
ns_log error "Error while exporting $item_id [::$item_id name]\n$errorMsg\n$::errorInfo"
} finally {
ns_write "$obj\n"
}
}
include_needed_objects (scripted)
foreach item_id $item_ids {
if {[::xo::db::CrClass get_instance_from_db -item_id $item_id] eq ""} {
:log "Warning: cannot fetch item $item_id for exporting"
} else {
set items($item_id) 1
}
}
while {1} {
set new 0
if {[array size items] > 0} {
ns_log notice "--export works on [array size items] items: [array names items]"
}
foreach item_id [array names items] {
if {[::$item_id istype ::xowiki::PageInstance]} {
set template_id [::$item_id page_template]
if {![info exists items($template_id)]} {
ns_log notice "--export including template-object $template_id of item $item_id has name? [::$template_id exists name]"
ns_log notice "--export including template-object $template_id [::$template_id name]"
set items($template_id) 1
::xo::db::CrClass get_instance_from_db -item_id $template_id
set new 1
::$template_id set __export_reason implicit_page_template
continue
}
}
set sql [::xowiki::Page instance_select_query -folder_id $item_id -with_subtypes true]
::xo::dc foreach export_child_obj $sql {
if {![info exists items($item_id)]} {
ns_log notice "--export child $item_id not included, try to fetch"
::xo::db::CrClass get_instance_from_db -item_id $item_id
ns_log notice "--export including child $item_id [::$item_id name]"
set items($item_id) 1
set new 1
::$item_id set __export_reason implicit_child_page
}
}
}
if {!$new} {
break
}
}
return [array names items]
marshall_all (scripted)
set content ""
foreach item_id $item_ids {
ad_try {
set obj [::$item_id marshall -mode $mode]
} on error {errorMsg} {
ns_log error "Error while exporting $item_id [::$item_id name]\n$errorMsg\n$::errorInfo"
error $errorMsg
}
append content $obj\n
}
return $content
marshall_all_to_file (scripted)
set output_file [open $filename w]
foreach item_id $item_ids {
ad_try {
puts $output_file [::$item_id marshall -mode $mode]
if {$cleanup && [info exists ::xo::cleanup(::$item_id)]} {
{*}$::xo::cleanup(::$item_id)
}
} on error {errorMsg} {
ns_log error "Error while exporting $item_id [::$item_id name]\n$errorMsg\n$::errorInfo"
error $errorMsg
} finally {
close $output_file
}
}