| |
75 |
75 |
Link instproc render_found {href label} { |
| |
76 |
76 |
return "<a [my atts] [my mk_css_class] href='$href'>$label</a>" |
| |
77 |
77 |
} |
| |
78 |
78 |
Link instproc render_not_found {href label} { |
| |
79 |
79 |
if {$href eq ""} { |
| |
80 |
80 |
return \[$label\] |
| |
81 |
81 |
} else { |
| |
82 |
82 |
return "<a [my mk_css_class] href='$href'> \[ </a>$label\ |
| |
83 |
83 |
<a [my mk_css_class] href='$href'> \] </a>" |
| |
84 |
84 |
} |
| |
85 |
85 |
} |
| |
86 |
86 |
Link instproc pretty_link {item_id} { |
| |
87 |
87 |
my instvar package_id |
| |
88 |
88 |
return [::$package_id pretty_link -parent_id [my parent_id] -lang [my lang] \ |
| |
89 |
89 |
-anchor [my anchor] -query [my query] [my name]] |
| |
90 |
90 |
} |
| |
91 |
91 |
Link instproc new_link {} { |
| |
92 |
92 |
my instvar package_id form |
| |
93 |
93 |
set page [my page] |
| |
94 |
94 |
if {$form ne ""} { |
| |
95 |
|
# for now, we assume, the form is in same dir as the current |
| |
96 |
|
# page; we have to lookup the form to determine rights on the |
| |
97 |
|
# form. |
| |
98 |
|
set parent_id [$page parent_id] |
| |
99 |
|
set template_id [::xo::db::CrClass lookup -name $form -parent_id $parent_id] |
| |
100 |
|
if {$template_id == 0} { |
| |
101 |
|
# make a second try for the form with the en prefix |
| |
102 |
|
if {[regexp {^(..):(.+)$} $form _ lang stripped_form]} { |
| |
103 |
|
set form en:$stripped_form |
| |
104 |
|
set template_id [::xo::db::CrClass lookup -name $form -parent_id $parent_id] |
| |
|
95 |
# use the same instantiate_forms as everywhere; TODO: will go to a different namespace |
| |
|
96 |
set form_id [::xowiki::Weblog instantiate_forms -forms $form -package_id $package_id] |
| |
|
97 |
if {$form_id != 0} { |
| |
|
98 |
::xo::db::CrClass get_instance_from_db -item_id $form_id |
| |
|
99 |
set form_link [$package_id pretty_link -parent_id [$form_id parent_id] $form] |
| |
|
100 |
return [$package_id make_link -with_entities 0 -link $form_link $form_id \ |
| |
|
101 |
create-new return_url title \ |
| |
|
102 |
[list parent_id [my parent_id]] \ |
| |
|
103 |
[list name [my name]] \ |
| |
|
104 |
[list nls_language [$page nls_language]]] |
| |
105 |
105 |
} |
| |
106 |
106 |
} |
| |
107 |
|
if {$template_id != 0} { |
| |
108 |
|
::xo::db::CrClass get_instance_from_db -item_id $template_id |
| |
109 |
|
set form_link [$package_id pretty_link -parent_id $parent_id $form] |
| |
110 |
|
return [$package_id make_link -with_entities 0 -link $form_link $template_id \ |
| |
111 |
|
create-new return_url [list name [my name]] title [list nls_language [$page nls_language]]] |
| |
112 |
|
} |
| |
113 |
|
} |
| |
114 |
107 |
if {[$page exists __unresolved_object_type]} { |
| |
115 |
108 |
# get the desired object_type for unresoved entries |
| |
116 |
109 |
set object_type [$page set __unresolved_object_type] |
| |
117 |
110 |
} else { |
| |
118 |
111 |
set object_type [[$page info class] set object_type] |
| |
119 |
112 |
if {$object_type ne "::xowiki::Page" && $object_type ne "::xowiki::PlainPage"} { |
| |
120 |
113 |
# TODO: this is a temporary solution. we should find a way to |
| |
121 |
114 |
# pass similar to file or image entries the type of this |
| |
122 |
115 |
# entry. Maybe we can get the type as well from a kind of |
| |
123 |
116 |
# blackboard, where the type of the "edit" wiki-menu-entry is |
| |
124 |
117 |
# stored as well. |
| |
125 |
118 |
set object_type ::xowiki::Page |
| |
126 |
119 |
} |
| |
127 |
120 |
} |
| |
128 |
121 |
return [$page new_link -name [my name] -title [my label] -parent_id [my parent_id] \ |
| |
129 |
122 |
-nls_language [$page nls_language] $package_id] |
| |
130 |
123 |
} |
| |
131 |
124 |
|
| |
132 |
125 |
Link instproc render {} { |
| |
133 |
126 |
my instvar package_id |