- Publicity: Public Only All
form-procs.tcl
Reusable forms in the forums package
- Location:
- packages/forums/tcl/form-procs.tcl
- Created:
- 2003-11-12
- Author:
- lee@thaum.net
Procedures in this file
- forums::form::forum (public)
- forums::form::forward_message (public)
- forums::form::message (public)
- forums::form::post_message (public)
- forums::form::search (public)
Detailed information
forums::form::forum (public)
forums::form::forum [ -prefix prefix ] form_name
Constructs the elements of a form for creating/editing a forum
- Switches:
- -prefix (optional)
- Parameters:
- form_name (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- web_forum_new, web_forum_view, web_forum_edit, web_forums_message_and_reply
forums::form::forward_message (public)
forums::form::forward_message [ -prefix prefix ] form_name
adds form elements to form_name to allow the user to enter the details of a message they want to forward by email
- Switches:
- -prefix (optional)
- Parameters:
- form_name (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
forums::form::message (public)
forums::form::message [ -optional ] [ -prefix prefix ] form_name
adds form elements to form_name which represent the data held in a forum message
- Switches:
- -optional (optional, boolean)
- -prefix (optional)
- Parameters:
- form_name (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- web_forums_message_and_reply
forums::form::post_message (public)
forums::form::post_message [ -optional ] \ [ -show_anonymous_p show_anonymous_p ] \ [ -show_attachments_p show_attachments_p ] [ -prefix prefix ] \ form_name
adds form elements to a form for the default post message form
- Switches:
- -optional (optional, boolean)
- -show_anonymous_p (optional, defaults to
"1"
)- -show_attachments_p (optional, defaults to
"1"
)- -prefix (optional)
- Parameters:
- form_name (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
forums::form::search (public)
forums::form::search [ -prefix prefix ] form_name
Constructs the elements of a form for searching for a term optionally in a particular forum
- Switches:
- -prefix (optional)
- Parameters:
- form_name (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- web_forum_view, web_forum_edit, web_forums_message_and_reply
Content File Source
ad_library { Reusable forms in the forums package @author lee@thaum.net @creation-date 2003-11-12 } namespace eval forums {} namespace eval forums::form {} d_proc -public forums::form::message { {-optional:boolean} {-prefix {}} form_name } { adds form elements to form_name which represent the data held in a forum message } { ############################## # Form definition # set optional_switch [list] if { $optional_p } { lappend optional_switch -optional } template::element create $form_name ${prefix}subject \ -label [_ forums.Subject] \ -datatype text \ -widget text \ -html {maxlength 200 size 60} \ {*}$optional_switch template::element create $form_name ${prefix}message_body \ -label [_ forums.Body] \ -datatype richtext \ -widget richtext \ -html {rows 20 cols 60 style {width:100%}} \ {*}$optional_switch } d_proc -public forums::form::post_message { {-optional:boolean} {-show_anonymous_p 1} {-show_attachments_p 1} {-prefix {}} form_name } { adds form elements to a form for the default post message form } { template::element create $form_name ${prefix}forum_id \ -label [_ forums.forum_ID] \ -datatype integer \ -widget hidden template::element create $form_name ${prefix}parent_id \ -label [_ forums.parent_ID] \ -datatype integer \ -widget hidden \ -optional template::element create $form_name ${prefix}subscribe_p \ -label [_ forums.Subscribe] \ -datatype text \ -widget hidden \ -optional set options [list [list [_ forums.post_anonymously] 1 ] ] template::element create $form_name ${prefix}anonymous_p \ -label [_ forums.Anonymous] \ -datatype integer \ -widget [expr {$show_anonymous_p ? "checkbox" : "hidden"}] \ -options $options \ -optional set options [list [list [_ forums.No] 0] [list [_ forums.Yes] 1]] template::element create $form_name ${prefix}attach_p \ -label [_ forums.Attach] \ -datatype text \ -widget [expr {$show_attachments_p ? "radio" : "hidden"}] \ -options $options if {$optional_p} { template::element set_properties $form_name ${prefix}forum_id -optional template::element set_properties $form_name ${prefix}attach_p -optional } } d_proc -public forums::form::forward_message { {-prefix {}} form_name } { adds form elements to form_name to allow the user to enter the details of a message they want to forward by email } { template::element create $form_name ${prefix}to_email \ -label [_ forums.Email] \ -datatype email \ -widget text \ -html {size 60} template::element create $form_name ${prefix}subject \ -label [_ forums.Subject] \ -datatype text \ -widget text \ -html {size 80} template::element create $form_name ${prefix}pre_body \ -label [_ forums.Your_Note] \ -datatype text \ -widget textarea \ -html {cols 80 rows 10} } d_proc -public forums::form::search { {-prefix {}} form_name } { Constructs the elements of a form for searching for a term optionally in a particular forum } { template::element create $form_name ${prefix}search_text \ -label [_ forums.Search_1] \ -datatype text \ -widget text template::element create $form_name ${prefix}forum_id \ -label [_ forums.ForumID] \ -datatype text \ -widget hidden \ -optional } d_proc -public forums::form::forum { {-prefix {}} form_name } { Constructs the elements of a form for creating/editing a forum } { template::element create $form_name ${prefix}name \ -label [_ forums.Name] \ -datatype text \ -widget text \ -html {size 60} \ -validate { {expr {[string trim $value] ne ""}} {Forum Name can not be blank} } template::element create $form_name ${prefix}charter \ -label [_ forums.Charter] \ -datatype richtext \ -widget richtext \ -html {cols 60 rows 10 style {width: 100%}} \ -validate { {expr {[string length $value] <= 4000} } {\#forums.charter_max_chars#} } \ -optional template::element create $form_name ${prefix}presentation_type \ -label [_ forums.Presentation] \ -datatype text \ -widget select \ -help_text [_ forums.help_presentation] \ -options [list [list [_ forums.Flat] flat] [list [_ forums.Threaded] threaded]] template::element create $form_name ${prefix}posting_policy \ -label [_ forums.Posting_Policy] \ -datatype text \ -widget select \ -help_text [_ forums.help_posting_policy] \ -options [list [list [_ forums.open] open] [list [_ forums.moderated] moderated] [list [_ forums.closed] closed] ] template::element create $form_name ${prefix}anonymous_allowed_p \ -label [_ forums.post_anonymously] \ -datatype text \ -widget radio \ -options [list [list [_ forums.Yes] t] [list [_ forums.No] f] ] template::element create $form_name ${prefix}new_threads_p \ -label [_ forums.lt_Users_Can_Create_New_] \ -datatype text \ -widget radio \ -help_text [_ forums.help_new_threads] \ -options [list [list [_ forums.Yes] t] [list [_ forums.No] f] ] if {[forum::attachments_enabled_p]} { template::element create $form_name ${prefix}attachments_allowed_p \ -label [_ forums.lt_Users_Can_Add_Attachments] \ -datatype text \ -widget radio \ -options [list [list [_ forums.Yes] t] [list [_ forums.No] f] ] } } # Local variables: # mode: tcl # tcl-indent-level: 4 # indent-tabs-mode: nil # End: