Index: openacs-4/packages/xowiki/tcl/includelet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/includelet-procs.tcl,v diff -u -r1.142 -r1.143 --- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 2 May 2010 14:26:03 -0000 1.142 +++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 17 May 2010 09:24:51 -0000 1.143 @@ -3110,16 +3110,17 @@ method link package_id + parent_id base return_url {label_suffix ""} } form-menu-button instproc render {} { - my instvar package_id base form method return_url label_suffix link + my instvar package_id base form method return_url label_suffix link parent_id if {![info exists link]} { #my msg "[my info class] check-link-package_id=$package_id" - set link [$package_id make_link -link $base $form $method return_url] + set link [$package_id make_link -link $base $form $method return_url parent_id] } if {$link eq ""} { return "" @@ -3140,7 +3141,9 @@ array set "" [::xowiki::PageInstance get_list_from_form_constraints \ -name @table_properties \ -form_constraints [[my form] get_form_constraints -trylocal true]] - set count [[my form] count_usages -package_id [my package_id] -publish_status $(publish_status)] + set count [[my form] count_usages \ + -package_id [my package_id] -parent_id [my parent_id] \ + -publish_status $(publish_status)] my label_suffix " ($count)" next } @@ -3156,6 +3159,8 @@ {__decoration none} {parameter_declaration { {-form_item_id:integer} + {-parent_id} + {-form} {-buttons {new answers}} {-button_objs} {-return_url} @@ -3165,6 +3170,16 @@ form-menu instproc render {} { my get_parameters my instvar __including_page + if {![info exists form_item_id]} { + set form_item_id [::xowiki::Weblog instantiate_forms -forms $form -package_id [$__including_page package_id]] + } + if {[info exists parent_id]} { + if {$parent_id eq "self"} { + set parent_id [$__including_page item_id] + } + } else { + set parent_id [$package_id folder_id] + } if {![info exists button_objs]} { foreach b $buttons { if {[llength $b]>1} { @@ -3179,8 +3194,8 @@ # set form_package_id [$form package_id] ::xowiki::Package require $form_package_id - set obj [form-menu-button-$button new -volatile -package_id $package_id \ - -base [$form_package_id pretty_link [$form name]] -form $form] + set obj [form-menu-button-$button new -volatile -package_id $package_id \ + -base [$form_package_id pretty_link [$form name]] -form $form -parent_id $parent_id] if {[info exists return_url]} {$obj return_url $return_url} lappend button_objs $obj } @@ -3247,20 +3262,21 @@ {parameter_declaration { {-form_item_id:integer} {-form} + {-parent_id} {-orderby "__last_modified,desc"} {-publish_status "ready"} {-field_names} {-extra_form_constraints ""} {-category_id} {-unless} {-where} - {-with_categories} {-csv true} {-voting_form} {-voting_form_form ""} {-voting_form_anon_instances "t"} {-generate} {-with_form_link true} + {-with_categories} {-wf} {-buttons "edit delete"} }} @@ -3279,6 +3295,13 @@ } else { set form_item_ids [list $form_item_id] } + if {[info exists parent_id]} { + if {$parent_id eq "self"} { + set parent_id [$__including_page item_id] + } + } else { + set parent_id [$package_id folder_id] + } set form_constraints $extra_form_constraints\n foreach form_item $form_item_ids { @@ -3406,6 +3429,7 @@ set items [::xowiki::FormPage get_form_entries \ -base_item_ids $form_item_ids \ + -parent_id $parent_id \ -form_fields $form_fields \ -publish_status $publish_status \ -extra_where_clause $extra_where_clause \ Index: openacs-4/packages/xowiki/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v diff -u -r1.208 -r1.209 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 14 May 2010 11:23:19 -0000 1.208 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 17 May 2010 09:24:51 -0000 1.209 @@ -1889,7 +1889,6 @@ delete {{package_id admin}} save-tags login popular-tags login - create-child {{item_id create}} create-new {{parent_id create}} create-or-use {{parent_id create}} } -set default_permission {{package_id write}} @@ -1947,7 +1946,6 @@ delete swa save-tags login popular-tags login - create-child {{item_id create}} create-new {{parent_id create}} create-or-use {{parent_id create}} } @@ -1999,7 +1997,6 @@ delete swa save-tags login popular-tags login - create-child {{item_id create}} create-new {{parent_id create}} create-or-use {{parent_id create}} } @@ -2063,7 +2060,6 @@ delete swa save-tags login popular-tags login - create-child {{item_id create}} create-new {{parent_id create}} create-or-use {{parent_id create}} } Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.393 -r1.394 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 4 May 2010 12:29:04 -0000 1.393 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 17 May 2010 09:24:51 -0000 1.394 @@ -1902,12 +1902,21 @@ PageTemplate parameter { {render_adp 0} } - PageTemplate instproc count_usages {{-package_id 0} {-publish_status ready}} { - return [::xowiki::PageTemplate count_usages -package_id $package_id \ + PageTemplate instproc count_usages { + {-package_id 0} + {-parent_id 0} + {-publish_status ready} + } { + return [::xowiki::PageTemplate count_usages -package_id $package_id -parent_id $parent_id \ -item_id [my item_id] -publish_status $publish_status] } - PageTemplate proc count_usages {{-package_id:integer 0} -item_id:required {-publish_status ready}} { + PageTemplate proc count_usages { + {-package_id:integer 0} + {-parent_id:integer 0} + -item_id:required + {-publish_status ready} + } { set publish_status_clause [::xowiki::Includelet publish_status_clause -base_table i $publish_status] if {$package_id} { set bt "xowiki_page_instancei" @@ -1916,14 +1925,15 @@ set bt "xowiki_page_instance" set package_clause "" } - my ds "select count(page_instance_id) from $bt, cr_items i \ - where page_template = $item_id \ - $publish_status_clause $package_clause \ - and page_instance_id = coalesce(i.live_revision,i.latest_revision)" + if {$parent_id} { + set parent_id_clause "and parent_id = $parent_id" + } else { + set parent_id_clause "" + } set count [db_string [my qn count_usages] \ "select count(page_instance_id) from $bt, cr_items i \ where page_template = $item_id \ - $publish_status_clause $package_clause \ + $publish_status_clause $package_clause $parent_id_clause \ and page_instance_id = coalesce(i.live_revision,i.latest_revision)"] return $count } @@ -2739,11 +2749,13 @@ # its pretty value in variable substitutions. # if {![my exists_property $varname]} { - # We check for current_user here. In case the property does - # not exist, we provide a value from the currently connected - # user. + # We check for special variables here (such as current_user or + # current_url). In case the property does not exist, we provide + # a value from the current connection context. if {$varname eq "current_user"} { set value [::xo::cc set untrusted_user_id] + } elseif {$varname eq "current_url"} { + set value [::xo::cc url] } else { set value "" } 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 -r1.261 -r1.262 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 4 May 2010 12:29:04 -0000 1.261 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 17 May 2010 09:24:51 -0000 1.262 @@ -1383,7 +1383,7 @@ return } } - } elseif {[my form_parameter __form_action ""] eq "view-form-data" && ![my exists __feedback_mode]} { + } elseif {[my form_parameter __form_action ""] eq "view-form-data" && ![my exists __feedback_mode]} { # We have nothing to save (maybe everything is read.only). Check # __feedback_mode to prevent recursive loops. set redirect_method [my form_parameter __form_redirect_method "view"] @@ -1891,10 +1891,6 @@ return $f } - Page instproc create-child {{-view_method edit} {-name ""} {-nls_language ""}} { - my create-new -parent_id [my item_id] -view_method $view_method -name $name -nls_language $nls_language - } - Page instproc create-new {-parent_id {-view_method edit} {-name ""} {-nls_language ""}} { my instvar package_id set original_package_id $package_id @@ -1925,20 +1921,36 @@ } } + # TODO: the following calls are here temporarily for posting + # content from manually added forms (e.g. linear forum). The + # following should be done: + # - create an includelet to create the form markup automatically + # - validate and transform input as usual + # We should probably allow as well controlling autonaming and + # setting of publish_status, and probhibit empty postings. + + set text_to_html [my form_parameter "__text_to_html" ""] + foreach key {_text} { + if {[my exists_form_parameter $key]} { + set __value [my form_parameter $key] + if {[lsearch $text_to_html $key] > -1} { + set __value [ad_text_to_html $__value] + } + lappend default_variables [string range $key 1 end] $__value + } + } + + # # To create form_pages in different places than the form, provide # fp_parent_id and fp_package_id. # # The following construct is more complex than necessary to - # provide more backward compatibility. Child objects should be - # always created via the create create-child method. The passed + # provide backward compatibility. Note that the passed-in # parent_id has priority over the other measures to obtain it. # if {![info exists parent_id]} { if {![my exists parent_id]} {my parent_id [$package_id folder_id]} set fp_parent_id [my query_parameter "parent_id" [my parent_id]] - if {[my parent_id] ne $fp_parent_id} { - my log "consider using the create-child method instead of passing a parent_id via query parameter" - } } else { set fp_parent_id $parent_id } @@ -1953,23 +1965,18 @@ -source_item_id [my query_parameter source_item_id ""]] $f save_new - - if {[my exists_query_parameter "return_url"]} { - set return_url [my query_parameter "return_url"] - } - if {[my exists_query_parameter "template_file"]} { - set template_file [my query_parameter "template_file"] - } + foreach var {return_url template_file title detail_link text} { if {[my exists_query_parameter $var]} { set $var [my query_parameter $var] } } - - $package_id returnredirect \ - [export_vars -base [$package_id pretty_link -parent_id [$f parent_id] [$f name]] \ - [list [list m $view_method] return_url template_file title detail_link text]] - + set form_redirect [my form_parameter "__form_redirect" ""] + if {$form_redirect eq ""} { + set form_redirect [export_vars -base [$package_id pretty_link -parent_id [$f parent_id] [$f name]] \ + [list [list m $view_method] return_url template_file title detail_link text]] + } + $package_id returnredirect $form_redirect set package_id $original_package_id }