xowiki::Package instproc item_ref (public)

 <instance of xowiki::Package[i]> item_ref \
    [ -use_package_path use_package_path ] \
    [ -use_site_wide_pages use_site_wide_pages ] \
    [ -normalize_name normalize_name ] -default_lang default_lang  \
    -parent_id parent_id  link

Defined in packages/xowiki/tcl/package-procs.tcl

An item_ref refers to an item (existing or non-existing) in the content repository relative to some parent_id. The item might be either a folder or some kind of "page" (e.g. a file). An item_ref might be complex, i.e. consist of a path of simple_item_refs, separated by "/". An item_ref stops at the first unknown part in the path and returns item_id == 0 and the appropriate parent_id (and name etc.) for insertion.

Switches:
-use_package_path
(defaults to "false") (optional)
-use_site_wide_pages
(defaults to "false") (optional)
-normalize_name
(defaults to "true") (optional)
-default_lang
(required)
-parent_id
(required)
Parameters:
link
Returns:
item info containing link_type form prefix stripped_name item_id parent_id

Partial Call Graph (max 5 caller/called nodes):
%3 test_path_resolve path_resolve (test xowiki) xowiki::Package instproc item_ref xowiki::Package instproc item_ref test_path_resolve->xowiki::Package instproc item_ref test_xowiki_test_cases xowiki_test_cases (test xowiki) test_xowiki_test_cases->xowiki::Package instproc item_ref

Testcases:
xowiki_test_cases, path_resolve
Source code:
# A trailing slash says that the last element is a folder. We
# substitute it to allow easy iteration over the slash separated
# segments.
if {[string match "*/" $link]} {
  set llink [string trimright $link /]\0
} else {
  set llink $link
}

set elements [split $llink /]
# Get start-page, if path is empty
if {[llength $elements] == 0} {
  set link [:get_parameter -check_query_parameter false index_page "index"]
  set elements [list $link]
}

#
# Iterate bottom-up until the first unknown element appears in the
# path (we can handle only one unknown at a time).
#
set nr_elements [llength $elements]
set n 0
set ref_ids {}
foreach element $elements {
  set (last_parent_id) $parent_id
  lappend ref_ids $parent_id
  array set "" [:simple_item_ref  -normalize_name $normalize_name  -use_package_path $use_package_path  -use_site_wide_pages $use_site_wide_pages  -default_lang $default_lang  -parent_id $parent_id  -assume_folder [expr {[incr n] < $nr_elements}]  $element]
  #:msg "simple_item_ref <$element> => [array get {}]"
  if {$(item_id) == 0} {
    set parent_id $(parent_id)
    break
  } else {
    set parent_id $(item_id)
  }
}

return [list link $link link_type $(link_type) form $(form)  prefix $(prefix) stripped_name $(stripped_name)  item_id $(item_id) parent_id $(parent_id) ref_ids $ref_ids]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: