Class ::xowiki::WikiForm (public)
::xotcl::Class ::xowiki::WikiForm
Defined in /var/www/openacs.org/packages/xowiki/tcl/xowiki-form-procs.tcl
Form Class for XoWiki Pages. You can manipulate the form elements shown by editing the field_list. The following elements are mandatory in field_list and should never be left out:
- name
- item_id
- Testcases:
- No testcase defined.
Source code: namespace eval ::xowiki {} ::nsf::object::alloc ::xotcl::Class ::xowiki::WikiForm {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object} ::xowiki::WikiForm instproc data_from_form {{-new 0}} { if {[${:data} exists_form_parameter text.format:graph]} { ${:data} set mime_type [${:data} form_parameter text.format] } if {$new && [[${:data} set package_id] get_parameter production_mode:boolean 0]} { ${:data} set publish_status production } :tidy } ::xowiki::WikiForm instproc on_submit args { #:log "--form on_submit $args <[${:data} info vars]> " :var page_order [${:data} set page_order] next } ::xowiki::WikiForm instproc new_request {} { # # Get the defaults from the slots and set it in the data. # This should not be necessary with xotocl 1.6.* # foreach f [:field_list] { set s [${:data} find_slot $f] if {$s ne "" && [$s exists default] && [$s default] ne ""} { #:msg "new_request $f default = '[$s default]'" ${:data} set $f [$s default] } } # # set the following defaults manually # ${:data} set creator [::xo::get_user_name [::xo::cc user_id]] if {[${:data} name] eq ""} { set nls_language [[${:data} package_id] default_locale] ${:data} set nls_language $nls_language } next } ::xowiki::WikiForm instproc tidy {} { upvar #[template::adp_level] text text if {[info exists text]} { lassign [:var text] text format if {[info exists format]} { :var text [list [list [::xowiki::tidy clean $text] $format]] } } } ::xowiki::WikiForm instproc new_data {} { :data_from_form -new 1 ${:data} set __autoname_prefix [string range [${:data} set nls_language] 0 1]: set item_id [next] ${:data} set creation_user [::xo::cc user_id] :update_references return $item_id } ::xowiki::WikiForm instproc update_references {} { if {![:istype PageInstanceForm]} { ### danger: update references does an ad_eval, which breaks the [template::adp_level] ### ad_form! don't do it in pageinstanceforms. ${:data} render_adp false ${:data} render -update_references all } # Delete the link cache entries for this entry. # The logic could be made more intelligent to delete entries is more rare cases, like # in case the file was renamed, but this is more bullet-proof. # # xowiki::LinkCache flush ${:folder_id} [${:data} set item_id] # if {![${:data} istype ::xowiki::Object] && ![${:data} istype ::xowiki::PageTemplate] } { if {[${:data} istype ::xowiki::PageInstance]} { if {[${:data} set instance_attributes] ne ""} { # # Field-less page instances are not notified. Problem? # # :log "--i instance_attributes = <[${:data} set instance_attributes]>" ::xowiki::notification::do_notifications -page ${:data} } } else { ::xowiki::notification::do_notifications -page ${:data} } } if {[apm_version_names_compare [ad_acs_version] 5.3.0d4] == 1} { application_data_link::update_links_from -object_id [${:data} set item_id] -text [${:data} set text] } } ::xowiki::WikiForm instproc after_submit item_id { #:log "--form after submit" set link [:submit_link] if {$link eq "."} { # we can determine submit link only after nls_language # is returned from the user :submit_link [${:data} pretty_link] } next } ::xowiki::WikiForm instproc edit_request args { if {[${:data} set creator] eq ""} { ${:data} set creator [::xo::get_user_name [::xo::cc user_id]] } next } ::xowiki::WikiForm instproc edit_data {} { #:log "--form edit_data " :data_from_form -new 0 set item_id [next] :update_references return $item_id } ::xowiki::WikiForm instproc mkFields {} { set __fields "" set field_list [:field_list] set show_page_order [[${:data} package_id] show_page_order] if {!$show_page_order} { :f.page_order "= hidden" } if {${:autoname}} { :f.name "= hidden,optional"} set form_fields [list] foreach __field $field_list { # if there is no field spec, use the default from the slot definitions set __spec [expr {[info exists :f.$__field] ? [set :f.$__field] : "="}] set __wspec [lindex $__spec 0] #:msg "$__field: wspec=$__wspec, spec=$__spec" # check first if we have widget_specs. # TODO: this part is likely to be removed in the future. if { [${:data} istype ::xowiki::PlainPage] && $__field eq "text" || [${:data} istype ::xowiki::File] && $__field eq "text" } { set s "" } else { set s [${:data} get_rich_text_spec $__field ""] } if {$s ne ""} { #:msg "we got richtext spec for $__field = '$s'" set __spec $s set __wspec [lindex $__spec 0] # # Old style folder spec substitution. Ugly. # if {[:folderspec] ne ""} { # append the folder spec to its options set __newspec [list $__wspec] foreach __e [lrange $__spec 1 end] { lassign $__e __name __value if {$__name eq "options"} {lappend __value {*}[:folderspec]} lappend __newspec [list $__name $__value] } #:msg "--F rewritten spec is '$__newspec'" set __spec $__newspec } } elseif {[lindex $__wspec 0] eq "="} { # # Get the information from the attribute definitions and given # specs. # set f [${:data} create_raw_form_field -name $__field -slot [${:data} find_slot $__field] -spec [lindex $__spec 1] ] #:log SPEC=[lindex $__spec 1] if {[$f istype ::xowiki::formfield::richtext] && [:folderspec] ne ""} { # Insert the folder_id and the script_dir into the spec for # the oacsfs plugin to access the correct filestore instance # and to find the script directory foreach {key value} [:folderspec] { $f $key $value } # We have to reinitialize for exporting these values asWidgetSpec $f initialize } set __spec ${__field}:[$f asWidgetSpec] set __wspec [lindex $__spec 0] lappend form_fields $f } if {[string first "richtext" $__wspec] > -1} { # ad_form does a subst, therefore, escape esp. the JavaScript stuff set __spec [string map {\[ \\[ \] \\] \$ \\$ \\ \\\\} $__spec] } #:msg "--F field <$__field> = $__spec" append __fields [list $__spec] \n } # setting form fields for later use in validator # ${:data} show_fields $form_fields set :form_fields $form_fields set :fields $__fields } ::xowiki::WikiForm instparametercmd submit_link ::xowiki::WikiForm instparametercmd with_categories ::xowiki::WikiForm instparametercmd f.creator ::xowiki::WikiForm instparametercmd f.page_order ::xowiki::WikiForm instparametercmd f.description ::xowiki::WikiForm instparametercmd f.text ::xowiki::WikiForm instparametercmd validate ::xowiki::WikiForm instparametercmd autoname ::xowiki::WikiForm instparametercmd f.nls_language ::xowiki::WikiForm instparametercmd f.name ::xowiki::WikiForm instparametercmd f.title ::xowiki::WikiForm instparametercmd folderspec ::xowiki::WikiForm instparametercmd f.item_id ::xowiki::WikiForm instparametercmd field_list ::nsf::relation::set ::xowiki::WikiForm superclass ::Generic::Form ::nx::slotObj -container slot ::xowiki::WikiForm ::xowiki::WikiForm::slot eval {set :__parameter { {field_list {item_id name page_order title creator text description nls_language}} {f.item_id {item_id:key}} {f.name "="} {f.page_order "="} {f.title "="} {f.creator "="} {f.text "= richtext,extraPlugins=xowikiimage"} {f.description "="} {f.nls_language "="} {validate { {name {\[::xowiki::validate_name\]} {Another item with this name exists already in this folder} } {name {[string length \$name] < 4000} {The name is too long. Please enter a value of at most 4000 characters long} } {page_order {\[::xowiki::validate_form_field page_order\]} {Page Order invalid; might only contain upper and lowercase letters, underscore, digits and dots}} }} {with_categories true} {submit_link "view"} {folderspec ""} {autoname 0} }} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::f.creator {set :accessor public set :configurable true set :convert false set :default = set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::f.creator set :methodname f.creator set :multiplicity 1..1 set :name f.creator set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::f.nls_language {set :accessor public set :configurable true set :convert false set :default = set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::f.nls_language set :methodname f.nls_language set :multiplicity 1..1 set :name f.nls_language set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::f.name {set :accessor public set :configurable true set :convert false set :default = set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::f.name set :methodname f.name set :multiplicity 1..1 set :name f.name set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::field_list {set :accessor public set :configurable true set :convert false set :default {item_id name page_order title creator text description nls_language} set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::field_list set :methodname field_list set :multiplicity 1..1 set :name field_list set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::folderspec {set :accessor public set :configurable true set :convert false set :default {} set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::folderspec set :methodname folderspec set :multiplicity 1..1 set :name folderspec set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::f.description {set :accessor public set :configurable true set :convert false set :default = set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::f.description set :methodname f.description set :multiplicity 1..1 set :name f.description set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::f.page_order {set :accessor public set :configurable true set :convert false set :default = set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::f.page_order set :methodname f.page_order set :multiplicity 1..1 set :name f.page_order set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::f.title {set :accessor public set :configurable true set :convert false set :default = set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::f.title set :methodname f.title set :multiplicity 1..1 set :name f.title set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::f.item_id {set :accessor public set :configurable true set :convert false set :default item_id:key set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::f.item_id set :methodname f.item_id set :multiplicity 1..1 set :name f.item_id set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::with_categories {set :accessor public set :configurable true set :convert false set :default true set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::with_categories set :methodname with_categories set :multiplicity 1..1 set :name with_categories set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::submit_link {set :accessor public set :configurable true set :convert false set :default view set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::submit_link set :methodname submit_link set :multiplicity 1..1 set :name submit_link set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::f.text {set :accessor public set :configurable true set :convert false set :default {= richtext,extraPlugins=xowikiimage} set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::f.text set :methodname f.text set :multiplicity 1..1 set :name f.text set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::autoname {set :accessor public set :configurable true set :convert false set :default 0 set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::autoname set :methodname autoname set :multiplicity 1..1 set :name autoname set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::WikiForm::slot::validate {set :accessor public set :configurable true set :convert false set :default { {name {\[::xowiki::validate_name\]} {Another item with this name exists already in this folder} } {name {[string length \$name] < 4000} {The name is too long. Please enter a value of at most 4000 characters long} } {page_order {\[::xowiki::validate_form_field page_order\]} {Page Order invalid; might only contain upper and lowercase letters, underscore, digits and dots}} } set :defaultmethods {} set :disposition alias set :domain ::xowiki::WikiForm set :incremental 0 set :manager ::xowiki::WikiForm::slot::validate set :methodname validate set :multiplicity 1..1 set :name validate set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} namespace eval ::xowiki {::namespace export Menu YUIMenuBar YUIMenuBarItem YUIMenu YUIMenuItem YUIMenuItemList YUIContextMenu YUIContextMenuItem}XQL Not present: Generic, PostgreSQL, Oracle