xowiki::Page instproc create_link
<instance of xowiki::Page> create_link
Defined in
- Testcases:
-
path_resolve, xowiki, nested_self_references
Source code:
set label $arg
set link $arg
set options ""
regexp {^([^|]+)[|](.*)$} $arg _ link label
regexp {^([^|]*)[|](.*)$} $label _ label options
set options [:unescape $options]
set link [string trim $link]
set package_id [::${:package_id} resolve_package_path $link link]
if {$package_id == 0} {
if {[regsub {^//} $link / link]} {
switch -glob -- [::xowiki::guesstype $link] {
text/css {
::xo::Page requireCSS $link
return ""
}
application/x-javascript -
application/javascript {
::xo::Page requireJS $link
return ""
}
image/* {
Link create [self]::link -page [self] -name "" -type localimage -label $label -href $link
[self]::link configure {*}$options
return [self]::link
}
}
}
set l [ExternalLink new -label $label -href $link]
$l configure {*}$options
return $l
}
set link_info [:get_anchor_and_query $link]
set parent_id [expr {$package_id == ${:package_id} ?
${:parent_id} : [::$package_id folder_id]}]
set use_package_path true
set is_self_link false
if {[regexp {^:(..):(.+)$} [dict get $link_info link] _ lang stripped_name]} {
set item_ref_info [::$package_id item_ref -use_package_path $use_package_path -default_lang [:lang] -parent_id $parent_id ${lang}:$stripped_name]
dict set item_ref_info link_type language
} elseif {[regexp {^[.]SELF[.]/(.*)$} [dict get $link_info link] _ link]} {
set self_link_ids [:self_link_ids]
set parent_id [dict get $self_link_ids parent_id]
set package_id [dict get $self_link_ids package_id]
set is_self_link true
set item_ref_info [::$package_id item_ref -use_package_path $use_package_path -default_lang [:lang] -parent_id $parent_id $link]
dict set link_info link $link
} else {
set item_ref_info [::$package_id item_ref -use_package_path $use_package_path -default_lang [:lang] -parent_id $parent_id [dict get $link_info link]]
}
if {$label eq $arg} {
set label [dict get $link_info link]
}
set item_name [string trimleft [dict get $item_ref_info prefix]:[dict get $item_ref_info stripped_name] :]
Link create [self]::link -page [self] -form [dict get $item_ref_info form] -type [dict get $item_ref_info link_type] -name $item_name -lang [dict get $item_ref_info prefix] -anchor [dict get $link_info anchor] -query [dict get $link_info query] -stripped_name [dict get $item_ref_info stripped_name] -label $label -parent_id [dict get $item_ref_info parent_id] -item_id [dict get $item_ref_info item_id] -package_id $package_id -is_self_link $is_self_link
if {[:can_link [dict get $item_ref_info item_id]] == 0} {
:references refused [dict get $item_ref_info item_id]
if {[[self]::link exists href]} {
[self]::link unset href
}
}
[self]::link configure {*}$options
set result [[self]::link]
return $result
XQL Not present:Generic, PostgreSQL, Oracle
[
hide source ]
| [
make this the default ]