Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v
diff -u -N -r1.357 -r1.358
--- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 20 May 2018 10:13:23 -0000 1.357
+++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 20 May 2018 11:01:57 -0000 1.358
@@ -1,5 +1,5 @@
::xo::library doc {
- XoWiki - www procs. These procs are the methods called on xowiki pages via
+ XoWiki - www procs. These procs are the methods called on xowiki pages via
the web interface.
@creation-date 2006-04-10
@@ -15,8 +15,8 @@
# naming convention dashes as separators.
#
#
- # externally callable method: bulk-delete
- #
+ # Externally callable method: bulk-delete
+ #
Page instproc www-bulk-delete {} {
set package_id ${:package_id}
::security::csrf::validate
@@ -39,8 +39,8 @@
}
#
- # externally callable method: clipboard-add
- #
+ # Externally callable method: clipboard-add
+ #
Page instproc www-clipboard-add {} {
if {![:exists_form_parameter "objects"]} {
:msg "nothing to copy"
@@ -50,8 +50,10 @@
# the page_name is the name exactly as stored in the content repository
set item_id [::xo::db::CrClass lookup -name $page_name -parent_id ${:item_id}]
if {$item_id == 0} {
- # when the pasted item was from a child-resources includelet
- # included on e.g. a plain page. we look for a sibling.
+ #
+ # When the pasted item was from a child-resources includelet
+ # included on e.g. a plain page. We look for a sibling.
+ #
set item_id [::xo::db::CrClass lookup -name $page_name -parent_id ${:parent_id}]
}
#:msg "want to copy $page_name // $item_id"
@@ -62,16 +64,16 @@
}
#
- # externally callable method: clipboard-clear
- #
+ # Externally callable method: clipboard-clear
+ #
Page instproc www-clipboard-clear {} {
::xowiki::clipboard clear
${:package_id} returnredirect [:query_parameter "return_url" [::xo::cc url]]
}
#
- # externally callable method: clipboard-content
- #
+ # Externally callable method: clipboard-content
+ #
Page instproc www-clipboard-content {} {
set clipboard [::xowiki::clipboard get]
if {$clipboard eq ""} {
@@ -89,8 +91,8 @@
}
#
- # externally callable method: clipboard-copy
- #
+ # Externally callable method: clipboard-copy
+ #
Page instproc www-clipboard-copy {} {
set package_id ${:package_id}
set clipboard [::xowiki::clipboard get]
@@ -111,24 +113,24 @@
}
#
- # externally callable method: clipboard-export
- #
+ # Externally callable method: clipboard-export
+ #
Page instproc www-clipboard-export {} {
set clipboard [::xowiki::clipboard get]
::xowiki::exporter export $clipboard
ns_conn close
::xowiki::clipboard clear
#${:package_id} returnredirect [:query_parameter "return_url" [::xo::cc url]]
}
-
+
#
- # externally callable method: create-new
- #
+ # Externally callable method: create-new
+ #
Page instproc www-create-new {
- {-parent_id 0}
- {-view_method edit}
- {-name ""}
+ {-parent_id 0}
+ {-view_method edit}
+ {-name ""}
{-nls_language ""}
{-publish_status ""}
} {
@@ -224,7 +226,7 @@
if {$publish_status ne "" && $publish_status in {"production" "ready" "live" "expired"}} {
$f publish_status $publish_status
}
-
+
if {$name eq ""} {
$f save_new
} else {
@@ -257,13 +259,13 @@
}
#
- # externally callable method: create-or-use
- #
+ # Externally callable method: create-or-use
+ #
Page instproc www-create-or-use {
- {-parent_id 0}
- {-view_method edit}
- {-name ""}
+ {-parent_id 0}
+ {-view_method edit}
+ {-name ""}
{-nls_language ""}
} {
# can be overloaded
@@ -273,8 +275,8 @@
}
#
- # externally callable method: csv-dump
- #
+ # Externally callable method: csv-dump
+ #
Page instproc www-csv-dump {} {
if {![:is_form]} {
@@ -298,8 +300,8 @@
}
#
- # externally callable method: use-template
- #
+ # Externally callable method: use-template
+ #
PageInstance instproc www-use-template {} {
set package_id ${:package_id}
set formName [:query_parameter "form" ""]
@@ -310,7 +312,7 @@
array set "" [$package_id item_ref -default_lang $lang -parent_id [$package_id folder_id] $formName]
if {$(item_id) == 0} { error "cannot lookup page $formName" }
::xo::db::CrClass get_instance_from_db -item_id $(item_id)
- if {[info commands ::$(item_id)] eq ""
+ if {[info commands ::$(item_id)] eq ""
|| "::xowiki::PageTemplate" ni [$(item_id) info precedence]} {
error "OK $formName is not suited to be used as template. Should be a Form!"
}
@@ -324,11 +326,11 @@
}
$package_id returnredirect [::xo::cc url]
}
-
+
#
- # externally callable method: delete
- #
+ # Externally callable method: delete
+ #
Page instproc www-delete {} {
# delete always via package
@@ -349,10 +351,10 @@
next
}
}
-
+
#
- # externally callable method: delete-revision
- #
+ # Externally callable method: delete-revision
+ #
Page instproc www-delete-revision {} {
set item_id ${:item_id}
@@ -387,8 +389,8 @@
}
#
- # externally callable method: diff
- #
+ # Externally callable method: diff
+ #
Page instproc www-diff {} {
@@ -429,7 +431,7 @@
set title "Differences for ${:name}"
set context [list $title]
-
+
# try util::html diff if it is available and works
ad_try {
set content [::util::html_diff -old $html2 -new $html1 -show_old_p t]
@@ -452,15 +454,15 @@
set out ""
set i 0
set j 0
-
+
#set lines1 [split $doc1 "\n"]
#set lines2 [split $doc2 "\n"]
-
+
regsub -all \n $doc1 "
" doc1
regsub -all \n $doc2 "
" doc2
set lines1 [split $doc1 " "]
set lines2 [split $doc2 " "]
-
+
foreach { x1 x2 } [list::longestCommonSubsequence $lines1 $lines2] {
foreach p $x1 q $x2 {
while { $i < $p } {
@@ -497,13 +499,13 @@
}
#
- # externally callable method: download
+ # Externally callable method: download
#
File instproc www-download {} {
#
# determine the delivery method
#
- set use_bg_delivery [expr {![catch {ns_conn contentsentlength}] &&
+ set use_bg_delivery [expr {![catch {ns_conn contentsentlength}] &&
[info commands ::bgdelivery] ne ""}]
#
# The package where the object is coming from might be different
@@ -574,8 +576,8 @@
# }
#
- # helper methods for externally callable method: edit
- #
+ # Helper methods for externally callable method: edit
+ #
Page instproc edit_set_default_values {} {
set package_id ${:package_id}
@@ -585,7 +587,7 @@
#:log "setting [self] set $key [$package_id query_parameter $key]"
set :$key [$package_id query_parameter $key]
}
- }
+ }
}
Page instproc edit_set_file_selector_folder {} {
@@ -619,11 +621,11 @@
}
#
- # externally callable method: edit
- #
+ # Externally callable method: edit
+ #
Page instproc www-edit {
- {-new:boolean false}
+ {-new:boolean false}
{-autoname:boolean false}
{-validation_errors ""}
} {
@@ -637,7 +639,7 @@
set submit_link [:query_parameter "return_url" "."]
set return_url $submit_link
} else {
- # before we used "." as default submit link (resulting in a "ad_returnredirect .").
+ # before we used "." as default submit link (resulting in a "ad_returnredirect .").
# However, this does not seem to work in case we have folders in use....
#set submit_link "."
set submit_link [:pretty_link]
@@ -691,7 +693,7 @@
}
#:log "form rendered"
::xowiki::f1 instvar edit_form_page_title context formTemplate
-
+
if {[info exists item_id]} {
set rev_link [$package_id make_link [self] revisions]
set view_link [$package_id make_link [self] view]
@@ -743,7 +745,7 @@
# can be overloaded
return [:pretty_link]
}
-
+
FormPage instproc www-edit {
{-validation_errors ""}
{-disable_input_fields 0}
@@ -762,7 +764,7 @@
set anon_instances [:get_anon_instances]
#:log form=$form
#:log anon_instances=$anon_instances
-
+
set field_names [:field_names -form $form]
#:msg field_names=$field_names
set form_fields [:create_form_fields $field_names]
@@ -779,9 +781,9 @@
}
#:log formgiven=$formgiven
- # check name field:
+ # check name field:
# - if it is for anon instances, hide it,
- # - if it is required but hidden, show it anyway
+ # - if it is required but hidden, show it anyway
# (might happen, when e.g. set via @cr_fields ... hidden)
set name_field [:lookup_form_field -name _name $form_fields]
if {$anon_instances} {
@@ -812,7 +814,7 @@
#:show_fields $form_fields
#:log "__form_action [:form_parameter __form_action {}]"
-
+
if {[:form_parameter __form_action ""] eq "save-form-data"} {
#:log "we have to validate"
#
@@ -831,14 +833,14 @@
#:msg "$validation_errors errors in $form_fields"
#foreach f $form_fields { :log "$f: [$f name] '[$f set value]' err: [$f error_msg] " }
#
- # In case we are triggered internally, we might not have a
- # a connection, so we don't present the form with the
+ # In case we are triggered internally, we might not have a
+ # a connection, so we don't present the form with the
# error messages again, but we return simply the validation
# problems.
#
if {[$package_id exists __batch_mode]} {
set errors [list]
- foreach f $form_fields {
+ foreach f $form_fields {
if {[$f error_msg] ne ""} {
lappend errors [list field [$f name] value [$f set value] error [$f error_msg]]
}
@@ -893,7 +895,7 @@
#:log "__redirect_method=$redirect_method"
return [:www-view]
} else {
- #
+ #
# Build the input form and display the current values.
#
if {[:is_new_entry ${:name}]} {
@@ -946,7 +948,7 @@
:form_fields_sanity_check $form_fields
:post_process_form_fields $form_fields
- # The following command would be correct, but does not work due to a bug in
+ # The following command would be correct, but does not work due to a bug in
# tdom.
# set form [:regsub_eval \
# [template::adp_variable_regexp] $form \
@@ -993,7 +995,7 @@
::html::input -type hidden -name __current_revision_id -value ${:revision_id}
::html::CSRFToken
}
- # insert automatic form fields on top
+ # insert automatic form fields on top
foreach att $field_names {
#if {$formgiven && ![string match _* $att]} continue
if {[info exists :__field_in_form($att)]} continue
@@ -1003,7 +1005,7 @@
}
} $fcn
#
- # append some fields after the HTML contents of the form
+ # append some fields after the HTML contents of the form
#
set button_class(wym) ""
set button_class(xinha) ""
@@ -1024,7 +1026,7 @@
}
}
- # insert unreported errors
+ # insert unreported errors
foreach f $form_fields {
if {[$f set error_msg] ne "" && ![$f exists error_reported]} {
$f render_error_msg
@@ -1035,7 +1037,7 @@
}
if {$formNode ne ""} {
-
+
if {[:exists_query_parameter "return_url"]} {
set return_url [:query_parameter "return_url"]
} else {
@@ -1092,10 +1094,10 @@
}
}
-
+
#
- # externally callable method: file-upload
- #
+ # Externally callable method: file-upload
+ #
FormPage instproc www-file-upload {} {
#
@@ -1132,8 +1134,8 @@
}
#
- # externally callable method: toggle-modebutton
- #
+ # Externally callable method: toggle-modebutton
+ #
FormPage instproc www-toggle-modebutton {} {
#
# This method is typically called via modebutton in a POST request via ajax;
@@ -1153,18 +1155,18 @@
#${:package_id} returnredirect [ns_set get $form return_url [::xo::cc url]]
ns_return 200 text/plain ok
}
-
+
#
- # externally callable method: list
- #
+ # Externally callable method: list
+ #
Page instproc www-list {} {
if {[:is_form]} {
# The following line is here to provide a short description for
# larger form-usages (a few MB) where otherwise
# "ad_html_text_convert" in Page.get_description tend to use forever
# (at least in Tcl 8.5)
set :description "form-usages for ${:name} [:title]"
-
+
return [:www-view [:include [list form-usages -form_item_id ${:item_id}]]]
}
if {[:is_folder_page]} {
@@ -1175,8 +1177,8 @@
}
#
- # externally callable method: make-live-revision
- #
+ # Externally callable method: make-live-revision
+ #
Page instproc www-make-live-revision {} {
set package_id ${:package_id}
@@ -1193,8 +1195,8 @@
}
#
- # externally callable method: popular-tags
- #
+ # Externally callable method: popular-tags
+ #
Page instproc www-popular-tags {} {
set limit [:query_parameter "limit" 20]
@@ -1217,12 +1219,12 @@
}
#
- # externally callable method: save-attributes
- #
+ # Externally callable method: save-attributes
+ #
Page ad_instproc www-save-attributes {} {
- The method save-attributes is typically callable over the
- REST interface. It allows one to save attributes of a
+ The method save-attributes is typically callable over the
+ REST interface. It allows one to save attributes of a
page without adding a new revision.
} {
set field_names [:field_names]
@@ -1257,7 +1259,7 @@
foreach form_field $form_fields {
set s [$form_field slot]
if {$s eq ""} {
- # empty slot means that we have an instance_attribute;
+ # empty slot means that we have an instance_attribute;
# we save all in one statement below
set update_instance_attributes 1
} else {
@@ -1272,7 +1274,7 @@
} else {
#
# perform standard update (with revision)
- #
+ #
:save_data \
-use_given_publish_date [expr {"_publish_date" in $field_names}] \
[::xo::cc form_parameter __object_name ""] $category_ids
@@ -1289,8 +1291,8 @@
}
#
- # externally callable method: revisions
- #
+ # Externally callable method: revisions
+ #
Page instproc www-revisions {} {
set context [list [list [${:package_id} url] ${:name} ] [_ xotcl-core.revisions]]
@@ -1305,8 +1307,8 @@
}
#
- # externally callable method: save-tags
- #
+ # Externally callable method: save-tags
+ #
Page instproc www-save-tags {} {
::xowiki::Page save_tags \
@@ -1321,8 +1323,8 @@
}
#
- # externally callable method: validate-attribute
- #
+ # Externally callable method: validate-attribute
+ #
Page instproc www-validate-attribute {} {
set field_names [:field_names]
@@ -1351,8 +1353,8 @@
}
#
- # externally callable method: view
- #
+ # Externally callable method: view
+ #
Page instproc www-view {{content ""}} {
# The method "view" is used primarily for the toplevel call, when
@@ -1376,7 +1378,7 @@
#
set object_type [$page_package_id get_parameter object_type [:info class]]
set rev_link [$page_package_id make_link -with_entities 0 [self] revisions]
-
+
if {[$context_package_id query_parameter m ""] eq "edit"} {
set view_link [$page_package_id make_link -with_entities 0 [self] view return_url]
set edit_link ""
@@ -1390,8 +1392,8 @@
} else {
set new_link [:new_link $page_package_id]
}
-
- set admin_link [$context_package_id make_link -privilege admin -link admin/ $context_package_id {} {}]
+
+ set admin_link [$context_package_id make_link -privilege admin -link admin/ $context_package_id {} {}]
set index_link [$context_package_id make_link -privilege public -link "" $context_package_id {} {}]
set toc_link [$context_package_id make_link -privilege public -link "list" $context_package_id {} {}]
set import_link [$context_package_id make_link -privilege admin -link "" $context_package_id {} {}]
@@ -1406,8 +1408,8 @@
set notification_subscribe_link \
[export_vars -base /notifications/request-new \
{{return_url $notifications_return_url}
- {pretty_name $notification_text}
- {type_id $notification_type}
+ {pretty_name $notification_text}
+ {type_id $notification_type}
{object_id $context_package_id}}]
set notification_image \
" -1} {
#if {$form_vars} {
#set auto_field_in_form($f) 1
#}
set reduced_attributes [lreplace $reduced_attributes $p $p]
- }
+ }
}
- #:msg reduced_attributes(after)=$reduced_attributes
+ #:msg reduced_attributes(after)=$reduced_attributes
#:msg fields_from_form=[array names :__field_in_form]
set field_names [list _name]
@@ -2405,7 +2411,7 @@
$f help_text ""
}
}
- if {[$f exists transmit_field_always]
+ if {[$f exists transmit_field_always]
&& "::xowiki::formfield::omit" in [$f info mixin]} {
# Never omit these fields, this would cause problems with
# autonames and empty languages. Set these fields to hidden
@@ -2428,7 +2434,7 @@
}
}
-::xo::library source_dependent
+::xo::library source_dependent
#