xowiki::markdown_image::drafts (private)

 xowiki::markdown_image::drafts page

Defined in packages/xowiki/tcl/markdown-image-procs.tcl

Collect this user's staged inline images referenced by the page and its form fields.

Parameters:
page (required)

Partial Call Graph (max 5 caller/called nodes):
xowiki::Page instproc save_new xowiki::Page instproc save_new (public) xowiki::markdown_image::drafts xowiki::markdown_image::drafts xowiki::Page instproc save_new->xowiki::markdown_image::drafts acs_object_type acs_object_type (public) xowiki::markdown_image::drafts->acs_object_type ad_conn ad_conn (public) xowiki::markdown_image::drafts->ad_conn xowiki::markdown_image::draft_path xowiki::markdown_image::draft_path (private) xowiki::markdown_image::drafts->xowiki::markdown_image::draft_path xowiki::markdown_image::mime_type xowiki::markdown_image::mime_type (private) xowiki::markdown_image::drafts->xowiki::markdown_image::mime_type

Testcases:
No testcase defined.
Source code:
  if {![ns_conn isconnected] || [ad_conn user_id] == 0
      || [ad_conn package_id] != [$page package_id]
      || [namespace which ::attachments::richtext::file_attach] eq ""} {
    return {}
  }
  set values {}
  if {[$page exists text]} {
    lappend values [$page set text]
  }
  if {[$page exists instance_attributes]} {
    lappend values {*} [dict values [$page set instance_attributes]]
  }

  set prefix [ad_conn package_url]markdown-image?image_id=
  set drafts {}
  foreach html $values {
    if {[string first $prefix $html] == -1} continue
    foreach tag [ns_parsehtml -onlytags -- $html] {
      lassign $tag element attributes
      if {![string equal -nocase $element img] || ![dict exists $attributes src]} continue
      set src [dict get $attributes src]
      if {[string first $prefix $src] != 0} continue
      set image_id [string range $src [string length $prefix] end]
      if {![regexp {^[1-9][0-9]*$} $image_id] || [dict exists $drafts $image_id]} continue

      # A previously attached image, including one referenced from another page,
      # keeps its current owner.
      if {[acs_object_type $image_id] ne ""} continue
      set path [draft_path $image_id]
      set mime [mime_type $path]
      if {$mime eq ""} {
        error "A pasted image is unavailable. Remove it or paste it again."
      }
      dict set drafts $image_id [list $path $mime]
    }
  }
  return $drafts
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: