Begin main content
Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]

::xo::db::CrClass[i] ::xowiki::File

Class Hierarchy of ::xowiki::File

  • ::xotcl::Object[i]
    Methods for instances:
    __api_make_doc, __api_make_forward_doc, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, check, classC, cleanupC, configureC, containsC, copyC, db_0or1rowC, db_1rowC, debug, defaultmethodC, destroyC, destroy_on_cleanup, ds, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearch, forward, hasclass, incrC, infoC, init, instvarC, invarC, isclass, ismetaclass, ismixin, isobject, istype, lappendC, log, method, mixinC, mixinguardC, moveC, msg, noinitC, objectparameter, parametercmdC, proc, procsearch, qn, requireNamespaceC, residualargsC, self, serialize, setC, set_instance_vars_defaults, show-object, substC, traceC, unknown, unsetC, uplevelC, upvarC, volatileC, vwait
    Methods to be applied on the class (in addition to the methods provided by the meta-class):
    getExitHandler, setExitHandler, unsetExitHandler
    • ::xo::db::Object[i]
      Methods for instances:
      db_1row, delete, initialize_loaded_object, insert, object_idC, object_titleC, save, save_new
      Methods to be applied on the class:
      Methods provided by the meta-class
      • ::xo::db::CrItem[i]
        Parameter for instances:
        package_id, parent_id (default "-100"), publish_status (default "ready")
        Methods for instances:
        current_user_id, delete, descriptionC, fix_content, initialize_loaded_object, item_idC, mime_typeC, nameC, nls_languageC, privilege=creator, publish_dateC, rename, revision_idC, revisions, save, save_new, set_live_revision, textC, titleC, update_attribute_from_slot, update_content, update_revision
        Methods to be applied on the class:
        Methods provided by the meta-class
        • ::xowiki::Page[i]
          Parameter for instances:
          absolute_links (default "0"), do_substitutions (default "1"), render_adp (default "1")
          Methods for instances:
          adp_subst, anchor, build_instance_attribute_map, build_name, category_export, category_import, check_adp_include_path, clipboard-add, clipboard-clear, clipboard-content, clipboard-copy, clipboard-export, condition=match, condition=regexp, copy_content_vars, create-new, create-or-use, create_form_field, create_form_fields, create_form_fields_from_form_constraints, create_form_page_instance, create_link, create_raw_form_field, creation_userC, creatorC, css_class_name, csv-dump, default_instance_attributes, delete, delete-revision, demarshall, descriptionC, detail_link, diff, div, edit, edit_set_default_values, edit_set_file_selector_folder, error_during_render, error_in_includelet, exists_form_parameterC, exists_query_parameterC, field_names, find_slot, footer, form_field_index, form_parameterC, get_anchor_and_query, get_content, get_description, get_folder, get_form_data, get_html_from_content, get_instance_attributes, get_nls_language_from_lang, get_property_from_link_page, get_rich_text_spec, get_target_from_link_page, htmlFooter, include, include_content, initialize_loaded_object, instantiate_includelet, is_folder_page, is_form, is_link_page, is_new_entry, item_refC, lang, last_modifiedC, list, lookup_cached_form_field, lookup_form_field, make-live-revision, map_categories, map_party, marshall, mime_typeC, mutual_overwrite_occurred, nameC, new_link, nls_languageC, normalize_internal_link_name, page_idC, page_orderC, physical_package_id, physical_parent_id, popular-tags, pretty_link, pretty_name, publish_dateC, query_parameterC, record_last_visited, references_update, regsub_eval, render, render_content, render_icon, render_includelet, reset_resolve_context, resolve_included_page_name, reverse_map_party, reverse_map_party_attribute, revisions, save, save-attributes, save-tags, save_data, save_new, search_render, set_content, set_resolve_context, show_fields, substitute_markup, textC, titleC, translate, unescape, unset_temporary_instance_variables, validate-attribute, validate=form_constraints, validate=name, validate=page_order, view
          Methods to be applied on the class (in addition to the methods provided by the meta-class):
          container_already_rendered, find_slot, get_tags, import, quoted_html_content, save_tags
          • ::xowiki::File[i]
            Parameter for instances:
            render_adp (default "0")
            Methods for instances:
            build_name, demarshall, download, file_idC, full_file_name, html_content, marshall, mime_typeC, pretty_name, render_content, render_icon
            Methods to be applied on the class:
            Methods provided by the meta-class

Class Relations

  • superclass: ::xowiki::Page[i]
  • subclass: ::xowiki::PodcastItem[i]
::xo::db::CrClass create ::xowiki::File \
     -superclass ::xowiki::Page \
     -parameter {{render_adp 0}}


  • instproc build_name

    ::385385 instproc build_name {name {fn {}}} {
        if {$name ne ""} {
          set stripped_name $name
          regexp {^(.*):(.*)$} $name _ _t stripped_name
        } else {
          set stripped_name $fn
          # Internet explorer seems to transmit the full path of the
          # filename. Just use the last part in such cases as name.
          regexp {[/\\]([^/\\]+)$} $stripped_name _ stripped_name
        return file:[[my package_id] normalize_name $stripped_name]
  • instproc demarshall

    ::385385 instproc demarshall args {
        # we have to care about recoding the file content
        my instvar import_file __file_content
        set import_file [ns_tmpnam]
        ::xowiki::write_file $import_file [::base64::decode $__file_content]
        catch {my unset full_file_name}
        unset __file_content
  • instproc download

    ::385385 instproc download {} {
        my instvar mime_type
        # determine the delivery method
        set use_bg_delivery [expr {![catch {ns_conn contentsentlength}] && 
                                   [info command ::bgdelivery] ne ""}]
        # The package where the object is coming from might be different
        # from the package on which it is delivered. Use the latter one
        # with the proper delivery information.
        set package_id [::xo::cc package_id]
        $package_id set mime_type $mime_type
        $package_id set delivery  [expr {$use_bg_delivery ? "ad_returnfile_background" : "ns_returnfile"}]
        if {[my exists_query_parameter filename]} {
          set fn [::xo::backslash_escape \" [my query_parameter filename]]
          ns_set put [ns_conn outputheaders] Content-Disposition "attachment;filename=\"$fn\""
        set full_file_name [my full_file_name]
        #my log "--F FILE=$full_file_name // $mime_type"
        set geometry [::xo::cc query_parameter geometry ""]
        if {[string match image/* $mime_type] && $geometry ne ""} {
          if {![file isdirectory /tmp/$geometry]} {
    	file mkdir /tmp/$geometry
          set scaled_image /tmp/$geometry/[my revision_id]
          if {![file readable $scaled_image]} {
    	set cmd [::util::which convert]
    	if {$cmd ne ""} {
    	  if {![catch {exec $cmd -geometry $geometry -interlace None -sharpen 1x2  $full_file_name $scaled_image}]} {
    	    return $scaled_image
          } else {
    	return $scaled_image
        set modtime [file mtime $full_file_name]
        set cmptime [ns_set iget [ns_conn headers] If-Modified-Since]
        if {$cmptime ne ""} {
          if {[clock scan $cmptime] >= $modtime} {
    	ns_returnnotice 304 "Not modified" "not modified"
    	return ""
        ns_set put [ns_conn outputheaders] Last-Modified [ns_httptime $modtime]
        return $full_file_name
  • instproc full_file_name

    ::385385 instproc full_file_name {} {
        if {![my exists full_file_name]} {
          if {[my exists item_id]} {
            my instvar text mime_type package_id item_id revision_id
            set storage_area_key [::xo::db_string get_storage_key  "select storage_area_key from cr_items where item_id=$item_id"]
            my set full_file_name [cr_fs_path $storage_area_key]/$text
            #my log "--F setting FILE=[my set full_file_name]"
        return [my set full_file_name]
  • instproc html_content

    ::385385 instproc html_content {{-add_sections_to_folder_tree 0} -owner} {
        set parent_id [my parent_id]
        set fileName [my full_file_name]
        set f [open $fileName r]; set data [read $f]; close $f 
        # Ugly hack to fight against a problem with tDom: asHTML strips
        # spaces between a </span> and the following <span>"
        #regsub -all "/span>      <span" $data "/span>\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;<span" data
        #regsub -all "/span>     <span" $data "/span>\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;<span" data
        #regsub -all "/span>    <span" $data "/span>\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;<span" data
        #regsub -all "/span>   <span" $data "/span>\\&nbsp;\\&nbsp;\\&nbsp;<span" data
        #regsub -all "/span>  <span" $data "/span>\\&nbsp;\\&nbsp;<span" data
        regsub -all "/span> " $data "/span>\\&nbsp;" data
        regsub -all " <span " $data "\\&nbsp;<span " data
        regsub -all "/span>\n<span " $data "/span><br><span " data
        regsub -all "/span>\n\n<span " $data "/span><br><br><span " data
        dom parse -html $data doc 
        $doc documentElement root 
        # substitute relative links to download links in the same folder
        set prefix [$parent_id pretty_link -absolute true -download true]
        foreach n [$root selectNodes //img] {
          set src [$n getAttribute src]
          if {[regexp {^[^/]} $src]} {
    	$n setAttribute src $prefix/$src
    	#my msg "setting src to $prefix/$src"
        # In case, the switch is activated, and we have a menubar, add the
        # top level section
        if {$add_sections_to_folder_tree && [info command ::__xowiki__MenuBar] ne ""} {
          $owner set book_mode 1
          set pages [::xo::OrderedComposite new -destroy_on_cleanup]
          if {$add_sections_to_folder_tree == 1} {
    	set selector //h2
          } else {
    	set selector {//h2 | //h3}
          set order 0
          foreach n [$root selectNodes $selector] {
    	if {[$n hasAttribute id]} {
    	  set name [$n getAttribute id]
    	} else {
    	  set name "section $n"
    	set o [::xotcl::Object new]
    	$o set page_order [incr $order]
    	$o set title [$n asText]
    	set e [$doc createElement a]
    	$e setAttribute name $name
    	[$n parentNode] insertBefore $e $n
    	$o set name $name
    	$pages add $o
          #$o instvar page_order title name
          ::__xowiki__MenuBar additional_sub_menu -kind folder -pages $pages -owner $owner
        # return content of body
        set content "" 
        foreach n [$root selectNodes //body/*] { append content [$n asHTML] \n } 
        return $content
  • instproc marshall

    ::385385 instproc marshall {} {
        set fn [my full_file_name]
        my set __file_content [::base64::encode [::xowiki::read_file $fn]]
  • instproc pretty_name

    ::385385 instproc pretty_name {} {
        set name [my name]
        regsub {^file:} $name "" name
        return $name
  • instproc render_content

    ::385385 instproc render_content {} {
        my instvar name mime_type description parent_id package_id item_id creation_user
        # don't require permissions here, such that rss can present the link
        #set page_link [$package_id make_link -privilege public [self] download ""]
        set ctx [$package_id context]
        set revision_id [$ctx query_parameter revision_id]
        set query [expr {$revision_id ne "" ? "revision_id=$revision_id" : ""}]
        set page_link [my pretty_link -download true -query $query]
        if {[$ctx query_parameter html-content] ne ""} {
          return [my html_content]
        #my log "--F page_link=$page_link ---- "
        set t [TableWidget new -volatile  -columns {
                     AnchorField name -label [_ xowiki.Page-name]
                     Field mime_type -label "Content Type"
                     Field last_modified -label "Last Modified"
                     Field mod_user -label "By User"
                     Field size -label "Size (Bytes)"
        regsub {[.][0-9]+([^0-9])} [my set last_modified] {\1} last_modified
        $package_id get_lang_and_name -name $name lang stripped_name
        set label $stripped_name
        $t add  -name $stripped_name  -mime_type $mime_type  -name.href $page_link  -last_modified $last_modified  -mod_user [::xo::get_user_name $creation_user]  -size [file size [my full_file_name]]
        switch -glob $mime_type {
          image/* {
    	set l [Link new -volatile  -page [self] -query $query  -type image -name $name -lang ""  -stripped_name $stripped_name -label $label  -parent_id $parent_id -item_id $item_id -package_id $package_id]
    	set preview "<div >[$l render]</div>"
          text/plain {
    	set text [::xowiki::read_file [my full_file_name]]
    	set preview "<pre class='code'>[::xowiki::Includelet html_encode $text]</pre>"
          default {set preview ""}
        return "$preview[$t asHTML]\n<p>$description</p>"
  • instproc render_icon

    ::385385 instproc render_icon {} {
        return [list text "<img src='/resources/file-storage/file.gif' width='12'>" is_richtext true]

Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]