Index: openacs-4/packages/acs-templating/www/doc/demo/index.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/index.html,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/acs-templating/www/doc/demo/index.html 13 Feb 2006 12:37:52 -0000 1.11
+++ openacs-4/packages/acs-templating/www/doc/demo/index.html 13 Feb 2006 13:11:12 -0000 1.12
@@ -447,6 +447,23 @@
View |
+
+ Add page group caching to pagination (no looks difference) |
+
+
+ index
+ add-edit
+ delete
+ |
+
+ index
+ |
+
+ index
+ |
+ View |
+
+
Forms
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.adp 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,6 @@
+
+@page_title@
+@context;noquote@
+
+
+
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.tcl 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,144 @@
+# packages/acs-templating/www/doc/demo/list8/add-edit.tcl
+ad_page_contract {
+
+ @author Don Baccus (dhogaza@pacifier.com)
+ @creation-date 2000-10-23
+ @cvs-id $Id: add-edit.tcl,v 1.1 2006/02/13 13:11:12 jiml Exp $
+
+ Example script that allows for the creation or editing of a simple note
+ object type, using ad_form and package Tcl API tools.
+
+} -query {
+ template_demo_note_id:integer,notnull,optional
+} -properties {
+ context:onevalue
+ page_title:onevalue
+}
+
+# When using ad_form to generate or edit acs_objects, the object type's
+# key column must be specified in ad_page_contract as is done above,
+# and defined with the type "key" in ad_form. This enables the use of
+# the various request and submission code blocks.
+
+set package_id [ad_conn package_id]
+
+ad_form -form {
+
+ # The "note" object type's key
+
+ template_demo_note_id:key
+
+ # "title" is of type text and will use a "text" widget.
+
+ {title:text \
+ {label Title}
+ {html {size 20}}
+ }
+
+ # "body" is of type text and will use a "textarea" widget.
+
+ {body:text(textarea) \
+ {label Body}
+ {html {rows 10 cols 40 wrap soft}}
+ }
+
+ # 'color' is a text using a text widget
+
+ {color:text \
+ {label "Color"}
+ {htmo {size 20}}
+ }
+
+} -new_request {
+
+ # By convention packages only allow a user to create new objects if the user has
+ # the "create" privilege on the package instance itself.
+
+ permission::require_permission -object_id $package_id -privilege create
+
+ # Customize the page title to reflect the fact that this form is used to
+ # create a new note.
+
+ set page_title "New Note"
+
+} -edit_request {
+
+ permission::require_permission -object_id $note_id -privilege write
+
+ # Customize the page title to reflect the fact that this form is used to
+ # edit an existing note.
+
+ set page_title "Edit Note"
+
+ # Fill the form with the values from the note we're editing.
+
+ db_1row note_select {}
+
+} -on_validation_error {
+
+ # There was an error in the form, let the page title reflect this.
+
+ set page_title "Error in submission"
+
+} -new_data {
+
+ # Create a new note.
+
+ # Generate the new object automatically from the data set in the form. Standard
+ # acs_object attributes like creation_user are set automatically.
+
+ package_instantiate_object \
+ -var_list [list [list context_id $package_id]] \
+ -form_id add-edit \
+ template_demo_note
+
+} -edit_data {
+
+ # Currently we need to update our object manually ...
+
+ set modifying_user [ad_conn user_id]
+ set modifying_ip [ad_conn peeraddr]
+
+ db_transaction {
+ db_dml object_update {}
+ db_dml template_demo_note_update {}
+ }
+
+} -after_submit {
+
+ # We've successfully processed the submission.
+ # Clear the pagination cache.
+
+ cache flush notes*
+
+ # send the user back to the index page
+
+ ad_returnredirect "./"
+
+ # NOTE! guess what, we wouldn't be done here; there is a problem:
+ # notice that when you add a note when you have filters active,
+ # it doesn't remember your filters when you come back from editing.
+ #
+ # we've decided this is beyond the scope of this tutorial and you
+ # can learn more by studying the function export_vars (which would
+ # be applied to the filter variables)
+
+ # ad_returnredirect returns after redirecting the user, so abort the script rather
+ # than fall through to the display code. Failure to abort the script will burden
+ # your server with needless template processing, though the user won't notice due to
+ # having been redirected.
+
+ ad_script_abort
+
+}
+
+# The following is only executed if we did not process a valid submission, in other
+# words on the initial "new" or "edit" form request or after a submission which
+# contained errors. Add the page title to the breadcrumb context bar.
+
+set context [list $page_title]
+
+# Display the form, blank if we're processing a "new" request, filled with data if we're
+# processing an "edit" request or a submitted form that contains errors.
+
+ad_return_template
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/add-edit.xql 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,30 @@
+
+
+
+
+
+ select title, body
+ from notes
+ where note_id = :note_id
+
+
+
+
+
+ update acs_objects
+ set modifying_user = :modifying_user,
+ modifying_ip = :modifying_ip
+ where object_id = :note_id
+
+
+
+
+
+ update notes
+ set title = :title,
+ body = :body
+ where note_id = :note_id
+
+
+
+
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/delete-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/delete-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/delete-oracle.xql 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,17 @@
+
+
+
+ oracle8.1.6
+
+
+
+
+ begin
+ note.del(:note_id);
+ end;
+
+
+
+
+
+
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/delete-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/delete-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/delete-postgresql.xql 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+ postgresql7.1
+
+
+
+
+ select note__delete( :note_id );
+
+
+
+
+
+
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/delete.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/delete.tcl 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,26 @@
+# packages/notes/www/delete.tcl
+
+ad_page_contract {
+
+ @author rhs@mit.edu
+ @creation-date 2000-10-23
+ @cvs-id $Id: delete.tcl,v 1.1 2006/02/13 13:11:12 jiml Exp $
+} {
+ template_demo_note_id:integer,notnull,multiple
+}
+
+foreach template_demo_note_id $template_demo_note_id {
+ ad_require_permission $template_demo_note_id delete
+
+ package_exec_plsql \
+ -var_list [list [list template_demo_note_id $template_demo_note_id]] \
+ template_demo_note \
+ del
+}
+
+# We've successfully processed the submission.
+# Clear the pagination cache.
+
+cache flush notes*
+
+ad_returnredirect "./"
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/index-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/index-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/index-oracle.xql 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,35 @@
+
+
+ oracle8.1.6
+
+
+
+ select note_id, title, body,
+ decode(acs_permission.permission_p(note_id,
+ :user_id,
+ 'write'),
+ 't', 1,
+ 'f', 0) as write_p,
+ decode(acs_permission.permission_p(note_id,
+ :user_id,
+ 'admin'),
+ 't', 1,
+ 'f', 0) as admin_p,
+ decode(acs_permission.permission_p(note_id,
+ :user_id,
+ 'delete'),
+ 't', 1,
+ 'f', 0) as delete_p
+ from notes n, acs_objects o
+ where n.note_id = o.object_id
+ and o.context_id = :package_id
+ and exists (select 1
+ from acs_object_party_privilege_map
+ where object_id = note_id
+ and party_id = :user_id
+ and privilege = 'read')
+ order by creation_date
+
+
+
+
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/index-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/index-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/index-postgresql.xql 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,54 @@
+
+
+ postgresql7.1
+
+
+
+
+ select
+ n.template_demo_note_id,
+ n.title,
+ n.color,
+ to_char(o.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date,
+ p.first_names || ' ' || p.last_name as creation_user_name
+ from
+ template_demo_notes n,
+ acs_objects o,
+ persons p
+ where n.template_demo_note_id = o.object_id
+ and p.person_id = o.creation_user
+ and exists (select 1
+ from acs_object_party_privilege_map
+ where object_id = n.template_demo_note_id
+ and party_id = :user_id
+ and privilege = 'read')
+ [template::list::filter_where_clauses -and -name notes]
+ [template::list::orderby_clause -orderby -name notes]
+
+
+
+
+
+
+ select
+ n.template_demo_note_id,
+ n.title,
+ n.color,
+ to_char(o.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date,
+ p.first_names || ' ' || p.last_name as creation_user_name
+ from
+ template_demo_notes n,
+ acs_objects o,
+ persons p
+ where n.template_demo_note_id = o.object_id
+ and p.person_id = o.creation_user
+ and exists (select 1
+ from acs_object_party_privilege_map
+ where object_id = n.template_demo_note_id
+ and party_id = :user_id
+ and privilege = 'read')
+ [template::list::page_where_clause -and -name notes -key template_demo_note_id]
+
+
+
+
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/index.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/index.adp 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,15 @@
+
+Notes
+@context;noquote@
+
+
+
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/index.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/index.tcl 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,96 @@
+# main index page for notes.
+
+ad_page_contract {
+
+ @author rhs@mit.edu
+ @creation-date 2000-10-23
+ @cvs-id $Id: index.tcl,v 1.1 2006/02/13 13:11:12 jiml Exp $
+} -query {
+ orderby:optional
+ color_filter_value:optional
+ page:optional
+} -properties {
+ notes:multirow
+ context:onevalue
+ create_p:onevalue
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_conn user_id]
+
+set context [list]
+set create_p [ad_permission_p $package_id create]
+
+set actions [list]
+
+if { $create_p } {
+ lappend actions "Create Note" add-edit "Create Note"
+}
+
+set color_choices {
+ {Blue blue}
+ {Green green}
+ {Purple purple}
+ {Red red}
+ {Orange orange}
+ {Yellow yellow}
+}
+
+template::list::create -name notes \
+ -multirow template_demo_notes \
+ -key "template_demo_note_id" \
+ -page_size 3 \
+ -page_query_name template_demo_notes_paginate \
+ -actions $actions \
+ -bulk_actions {
+ "Delete Checked Notes" "delete" "Delete Checked Notes"
+ } \
+ -elements {
+ title {
+ label "Title of Note"
+ link_url_col view_url
+ }
+ creation_user_name {
+ label "Owner of Note"
+ }
+ creation_date {
+ label "When Note Created"
+ }
+ color {
+ label "Color"
+ }
+ } \
+ -filters {
+ color_filter_value {
+ label "Color"
+ where_clause {
+ n.color = :color_filter_value
+ }
+ values $color_choices
+ }
+ } \
+ -orderby {
+ default_value title,asc
+ title {
+ label "Title of Note"
+ orderby n.title
+ }
+ creation_user_name {
+ label "Owner of Note"
+ orderby creation_user_name
+ }
+ creation_date {
+ label "When Note Created"
+ orderby o.creation_date
+ }
+ color {
+ label "Color"
+ orderby n.color
+ }
+ }
+
+db_multirow -extend { view_url } template_demo_notes template_demo_notes {} {
+ set view_url [export_vars -base view-one { template_demo_note_id }]
+}
+
+ad_return_template
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/view-one.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/view-one.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/view-one.adp 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,5 @@
+
+@title;noquote@
+@context;noquote@
+
+@body;noquote@
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/doc/demo/list9/view-one.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/demo/list9/view-one.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/doc/demo/list9/view-one.tcl 13 Feb 2006 13:11:12 -0000 1.1
@@ -0,0 +1,22 @@
+ad_page_contract {
+ @author Neophytos Demetriou
+ @creation-date 2001-09-02
+} {
+ note_id:integer,notnull
+} -properties {
+ context:onevalue
+ title:onevalue
+ body:onevalue
+}
+
+set context [list "One note"]
+
+db_1row note_select {
+ select title, body
+ from notes
+ where note_id = :note_id
+}
+
+set body [ad_text_to_html -- $body]
+
+ad_return_template