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.53 -r1.54 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 2 May 2007 10:13:39 -0000 1.53 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 9 May 2007 13:19:23 -0000 1.54 @@ -810,6 +810,10 @@ Class File -array set require_permission { download none } + Class Form -array set require_permission { + new {{item_id write}} + list {{package_id admin}} + } } Index: openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/Attic/xowiki-portlet-procs.tcl,v diff -u -r1.43 -r1.44 --- openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 2 May 2007 10:13:39 -0000 1.43 +++ openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 9 May 2007 13:19:23 -0000 1.44 @@ -1339,8 +1339,15 @@ $p set unresolved_references 0 #$p set render_adp 0 - set content [$p get_content] - set content [string map [list "\{\{" "\\\{\{"] $content] + switch [$p info class] { + ::xowiki::Form { + set content [$p render] + } + default { + set content [$p get_content] + set content [string map [list "\{\{" "\\\{\{"] $content] + } + } regexp {^.*:([^:]+)$} $name _ anchor append output "" \ $edit_markup \ @@ -1685,3 +1692,76 @@ } } + + +namespace eval ::xowiki::portlet { + ############################################################################# + Class create form-menu \ + -superclass ::xowiki::Portlet \ + -parameter { + {__decoration none} + {parameter_declaration { + {-form_item_id:integer,required} + }} + } + + form-menu instproc render {} { + my get_parameters + # todo return_url + my instvar __including_page + set base [$package_id pretty_link [$__including_page name]] + set new_link [$package_id make_link -link $base $__including_page new return_url] + set answer_link [$package_id make_link -link $base $__including_page list return_url] + set sql [::xowiki::FormInstance instance_select_query \ + -count true \ + -with_subtypes false \ + -from_clause ", xowiki_page_instance p" \ + -where_clause " p.page_template = $form_item_id and p.page_instance_id = cr.revision_id " \ + -folder_id [$package_id folder_id]] + set count [db_list [my qn count] $sql] + return "
\ + fill out · list answers ($count) +
" + } + + Class create form-instances \ + -superclass ::xowiki::Portlet \ + -parameter { + {__decoration none} + {parameter_declaration { + {-form_item_id:integer,required} + {-orderby "last_modified,desc"} + }} + } + + form-instances instproc render {} { + my get_parameters + + ::xowiki::Page requireCSS "/resources/acs-templating/lists.css" + TableWidget t1 -volatile \ + -columns { + Field last_modified -label "Modification Date" -orderby last_modified + Field creation_user -label "By User" -orderby creation_user + AnchorField view -label "View" + } + + foreach {att order} [split $orderby ,] break + set sql [::xowiki::FormInstance instance_select_query \ + -select_attributes "publish_date creation_user" \ + -from_clause ", xowiki_page_instance p" \ + -with_subtypes 0 \ + -order_clause "order by $att $order" \ + -where_clause " p.page_template = $form_item_id and p.page_instance_id = cr.revision_id " \ + -folder_id [$package_id folder_id]] + + db_foreach [my qn get_pages] $sql { + t1 add \ + -view $name \ + -view.href [$package_id pretty_link $name] \ + -creation_user [::xo::get_user_name $creation_user] \ + -last_modified $publish_date + } + return [t1 asHTML] + } +} + \ No newline at end of file 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.91 -r1.92 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 2 May 2007 10:13:39 -0000 1.91 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 9 May 2007 13:19:23 -0000 1.92 @@ -67,6 +67,7 @@ ::Generic::Attribute new -attribute_name instance_attributes -datatype text \ -pretty_name "Instance Attributes" } \ + -parameter {page_template instance_attributes} \ -form ::xowiki::PageInstanceForm \ -edit_form ::xowiki::PageInstanceEditForm @@ -76,6 +77,18 @@ -mime_type text/xotcl \ -form ::xowiki::ObjectForm + ::Generic::CrClass create Form -superclass Page \ + -pretty_name "XoWiki Form" -pretty_plural "XoWiki Forms" \ + -table_name "xowiki_form" -id_column "xowiki_form_id" \ + -cr_attributes { + ::Generic::Attribute new -attribute_name form_constraints -datatype text \ + -pretty_name "Form Constraints" + } \ + -form ::xowiki::WikiForm + ::Generic::CrClass create FormInstance -superclass PageInstance \ + -pretty_name "XoWiki FormInstance" -pretty_plural "XoWiki FormInstances" \ + -table_name "xowiki_form_instance" -id_column "xowiki_form_instance_id" \ + -form ::xowiki::WikiForm # # create various extra tables, indices and views @@ -835,17 +848,16 @@ return $spec } - PageInstance instproc get_content {} { + PageInstance instproc get_text_from_template {} { my instvar page_template #my log "-- fetching page_template = $page_template" ::Generic::CrItem instantiate -item_id $page_template $page_template destroy_on_cleanup - #if {[my set instance_attributes] eq ""} { - # set T [my adp_subst [$page_template set text]] - # return [my substitute_markup $T] - #} - set template [$page_template set text] - set T [my adp_subst [lindex $template 0]] + return [lindex [$page_template set text] 0] ;# assuming html text with content type + } + + PageInstance instproc get_content {} { + set T [my adp_subst [my get_text_from_template]] return [my substitute_markup [list $T [lindex $template 1]]] } PageInstance instproc template_vars {content} { @@ -911,6 +923,98 @@ expr {[$payload exists $var] ? [$payload set $var] : $default} } + # + # Methods of ::xowiki::Form + # + Form instproc render {-update_references:switch} { + set html [next] + append html [my include_portlet [list form-menu -form_item_id [my item_id]]] + return $html + } + + Form instproc new {} { + my instvar package_id + my log "--new form_item_id=[my item_id]" + set f [FormInstance new -destroy_on_cleanup -page_template [my item_id] -instance_attributes [list]] + $f parent_id [my parent_id] + $f package_id $package_id + $f save_new + $package_id returnredirect \ + [my query_parameter "return_url" [$package_id pretty_link [$f name]]?m=edit] + } + + Form instproc list {} { + my view [my include_portlet [list form-instances -form_item_id [my item_id]]] + } + + # + # Methods of ::xowiki::FormInstance + # + FormInstance instproc provide_value {att value} { + my instvar root + set fields [$root selectNodes "//*\[@name='$att'\]"] + # my msg "found field = $fields xp=//*\[@name='$att'\]" + foreach field $fields { + if {[$field nodeName] ne "input"} continue + set type [expr {[$field hasAttribute type] ? [$field getAttribute type] : "text"}] + # the switch should be really different objects ad classes...., but thats HTML, anyhow. + switch $type { + checkbox {$field setAttribute checked true} + radio { + set inputvalue [$field getAttribute value] + if {$inputvalue eq $value} { + $field setAttribute checked true + } + } + text { $field setAttribute value $value} + default {my msg "can't handle $type so far $att=$value"} + } + } + } + FormInstance instproc provide_values {} { + foreach {att value} [my instance_attributes] { + my provide_value $att $value + } + } + FormInstance instproc render {} { + my instvar doc root package_id + set form [my get_text_from_template] + dom parse -simple -html $form doc + $doc documentElement root + my provide_values + return [$root asHTML] + } + + FormInstance instproc edit {} { + my instvar page_template doc root package_id + + set form [my get_text_from_template] + dom parse -simple -html $form doc + $doc documentElement root + + $root appendFromList [list input [list type submit] {}] + set form [lindex [$root selectNodes //form] 0] + if {$form eq ""} { + my msg "no form found in page [$page_template name]" + } else { + $form setAttribute action [$package_id pretty_link [my name]]?m=save method POST + } + my provide_values + set result [$root asHTML] + my view $result + } + FormInstance instproc save {} { + my instvar package_id + array set __ia [my set instance_attributes] + foreach {att value} [::xo::cc array get form_parameter] { + set __ia($att) $value + } + my set instance_attributes [array get __ia] + next + $package_id returnredirect \ + [my query_parameter "return_url" [::xo::cc url]] + } + } source [file dirname [info script]]/xowiki-www-procs.tcl 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.48 -r1.49 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 2 May 2007 10:13:39 -0000 1.48 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 9 May 2007 13:19:23 -0000 1.49 @@ -74,7 +74,7 @@ } - Page instproc view {} { + Page instproc view {{content ""}} { # view is used only for the toplevel call, when the xowiki page is viewed # this is not inteded for embedded wiki pages my instvar package_id item_id @@ -88,7 +88,9 @@ $template_file before_render [self] } - set content [my render] + if {$content eq ""} { + set content [my render] + } my log "--after render" set footer [my htmlFooter -content $content] Index: openacs-4/packages/xowiki/www/resources/xowiki.css =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/resources/xowiki.css,v diff -u -r1.17 -r1.18 --- openacs-4/packages/xowiki/www/resources/xowiki.css 25 Mar 2007 16:27:04 -0000 1.17 +++ openacs-4/packages/xowiki/www/resources/xowiki.css 9 May 2007 13:19:23 -0000 1.18 @@ -3,13 +3,19 @@ #at-a-glance td.active {color: #003b53;} #at-a-glance td.today {color: #FFFFFF;} + +div.wiki-menu { + position: relative; right: 0px; + text-align: right; font-family: sans-serif; font-size: 85%;color: #7A7A78 +} + #wikicmds {position: relative; top: -24px; right: 0px; height: 0px; text-align: right; font-family: sans-serif; font-size: 85%;color: #7A7A78;} /*#portal #wikicmds {top: -90px;}*/ div.portlet #wikicmds {float: inherit ! important; top: 0px ! important; height: inherit;} #page-body #wikicmds {top: -30px;} -#wikicmds a, #wikicmds a:visited { color: #7A7A78; text-decoration: none;} +#wikicmds a, #wikicmds a:visited, div.wiki-menu a { color: #7A7A78; text-decoration: none;} #wikicmds a:hover {text-decoration: underline;} #wikicmds a:active {color: rgb(255,153,51);} #cmdbar {