Index: openacs-4/packages/package-builder/package-builder.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/package-builder.info,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/package-builder.info 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,36 @@
+
+
+
+
+ Package Builder
+ Package Builders
+ f
+ f
+
+
+
+ oracle
+ postgresql
+
+ Timo Hentschel
+ Package Builder enables to create content types with attributes.
+ From this data a complete package with add/edit/delete/view forms will
+ be created.
+ 2005-01-07
+ 0
+ cognovis GmbH & Co. KG
+ Create packages with versioned data.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/package-builder/catalog/package-builder.en_US.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/catalog/package-builder.en_US.ISO-8859-1.xml,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/catalog/package-builder.en_US.ISO-8859-1.xml 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,63 @@
+
+
+
+ Attributes
+ DB Column Spec
+ Datatype
+ Attribute Name
+ Choice Options
+ Pretty Name
+ Required?
+ Form Widget
+ Cancel and return
+ Continue with delete
+ Boolean
+ Number
+ String
+ Delete
+ Delete Attribute
+ Delete Package
+ Delete Item Type
+ Edit
+ From Item Type
+ From Package
+ Package Builder
+ Edit Attribute
+ Edit Package
+ Edit Item Type
+ Generate Code
+ New Attribute
+ Create New Attribute
+ New Package
+ Create New Package
+ New Item Type
+ Create New Item Type
+ Name
+ No
+ None
+ Package code created
+ Package exists already.
+ Description
+ Package Key
+ Pretty Name
+ Pretty Plural
+ Short Identifier
+ Summary
+ Vendor Name
+ Vendor Url
+ Pretty Item-Description, if used
+ ID Column
+ Type Name
+ Pretty Item-Name, if used
+ Pretty Name
+ Pretty Plural
+ Tablename
+ Pretty Item-Title, if used
+ Item Types
+ Checkbox
+ Radiobuttons
+ Selectbox
+ Textbox
+ Textarea
+ Yes
+
Index: openacs-4/packages/package-builder/sql/postgresql/package-builder-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/sql/postgresql/package-builder-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/sql/postgresql/package-builder-create.sql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,63 @@
+--
+-- Package Builder Package
+--
+-- @author Timo Hentschel (timo@timohentschel.de)
+-- @creation-date 2005-01-07
+--
+
+
+create table pb_packages (
+ pkg_id integer
+ constraint pb_packages_pkg_id_pk
+ primary key,
+ package_id integer
+ constraint pb_packages_package_id_fk
+ references apm_packages,
+ key varchar(50),
+ short_name varchar(5),
+ pretty_name varchar(200),
+ pretty_plural varchar(200),
+ owner_id integer
+ constraint pb_packages_owner_id_fk
+ references users(user_id),
+ summary varchar(1000),
+ vendor_name varchar(200),
+ vendor_url varchar(200),
+ description varchar(1000)
+);
+
+create table pb_types (
+ type_id integer
+ constraint pb_types_type_id_pk
+ primary key,
+ pkg_id integer
+ constraint pb_types_pkg_id_fk
+ references pb_packages,
+ name varchar(200),
+ pretty_name varchar(200),
+ pretty_plural varchar(200),
+ tablename varchar(200),
+ id_column varchar(200),
+ name_pretty varchar(200),
+ title_pretty varchar(200),
+ descr_pretty varchar(200),
+ sort_order integer
+);
+
+create table pb_attributes (
+ attribute_id integer
+ constraint pb_attributes_attribute_id_pk
+ primary key,
+ type_id integer
+ constraint pb_attributes_type_id_fk
+ references pb_types,
+ name varchar(200),
+ pretty_name varchar(200),
+ datatype varchar(20),
+ column_spec varchar(1000),
+ required_p char(1) default 't'
+ constraint pb_attributes_required_p_ck
+ check (required_p in ('t','f')),
+ widget varchar(20),
+ options varchar(1000)
+);
Index: openacs-4/packages/package-builder/sql/postgresql/package-builder-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/sql/postgresql/package-builder-drop.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/sql/postgresql/package-builder-drop.sql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,11 @@
+--
+-- Package Builder Package
+--
+-- @author Timo Hentschel (timo@timohentschel.de)
+-- @creation-date 2005-01-07
+--
+
+
+drop table pb_attributes;
+drop table pb_types;
+drop table pb_packages;
Index: openacs-4/packages/package-builder/tcl/pb-create-catalog-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-catalog-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-catalog-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,79 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::create::catalog {}
+
+ad_proc -public pb::create::catalog::create {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates english catalog file
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+ set types [db_list_of_lists types {}]
+
+ set msg($pkg(key_under)) $pkg(pretty_plural)
+ set msg(Edit) Edit
+ set msg(Delete) Delete
+ set msg(None) None
+ set msg(continue_with_delete) "Continue with Delete"
+ set msg(cancel_and_return) "Cancel and Return"
+ set msg(admin_categories) "Categories Administration"
+
+ foreach one_type $types {
+ util_unlist $one_type type_id type_name pretty_name pretty_plural name_pretty title_pretty descr_pretty
+ set msg($type_name\_Add) "Add $pretty_name"
+ set msg($type_name\_Edit) "Edit $pretty_name"
+ set msg($type_name\_Delete) "Delete $pretty_name"
+ set msg($type_name\_View) "View $pretty_name"
+ set msg($type_name\_New) "New $pretty_name"
+ set msg($type_name\_New2) "Create New $pretty_name"
+ set msg($type_name\_1) $pretty_name
+ set msg($type_name\_2) $pretty_plural
+ if {![empty_string_p $name_pretty]} {
+ set msg($type_name\_Name) $name_pretty
+ }
+ if {![empty_string_p $title_pretty]} {
+ set msg($type_name\_Title) $title_pretty
+ }
+ if {![empty_string_p $descr_pretty]} {
+ set msg($type_name\_Description) $descr_pretty
+ }
+
+ db_foreach attributes {} {
+ set msg($type_name\_$name) $pretty_name
+ if {$datatype == "string" && $widget != "text" && $widget != "textarea"} {
+ foreach opt $options {
+ regsub -all { } [string tolower $opt] {_} opt_under
+ set msg($type_name\_$name\_$opt_under) $opt
+ }
+ }
+ if {$datatype == "boolean"} {
+ set msg(yes) Yes
+ set msg(no) No
+ }
+ }
+ }
+
+ set msgs ""
+ foreach key [lsort -dictionary [array names msg]] {
+ append msgs " $msg($key)\n"
+ }
+
+ set result [subst {
+
+
+$msgs
+
+ }]
+
+ set f [open "$pkg(path)/catalog/$pkg(key).en_US.ISO-8859-1.xml" w]
+ puts $f $result
+ close $f
+}
Index: openacs-4/packages/package-builder/tcl/pb-create-catalog-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-catalog-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-catalog-procs.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+ select type_id, name, pretty_name, pretty_plural, name_pretty,
+ title_pretty, descr_pretty
+ from pb_types
+ where pkg_id = :pkg_id
+ order by sort_order
+
+
+
+
+
+
+
+ select name, pretty_name, datatype, widget, options
+ from pb_attributes
+ where type_id = :type_id
+ order by attribute_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/tcl/pb-create-db-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-db-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-db-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,81 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::create::db {}
+
+ad_proc -public pb::create::db::create {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates the db create scripts
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ set type_list [db_list_of_lists types {}]
+
+ set result [subst {--
+-- $pkg(pretty_name) Package
+--
+-- @author $pkg(owner_name) ($pkg(owner_email))
+-- @author Timo Hentschel (timo@timohentschel.de)
+-- @creation-date $pkg(date)
+--
+
+
+}]
+
+ foreach one_type $type_list {
+ util_unlist $one_type type_id tablename id_column
+ append result "\n\ncreate table $tablename (\n"
+ append result "\t$id_column\t\tinteger constraint $tablename\_$id_column\_pk primary key"
+
+ db_foreach attributes {} {
+ append result ",\n\t$name\t\t$column_spec"
+ }
+
+ append result "\n);\n"
+ }
+
+ set f [open "$pkg(path)/sql/postgresql/$pkg(key)-create.sql" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::db::drop {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates the db drop scripts
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ set result [subst {--
+-- $pkg(pretty_name) Package
+--
+-- @author $pkg(owner_name) ($pkg(owner_email))
+-- @author Timo Hentschel (timo@timohentschel.de)
+-- @creation-date $pkg(date)
+--
+
+
+
+}]
+
+ db_foreach tables {} {
+ append result "drop table $tablename;\n"
+ }
+
+ set f [open "$pkg(path)/sql/postgresql/$pkg(key)-drop.sql" w]
+ puts $f $result
+ close $f
+}
Index: openacs-4/packages/package-builder/tcl/pb-create-db-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-db-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-db-procs.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ select type_id, tablename, id_column
+ from pb_types
+ where pkg_id = :pkg_id
+ order by sort_order
+
+
+
+
+
+
+
+ select name, column_spec
+ from pb_attributes
+ where type_id = :type_id
+ order by attribute_id
+
+
+
+
+
+
+
+ select tablename
+ from pb_types
+ where pkg_id = :pkg_id
+ order by sort_order desc
+
+
+
+
+
Index: openacs-4/packages/package-builder/tcl/pb-create-info-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-info-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-info-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,58 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::create::info {}
+
+ad_proc -public pb::create::info::create {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates the package info script
+} {
+ array set pkg $pkg_data
+ set result [subst {
+
+
+
+ $pkg(pretty_name)
+ $pkg(pretty_plural)
+ f
+ f
+
+
+
+ postgresql
+
+ $pkg(owner_name)
+ $pkg(summary)
+ $pkg(date)
+ 0
+ $pkg(vendor_name)
+ $pkg(description)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }]
+
+ set f [open "$pkg(path)/$pkg(key)\.info" w]
+ puts $f $result
+ close $f
+}
Index: openacs-4/packages/package-builder/tcl/pb-create-tcl-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-tcl-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-tcl-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,206 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::create::tcl {}
+
+ad_proc -public pb::create::tcl::install {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates the tcl install script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ set type_list [db_list_of_lists types {}]
+
+ set result [subst {ad_library \{
+ $pkg(pretty_name) Package install callbacks
+
+ Procedures that deal with installing.
+
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+\}
+
+namespace eval $pkg(short_name)::install \{\}
+
+ad_proc -public $pkg(short_name)::install::create_install \{
+\} \{
+ Creates the content types and adds the attributes.
+\} \{
+ }]
+
+ foreach one_type $type_list {
+ util_unlist $one_type type_id type_name pretty_name pretty_plural tablename id_column
+ append result "content::type::new -content_type \{$type_name\} -supertype \{content_revision\} -pretty_name \{$pretty_name\} -pretty_plural \{$pretty_plural\} -table_name \{$tablename\} -id_column \{$id_column\}\n"
+ }
+
+ foreach one_type $type_list {
+ util_unlist $one_type type_id type_name pretty_name pretty_plural tablename id_column
+ append result "\n# $pretty_name\n"
+
+ db_foreach attributes {} {
+ append result "content::type::attribute::new -content_type \{$type_name\} -attribute_name \{$name\} -datatype \{$datatype\} -pretty_name \{$pretty_name\} -column_spec \{$column_spec\}\n"
+ }
+ }
+
+ append result [subst {
+\}
+
+ad_proc -public $pkg(short_name)::install::package_instantiate \{
+ -package_id:required
+\} \{
+ Define folders
+\} \{
+ # create a content folder
+ set folder_id \[content::folder::new -name \"$pkg(key_under)_\$package_id\" -package_id \$package_id\]
+ # register the allowed content types for a folder
+ }]
+
+ foreach one_type $type_list {
+ util_unlist $one_type type_id type_name pretty_name pretty_plural tablename id_column
+ append result "content::folder::register_content_type -folder_id \$folder_id -content_type \{$type_name\} -include_subtypes t\n"
+ }
+
+ append result "\}"
+ set f [open "$pkg(path)/tcl/$pkg(short_name)-install-procs.tcl" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::tcl::util {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates util tcl procs
+} {
+ array set pkg $pkg_data
+
+ set result [subst {ad_library \{
+ $pkg(pretty_name) util procs
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+\}
+
+namespace eval $pkg(short_name)::util \{\}
+
+ad_proc $pkg(short_name)::util::folder_id \{
+ -package_id:required
+\} \{
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+
+ Returns the folder_id of the package instance
+\} \{
+ return \[db_string get_folder_id \"select folder_id from cr_folders where package_id=:package_id\"\]
+\}
+ }]
+
+ set f [open "$pkg(path)/tcl/$pkg(short_name)-util-procs.tcl" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::tcl::wrapper {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates wrapper tcl procs to add/edit a content type
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set vars ""
+ set params ""
+ db_foreach attributes {} {
+ append vars " {-$attr_name \"\"}\n"
+ append params "\\\n\t\t\[list $attr_name \$$attr_name\] "
+ }
+
+ set result [subst {ad_library \{
+ $type(pretty_name) procs
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+\}
+
+namespace eval $pkg(short_name)::$type(name) \{\}
+
+ad_proc -public $pkg(short_name)::$type(name)::new \{
+ \{-name \"\"\}
+ \{-title \"\"\}
+ \{-description \"\"\}
+$vars\} \{
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+
+ New $type(pretty_name)
+\} \{
+ set package_id \[ad_conn package_id\]
+ set folder_id \[$pkg(short_name)::util::folder_id -package_id \$package_id\]
+
+ db_transaction \{
+ if \{\[empty_string_p \$name\]\} \{
+ set name \[exec uuidgen\]
+ \}
+ set item_id \[content::item::new -parent_id \$folder_id -content_type \{$type(name)\} -name \$name -title \$title\]
+
+ set new_id \[content::revision::new \\
+ -item_id \$item_id \\
+ -content_type \{$type(name)\} \\
+ -title \$title \\
+ -description \$description \\
+ -attributes \[list $params\] \]
+ \}
+
+ return \$new_id
+\}
+
+ad_proc -public $pkg(short_name)::$type(name)::edit \{
+ -$type(id_column)\:required
+ \{-title \"\"\}
+ \{-description \"\"\}
+$vars\} \{
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+
+ Edit $type(pretty_name)
+\} \{
+ db_transaction \{
+ set new_rev_id \[content::revision::new \\
+ -item_id \$$type(id_column) \\
+ -content_type \{$type(name)\} \\
+ -title \$title \\
+ -description \$description \\
+ -attributes \[list $params\] \]
+ \}
+
+ return \$new_rev_id
+\}
+ }]
+
+ set f [open "$pkg(path)/tcl/$type(name_dash)\-procs.tcl" w]
+ puts $f $result
+ close $f
+}
Index: openacs-4/packages/package-builder/tcl/pb-create-tcl-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-tcl-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-tcl-procs.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ select type_id, name, pretty_name, pretty_plural, tablename, id_column
+ from pb_types
+ where pkg_id = :pkg_id
+ order by sort_order
+
+
+
+
+
+
+
+ select name, pretty_name, datatype, column_spec
+ from pb_attributes
+ where type_id = :type_id
+ order by attribute_id
+
+
+
+
+
+
+
+ select name as attr_name
+ from pb_attributes
+ where type_id = :type_id
+ order by attribute_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/tcl/pb-create-www-ae-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-www-ae-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-www-ae-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,274 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::create::www::ae {}
+
+ad_proc -public pb::create::www::ae::tcl {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates add/edit form tcl script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+ # regsub -all {_} $type(name) {-} type(name_dash)
+
+ set eoptions ""
+ set elements ""
+ set defaults ""
+ set params ""
+ db_foreach attributes {} {
+ append defaults "\tset $name \"\"\n"
+ append params "\\\n\t\t-$name \$$name "
+ set optional ""
+ if {$required_p == "f"} {
+ set optional ",optional"
+ }
+ switch -exact $datatype {
+ string {
+ set etype text
+ if {$widget == "textarea"} {
+ set ewidget "(textarea)"
+ set other "\{html \{rows 8 cols 80\}\}"
+ } elseif {$widget == "text"} {
+ set ewidget ""
+ set other "\{html \{size 80 maxlength 200\}\}"
+ } else {
+ set ewidget "($widget)"
+ set other "\{options \$$name\_options\}"
+ append eoptions "set $name\_options \[list"
+ foreach opt $options {
+ regsub -all { } [string tolower $opt] {_} opt_under
+ append eoptions " \[list \"\[_ $pkg(key)\.$type(name)\_$name\_$opt_under\]\" \"$opt\"\]"
+ }
+ append eoptions "\]\n"
+ }
+ }
+ number {
+ set etype integer
+ set ewidget ""
+ set other "\{html \{size 10 maxlength 10\}\}"
+ }
+ boolean {
+ set etype text
+ set ewidget "(select)"
+ set other "\{options \$$name\_options\}"
+ append eoptions "set $name\_options \[list \[list \"\[_ $pkg(key)\.yes\]\" t\] \[list \"\[_ $pkg(key)\.no\]\" f\]\]\n"
+ }
+ }
+ append elements "\t\{$name\:$etype$ewidget$optional \{label \"\[_ $pkg(key)\.$type(name)\_$name\]\"\} $other \{help_text \"\[_ $pkg(key)\.$type(name)\_$name\_help\]\"\}\}\n"
+ }
+
+ set result [subst {ad_page_contract \{
+ Form to add/edit $type(pretty_name).
+
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+\} \{
+ $type(id_column)\:integer,optional
+ \{__new_p 0\}
+ \{mode edit\}
+\} -properties \{
+ context_bar:onevalue
+ page_title:onevalue
+\}
+
+set has_submit 0
+if \{!\[info exists $type(id_column)\] || \$__new_p\} \{
+ set page_title \"\[_ $pkg(key)\.$type(name)\_Add\]\"
+ set _$type(id_column) 0
+\} else \{
+ if \{\$mode == \"edit\"\} \{
+ set page_title \"\[_ $pkg(key)\.$type(name)\_Edit\]\"
+ \} else \{
+ set page_title \"\[_ $pkg(key)\.$type(name)\_View\]\"
+ set has_submit 1
+ \}
+ set _$type(id_column) \$$type(id_column)
+\}
+
+set context_bar \[ad_context_bar \[list \"$type(name_dash)-list\" \"\[_ $pkg(key)\.$type(name)\_2\]\"\] \$page_title\]
+set package_id \[ad_conn package_id\]
+
+$eoptions
+ad_form -name $type(name)\_form -action $type(name_dash)\-ae -mode \$mode -has_submit \$has_submit -form \{
+ \{$type(id_column):key\}
+\}
+ }]
+
+ set ntd_defaults ""
+ set n_param ""
+ if {![empty_string_p $type(name_pretty)]} {
+ set ntd_defaults " set name \"\"\n"
+ set n_param "\\\n\t\t-name \$name "
+ append result [subst {
+if \{\$_$type(id_column) > 0\} \{
+ ad_form -extend -name $type(name)\_form -form \{
+ \{name:text(inform) \{label \"\[_ $pkg(key)\.$type(name)\_Name\]\"\} \{html \{size 80 maxlength 1000\}\} \{help_text \"\[_ $pkg(key)\.$type(name)\_Name_help\]\"\}\}
+ \}
+\} else \{
+ ad_form -extend -name $type(name)\_form -form \{
+ \{name:text,optional \{label \"\[_ $pkg(key)\.$type(name)\_Name\]\"\} \{html \{size 80 maxlength 1000\}\} \{help_text \"\[_ $pkg(key)\.$type(name)\_Name_help\]\"\}\}
+ \}
+\}
+ }]
+ }
+
+ set td_params ""
+ if {![empty_string_p $type(title_pretty)] || ![empty_string_p $type(descr_pretty)]} {
+ append result [subst {
+ad_form -extend -name $type(name)\_form -form \{}]
+
+ if {![empty_string_p $type(title_pretty)]} {
+ append ntd_defaults " set title \"\"\n"
+ set td_params "\\\n\t\t-title \$title "
+ append result [subst {
+ \{title:text \{label \"\[_ $pkg(key)\.$type(name)\_Title\]\"\} \{html \{size 80 maxlength 1000\}\} \{help_text \"\[_ $pkg(key)\.$type(name)\_Title_help\]\"\}\}}]
+ }
+ if {![empty_string_p $type(descr_pretty)]} {
+ append ntd_defaults " set description \"\"\n"
+ append td_params "\\\n\t\t-description \$description "
+ append result [subst {
+ \{description:text(textarea),optional \{label \"\[_ $pkg(key)\.$type(name)\_Description\]\"\} \{html \{rows 5 cols 80\}\} \{help_text \"\[_ $pkg(key)\.$type(name)\_Description_help\]\"\}\}}]
+ }
+ append result [subst {
+\}
+ }]
+ }
+
+ append result [subst {
+if \{!\[empty_string_p \[category_tree::get_mapped_trees \$package_id\]\]\} \{
+ category::ad_form::add_widgets -container_object_id \$package_id -categorized_object_id \$_$type(id_column) -form_name $type(name)\_form
+\}
+
+ad_form -extend -name $type(name)\_form -form \{
+$elements\} -new_request \{
+$ntd_defaults$defaults\} -edit_request \{
+ db_1row get_data \{\}
+\} -on_submit \{
+ set category_ids \[category::ad_form::get_categories -container_object_id \$package_id\]
+\} -new_data \{
+ db_transaction \{
+ set new_$type(id_column) \[$pkg(short_name)::$type(name)::new $n_param $td_params $params\]
+
+ if \{\[exists_and_not_null category_ids\]\} \{
+ category::map_object -object_id \$new_$type(id_column) \$category_ids
+ \}
+ \}
+\} -edit_data \{
+ db_transaction \{
+ set new_$type(id_column) \[$pkg(short_name)::$type(name)::edit \\
+ -$type(id_column) \$$type(id_column) $td_params $params\]
+
+ if \{\[exists_and_not_null category_ids\]\} \{
+ category::map_object -object_id \$new_$type(id_column) \$category_ids
+ \}
+ \}
+\} -after_submit \{
+ ad_returnredirect $type(name_dash)-list
+ ad_script_abort
+\}
+
+ad_return_template
+ }]
+
+
+ set f [open "$pkg(path)/www/$type(name_dash)-ae.tcl" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::www::ae::adp {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates add/edit form adp script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set result [subst {
+@page_title;noquote@
+@context_bar;noquote@
+
+
+
+
+ }]
+
+ set f [open "$pkg(path)/www/$type(name_dash)-ae.adp" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::www::ae::xql {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates add/edit form xql script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set columns ""
+ if {![empty_string_p $type(name_pretty)]} {
+ set columns "i.name, "
+ }
+ if {![empty_string_p $type(title_pretty)]} {
+ append columns "r.title, "
+ }
+ if {![empty_string_p $type(descr_pretty)]} {
+ append columns "r.description, "
+ }
+
+ db_foreach attributes {} {
+ append columns "t.$name, "
+ }
+ set columns [string range $columns 0 end-2]
+
+ set result [subst {
+
+
+
+
+
+ select $columns
+ from $type(tablename) t, cr_revisions r, cr_items i
+ where r.revision_id = t.$type(id_column)
+ and i.item_id = r.item_id
+ and t.$type(id_column) = :$type(id_column)
+
+
+
+
+
+ }]
+
+ set f [open "$pkg(path)/www/$type(name_dash)-ae.xql" w]
+ puts $f $result
+ close $f
+}
Index: openacs-4/packages/package-builder/tcl/pb-create-www-ae-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-www-ae-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-www-ae-procs.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ select name, pretty_name, datatype, required_p, widget, options
+ from pb_attributes
+ where type_id = :type_id
+ order by attribute_id
+
+
+
+
+
+
+
+ select name
+ from pb_attributes
+ where type_id = :type_id
+ order by attribute_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/tcl/pb-create-www-delete-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-www-delete-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-www-delete-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,139 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::create::www::delete {}
+
+ad_proc -public pb::create::www::delete::tcl {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates delete tcl script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set result [subst {ad_page_contract \{
+ Delete $type(pretty_name).
+
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+\} \{
+ $type(id_column)
+\} -properties \{
+ context_bar:onevalue
+ page_title:onevalue
+\}
+
+set page_title \"\[_ $pkg(key)\.$type(name)\_Delete\]\"
+set context_bar \[ad_context_bar \[list \"$type(name_dash)-list\" \"\[_ $pkg(key)\.$type(name)\_2\]\"\] \$page_title\]
+
+set confirm_options \[list \[list \"\[_ $pkg(key)\.continue_with_delete\]\" t\] \[list \"\[_ $pkg(key)\.cancel_and_return\]\" f\]\]
+
+ad_form -name delete_confirm -action $type(name_dash)-delete -export \{ $type(id_column) \} -form \{
+ {section_id:key}
+ \{title:text(inform) \{label \"\[_ $pkg(key)\.Delete\]\"\}\}
+ \{confirmation:text(radio) \{label \" \"\} \{options \$confirm_options\} \{value f\}\}
+\} -select_query_name \{title\} \\
+-on_submit \{
+ if \{\$confirmation\} \{
+ db_dml mark_deleted \{\}
+ \}
+\} -after_submit \{
+ ad_returnredirect \"$type(name_dash)-list\"
+ ad_script_abort
+\}
+
+ad_return_template
+ }]
+
+ set f [open "$pkg(path)/www/$type(name_dash)-delete.tcl" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::www::delete::adp {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates delete adp script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set result [subst {
+@page_title;noquote@
+@context_bar;noquote@
+
+
+
+
+ }]
+
+ set f [open "$pkg(path)/www/$type(name_dash)-delete.adp" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::www::delete::xql {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates delete xql script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set result [subst {
+
+
+
+
+
+ select title
+ from cr_revisions
+ where revision_id = :$type(id_column)
+
+
+
+
+
+
+
+ update cr_items
+ set latest_revision = null
+ where latest_revision = :$type(id_column)
+
+
+
+
+
+ }]
+
+ set f [open "$pkg(path)/www/$type(name_dash)-delete.xql" w]
+ puts $f $result
+ close $f
+}
Index: openacs-4/packages/package-builder/tcl/pb-create-www-index-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-www-index-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-www-index-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,115 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::create::www::index {}
+
+ad_proc -public pb::create::www::index::tcl {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates index tcl script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ set result [subst {ad_page_contract \{
+ Index page.
+
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+\} \{
+\} -properties \{
+ context_bar:onevalue
+ page_title:onevalue
+\}
+
+set page_title \"\[_ $pkg(key)\.$pkg(key_under)\]\"
+set context_bar \[ad_context_bar\]
+set package_id \[ad_conn package_id\]
+set categories_node_id \[db_string get_category_node_id \{\}\]
+set categories_url \[site_node::get_url -node_id \$categories_node_id\]
+
+ad_return_template
+ }]
+
+ set f [open "$pkg(path)/www/index.tcl" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::www::index::adp {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates index adp script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ set types ""
+ db_foreach types {} {
+ regsub -all {_} $name {-} name_dash
+ append types "$pretty_plural\n"
+ }
+
+ set result [subst {
+@page_title;noquote@
+@context_bar;noquote@
+
+#$pkg(key).admin_categories#
+
+
+
+ }]
+
+ set f [open "$pkg(path)/www/index.adp" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::www::index::xql {
+ -pkg_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates index xql script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ set result [subst {
+
+
+
+
+
+
+ select n.node_id
+ from site_nodes n, site_nodes top, apm_packages p
+ where top.parent_id is null
+ and n.parent_id = top.node_id
+ and p.package_id = n.object_id
+ and p.package_key = 'categories'
+
+
+
+
+
+ }]
+
+ set f [open "$pkg(path)/www/index.xql" w]
+ puts $f $result
+ close $f
+}
Index: openacs-4/packages/package-builder/tcl/pb-create-www-index-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-www-index-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-www-index-procs.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ select name, pretty_plural
+ from pb_types
+ where pkg_id = :pkg_id
+ order by sort_order
+
+
+
+
+
Index: openacs-4/packages/package-builder/tcl/pb-create-www-list-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-create-www-list-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-create-www-list-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,137 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::create::www::list {}
+
+ad_proc -public pb::create::www::list::tcl {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates list tcl script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set result [subst {ad_page_contract \{
+ List of $type(pretty_plural).
+
+ @author $pkg(owner_name) ($pkg(owner_email))
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date $pkg(date)
+\} \{
+\} -properties \{
+ context_bar:onevalue
+ page_title:onevalue
+\}
+
+set page_title \"\[_ $pkg(key)\.$type(name)\_2\]\"
+set context_bar \[ad_context_bar \$page_title\]
+set package_id \[ad_conn package_id\]
+
+set actions \[list \"\[_ $pkg(key)\.$type(name)\_New\]\" $type(name_dash)-ae \"\[_ $pkg(key)\.$type(name)\_New2\]\"\]
+
+template::list::create \\
+ -name $type(name) \\
+ -key $type(id_column) \\
+ -no_data \"\[_ $pkg(key)\.None\]\" \\
+ -elements \{
+ title \{
+ label \{\[_ $pkg(key)\.$type(name)\_1\]\}
+ link_url_eval \{\[export_vars -base \"$type(name_dash)-ae\" \{$type(id_column) \{mode display\}\}\]\}
+ \}
+ action \{
+ display_template \{#$pkg(key)\.Edit# #$pkg(key)\.Delete#\}
+
+ \}
+ \} -actions \$actions
+
+db_multirow -extend \{edit_link delete_link\} $type(name) $type(name) \{\} \{
+ set edit_link \[export_vars -base \"$type(name_dash)-ae\" \{$type(id_column)\}\]
+ set delete_link \[export_vars -base \"$type(name_dash)-delete\" \{$type(id_column)\}\]
+\}
+
+ad_return_template
+ }]
+
+ set f [open "$pkg(path)/www/$type(name_dash)-list.tcl" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::www::list::adp {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates list adp script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set result [subst {
+@page_title;noquote@
+@context_bar;noquote@
+
+
+ }]
+
+ set f [open "$pkg(path)/www/$type(name_dash)-list.adp" w]
+ puts $f $result
+ close $f
+}
+
+
+ad_proc -public pb::create::www::list::xql {
+ -pkg_data:required
+ -type_data:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+
+ Creates list xql script
+} {
+ array set pkg $pkg_data
+ set pkg_id $pkg(pkg_id)
+
+ array set type $type_data
+ set type_id $type(type_id)
+
+ set result [subst {
+
+
+
+
+
+ select t.$type(id_column), cr.title
+ from cr_folders cf, cr_items ci, cr_revisions cr, $type(tablename) t
+ where cr.revision_id = ci.latest_revision
+ and t.$type(id_column) = cr.revision_id
+ and ci.parent_id = cf.folder_id
+ and cf.package_id = :package_id
+ order by cr.title
+
+
+
+
+
+ }]
+
+ set f [open "$pkg(path)/www/$type(name_dash)-list.xql" w]
+ puts $f $result
+ close $f
+}
Index: openacs-4/packages/package-builder/tcl/pb-util-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/tcl/pb-util-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/tcl/pb-util-procs.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,23 @@
+ad_library {
+ Package Builder procs
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-07
+}
+
+namespace eval pb::util {}
+
+ad_proc -public pb::util::package_exists {
+ -key:required
+ -pretty_name:required
+} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-09
+
+ Checks if package already exists in filesystem.
+ This protects against overwriting existing packages.
+} {
+ if {[empty_string_p $key]} {
+ regsub -all { } [string tolower $pretty_name] {-} key
+ }
+ return [file exists "[acs_root_dir]/packages/$key"]
+}
Index: openacs-4/packages/package-builder/www/attribute-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-ae.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-ae.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,7 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
+
+
Index: openacs-4/packages/package-builder/www/attribute-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-ae.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-ae.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,74 @@
+ad_page_contract {
+ Form to add/edit an attribute.
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @cvs-id $Id:
+} {
+ pkg_id:integer
+ type_id:integer
+ attribute_id:integer,optional
+ {__new_p 0}
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+db_1row type_and_package_data {}
+
+if {![info exists attribute_id] || $__new_p} {
+ set page_title [_ package-builder.New_Attribute]
+} else {
+ set page_title [_ package-builder.Edit_Attribute]
+}
+
+set context_bar [ad_context_bar [list [export_vars -base type-list {pkg_id}] $package_name] [list [export_vars -base attribute-list {pkg_id type_id}] $type_name] $page_title]
+set package_id [ad_conn package_id]
+
+set boolean_options [list [list "[_ package-builder.yes]" t] [list "[_ package-builder.no]" f]]
+set datatype_options [list]
+foreach dtype [list string number boolean] {
+ lappend datatype_options [list "[_ package-builder.datatype_$dtype]" $dtype]
+}
+set widget_options [list]
+foreach wtype [list text textarea radio checkbox select] {
+ lappend widget_options [list "[_ package-builder.widget_$wtype]" $wtype]
+}
+
+ad_form -name attribute_form -action attribute-ae -export {pkg_id type_id} -form {
+ {attribute_id:key}
+ {name:text,optional {label "[_ package-builder.attr_Name]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.attr_Name_help]"}}
+ {pretty_name:text {label "[_ package-builder.attr_Pretty_Name]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.attr_Pretty_Name_help]"}}
+ {datatype:text(select) {label "[_ package-builder.attr_Datatype]"} {options $datatype_options} {value string} {help_text "[_ package-builder.attr_Datatype_help]"}}
+ {column_spec:text(textarea) {label "[_ package-builder.attr_Column_Spec]"} {html {rows 8 cols 80}} {help_text "[_ package-builder.attr_Column_Spec_help]"}}
+ {required_p:text(select) {label "[_ package-builder.attr_Required]"} {options $boolean_options} {value t} {help_text "[_ package-builder.attr_Required_help]"}}
+ {widget:text(select) {label "[_ package-builder.attr_Widget]"} {options $widget_options} {help_text "[_ package-builder.attr_Widget_help]"}}
+ {options:text(textarea),optional {label "[_ package-builder.attr_Options]"} {html {rows 8 cols 80}} {help_text "[_ package-builder.attr_Options_help]"}}
+} -new_request {
+ set name ""
+ set pretty_name ""
+ set datatype ""
+ set column_spec ""
+ set required_p ""
+ set widget ""
+ set options ""
+} -edit_request {
+ db_1row attribute_data {}
+ set options [join $options "\n"]
+} -on_submit {
+ if {[empty_string_p $name]} {
+ regsub -all { } [string tolower $pretty_name] {_} name
+ }
+ set options_list [list]
+ foreach line [split $options "\n"] {
+ lappend options_list [string trim $line]
+ }
+} -new_data {
+ db_dml insert_attribute {}
+} -edit_data {
+ db_dml update_attribute {}
+} -after_submit {
+ ad_returnredirect [export_vars -base attribute-list {pkg_id type_id}]
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/attribute-ae.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-ae.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-ae.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+ select p.pretty_name as package_name, t.pretty_name as type_name
+ from pb_packages p, pb_types t
+ where p.pkg_id = :pkg_id
+ and t.type_id = :type_id
+
+
+
+
+
+
+
+ select name, pretty_name, datatype, column_spec, required_p, widget, options
+ from pb_attributes
+ where attribute_id = :attribute_id
+
+
+
+
+
+
+
+ insert into pb_attributes (attribute_id, type_id, name, pretty_name, datatype,
+ column_spec, required_p, widget, options)
+ values (:attribute_id, :type_id, :name, :pretty_name, :datatype, :column_spec,
+ :required_p, :widget, :options_list)
+
+
+
+
+
+
+
+ update pb_attributes
+ set name = :name,
+ pretty_name = :pretty_name,
+ datatype = :datatype,
+ column_spec = :column_spec,
+ required_p = :required_p,
+ widget = :widget,
+ options = :options_list
+ where attribute_id = :attribute_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/attribute-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-delete.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-delete.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,7 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
+
+
Index: openacs-4/packages/package-builder/www/attribute-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-delete.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-delete.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,37 @@
+ad_page_contract {
+ Confirmation form to delete an attribute.
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @cvs-id $Id:
+} {
+ pkg_id:integer
+ type_id:integer
+ attribute_id:integer
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+db_1row type_and_package_data {}
+
+set page_title "[_ package-builder.Delete_Attribute]"
+set context_bar [ad_context_bar [list [export_vars -base type-list {pkg_id}] $package_name] [list [export_vars -base attribute-list {pkg_id type_id}] $type_name] $page_title]
+
+set confirm_options [list [list "[_ package-builder.continue_with_delete]" t] [list "[_ package-builder.cancel_and_return]" f]]
+
+ad_form -name attribute_delete_confirm -action attribute-delete -export { pkg_id type_id } -form {
+ {attribute_id:key}
+ {pretty_name:text(inform) {label "[_ package-builder.Delete_Attribute]"}}
+ {from:text(inform) {label "[_ package-builder.From_Type]"} {value $type_name}}
+ {confirmation:text(radio) {label " "} {options $confirm_options} {value f}}
+} -select_query_name {attribute_name} \
+-on_submit {
+ if {$confirmation} {
+ db_dml delete_attribute {}
+ }
+} -after_submit {
+ ad_returnredirect [export_vars -base attribute-list {pkg_id type_id}]
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/attribute-delete.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-delete.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-delete.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ select p.pretty_name as package_name, t.pretty_name as type_name
+ from pb_packages p, pb_types t
+ where p.pkg_id = :pkg_id
+ and t.type_id = :type_id
+
+
+
+
+
+
+
+ select pretty_name
+ from pb_attributes
+ where attribute_id = :attribute_id
+
+
+
+
+
+
+
+ delete from pb_attributes
+ where attribute_id = :attribute_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/attribute-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-list.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-list.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,5 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
Index: openacs-4/packages/package-builder/www/attribute-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-list.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-list.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,38 @@
+ad_page_contract {
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-08
+} {
+ pkg_id:integer
+ type_id:integer
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+db_1row type_data {}
+
+set page_title "[_ package-builder.Attributes]"
+set context_bar [ad_context_bar [list [export_vars -base type-list {pkg_id}] $type_name] $page_title]
+
+set actions [list "[_ package-builder.New_Attribute]" [export_vars -base attribute-ae {pkg_id type_id}] "[_ package-builder.New_Attribute2]"]
+
+db_multirow -extend {edit_link delete_link} attributes attributes {} {
+ set edit_link [export_vars -base attribute-ae {pkg_id type_id attribute_id}]
+ set delete_link [export_vars -base attribute-delete {pkg_id type_id attribute_id}]
+}
+
+list::create \
+ -name attributes \
+ -key attribute_id \
+ -no_data "[_ package-builder.None]" \
+ -elements {
+ pretty_name {
+ label "[_ package-builder.Name]"
+ }
+ action {
+ display_template {#package-builder.Edit# #package-builder.Delete#}
+ }
+ } -actions $actions
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/attribute-list.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/attribute-list.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/attribute-list.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ select pretty_name as type_name
+ from pb_types
+ where type_id = :type_id
+
+
+
+
+
+
+
+ select :pkg_id as pkg_id, type_id, attribute_id, pretty_name
+ from pb_attributes
+ where type_id = :type_id
+ order by attribute_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/index.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/index.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,5 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
Index: openacs-4/packages/package-builder/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/index.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/index.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,37 @@
+ad_page_contract {
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-08
+} {
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+set page_title "[_ package-builder.Index]"
+set context_bar [ad_context_bar]
+set package_id [ad_conn package_id]
+
+set actions [list "[_ package-builder.New_Package]" package-ae "[_ package-builder.New_Package2]"]
+
+db_multirow -extend {edit_link delete_link create_link} packages packages {} {
+ set edit_link [export_vars -base package-ae {pkg_id}]
+ set delete_link [export_vars -base package-delete {pkg_id}]
+ set create_link [export_vars -base package-code-generate {pkg_id}]
+}
+
+list::create \
+ -name packages \
+ -key pkg_id \
+ -no_data "[_ package-builder.None]" \
+ -elements {
+ pretty_name {
+ label "[_ package-builder.Name]"
+ link_url_eval "[export_vars -base type-list { pkg_id }]"
+ }
+ action {
+ display_template {#package-builder.Edit# #package-builder.Delete# #package-builder.Generate#}
+ }
+ } -actions $actions
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/index.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/index.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/index.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ select pkg_id, pretty_name
+ from pb_packages
+ where package_id = :package_id
+ order by lower(pretty_name)
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/package-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-ae.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-ae.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,7 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
+
+
Index: openacs-4/packages/package-builder/www/package-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-ae.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-ae.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,63 @@
+ad_page_contract {
+ Form to add/edit a package.
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @cvs-id $Id:
+} {
+ pkg_id:integer,optional
+ {__new_p 0}
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+if {![info exists pkg_id] || $__new_p} {
+ set page_title [_ package-builder.New_Package]
+} else {
+ set page_title [_ package-builder.Edit_Package]
+}
+
+set context_bar [ad_context_bar $page_title]
+set package_id [ad_conn package_id]
+set user_id [ad_conn user_id]
+
+ad_form -name package_form -action package-ae -form {
+ {pkg_id:key}
+ {key:text,optional {label "[_ package-builder.pkg_Key]"} {html {size 50 maxlength 50}} {help_text "[_ package-builder.pkg_Key_help]"}}
+ {short_name:text {label "[_ package-builder.pkg_Short_Name]"} {html {size 5 maxlength 5}} {help_text "[_ package-builder.pkg_Short_Name_help]"}}
+ {pretty_name:text {label "[_ package-builder.pkg_Pretty_Name]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.pkg_Pretty_Name_help]"}}
+ {pretty_plural:text,optional {label "[_ package-builder.pkg_Pretty_Plural]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.pkg_Pretty_Plural_help]"}}
+ {summary:text(textarea),optional {label "[_ package-builder.pkg_Summary]"} {html {rows 5 cols 80}} {help_text "[_ package-builder.pkg_Summary_help]"}}
+ {vendor_name:text,optional {label "[_ package-builder.pkg_Vendor_Name]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.pkg_Vendor_Name_help]"}}
+ {vendor_url:text,optional {label "[_ package-builder.pkg_Vendor_Url]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.pkg_Vendor_Url_help]"}}
+ {description:text(textarea),optional {label "[_ package-builder.pkg_Description]"} {html {rows 5 cols 80}} {help_text "[_ package-builder.pkg_Description_help]"}}
+} -new_request {
+ set key ""
+ set short_name ""
+ set pretty_name ""
+ set pretty_plural ""
+ set summary ""
+ set vendor_name ""
+ set vendor_url ""
+ set description ""
+} -edit_request {
+ db_1row package_data {}
+} -validate {
+ {key {![pb::util::package_exists -key $key -pretty_name $pretty_name]} "[_ package-builder.Package_exists]"}
+} -on_submit {
+ if {[empty_string_p $key]} {
+ regsub -all { } [string tolower $pretty_name] {-} key
+ }
+ if {[empty_string_p $pretty_plural]} {
+ set pretty_plural "${pretty_name}s"
+ }
+} -new_data {
+ db_dml insert_package {}
+} -edit_data {
+ db_dml update_package {}
+} -after_submit {
+ ad_returnredirect .
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/package-ae.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-ae.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-ae.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+ select key, short_name, pretty_name, pretty_plural, summary, vendor_name,
+ vendor_url, description
+ from pb_packages
+ where pkg_id = :pkg_id
+
+
+
+
+
+
+
+ insert into pb_packages (pkg_id, package_id, key, short_name, pretty_name,
+ pretty_plural, summary, vendor_name, vendor_url,
+ description, owner_id)
+ values (:pkg_id, :package_id, :key, :short_name, :pretty_name, :pretty_plural,
+ :summary, :vendor_name, :vendor_url, :description, :user_id)
+
+
+
+
+
+
+
+ update pb_packages
+ set key = :key,
+ short_name = :short_name,
+ pretty_name = :pretty_name,
+ pretty_plural = :pretty_plural,
+ summary = :summary,
+ vendor_name = :vendor_name,
+ vendor_url = :vendor_url,
+ description = :description
+ where pkg_id = :pkg_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/package-code-generate-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-code-generate-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-code-generate-postgresql.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,20 @@
+
+
+postgresql7.1
+
+
+
+
+ select p.pkg_id, p.key, p.short_name, p.pretty_name, p.pretty_plural, p.summary,
+ p.vendor_name, p.vendor_url, p.description, pa.email as owner_email,
+ pe.first_names || ' ' || pe.last_name as owner_name,
+ to_char(now(), 'YYYY-MM-DD') as date
+ from pb_packages p, persons pe, parties pa
+ where p.pkg_id = :pkg_id
+ and pe.person_id = p.owner_id
+ and pa.party_id = p.owner_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/package-code-generate.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-code-generate.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-code-generate.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,3 @@
+
+@page_title;noquote@
+@context_bar;noquote@
Index: openacs-4/packages/package-builder/www/package-code-generate.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-code-generate.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-code-generate.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,60 @@
+ad_page_contract {
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-08
+} {
+ pkg_id
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+set page_title "[_ package-builder.Package_Created]"
+set context_bar [ad_context_bar $page_title]
+
+# date owner_name owner_email path
+db_1row package_data {} -column_array pkg
+regsub -all -- {-} $pkg(key) {_} pkg(key_under)
+set pkg(path) "[acs_root_dir]/packages/$pkg(key)"
+set pkg_data [array get pkg]
+
+set types [db_list types {}]
+
+# ns_rmdir $pkg(path)
+ns_mkdir $pkg(path)
+ns_mkdir "$pkg(path)/tcl"
+ns_mkdir "$pkg(path)/www"
+ns_mkdir "$pkg(path)/catalog"
+ns_mkdir "$pkg(path)/sql"
+ns_mkdir "$pkg(path)/sql/postgresql"
+
+pb::create::info::create -pkg_data $pkg_data
+pb::create::db::create -pkg_data $pkg_data
+pb::create::db::drop -pkg_data $pkg_data
+pb::create::catalog::create -pkg_data $pkg_data
+pb::create::tcl::install -pkg_data $pkg_data
+pb::create::tcl::util -pkg_data $pkg_data
+pb::create::www::index::tcl -pkg_data $pkg_data
+pb::create::www::index::adp -pkg_data $pkg_data
+pb::create::www::index::xql -pkg_data $pkg_data
+
+foreach type_id $types {
+ db_1row type_data {} -column_array type
+ regsub -all {_} $type(name) {-} type(name_dash)
+ set type_data [array get type]
+
+ pb::create::tcl::wrapper -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::list::tcl -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::list::adp -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::list::xql -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::ae::tcl -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::ae::adp -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::ae::xql -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::delete::tcl -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::delete::adp -pkg_data $pkg_data -type_data $type_data
+ pb::create::www::delete::xql -pkg_data $pkg_data -type_data $type_data
+
+ array unset type
+}
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/package-code-generate.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-code-generate.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-code-generate.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ select type_id
+ from pb_types
+ order by sort_order
+
+
+
+
+
+
+
+ select type_id, name, pretty_name, pretty_plural, tablename, id_column,
+ name_pretty, title_pretty, descr_pretty
+ from pb_types
+ where type_id = :type_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/package-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-delete.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-delete.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,7 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
+
+
Index: openacs-4/packages/package-builder/www/package-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-delete.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-delete.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,36 @@
+ad_page_contract {
+ Confirmation form to delete a package.
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @cvs-id $Id:
+} {
+ pkg_id:integer
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+set page_title "[_ package-builder.Delete_Package]"
+set context_bar [ad_context_bar $page_title]
+
+set confirm_options [list [list "[_ package-builder.continue_with_delete]" t] [list "[_ package-builder.cancel_and_return]" f]]
+
+ad_form -name package_delete_confirm -action package-delete -form {
+ {pkg_id:key}
+ {pretty_name:text(inform) {label "[_ package-builder.Delete_Package]"}}
+ {confirmation:text(radio) {label " "} {options $confirm_options} {value f}}
+} -select_query_name {package_name} \
+-on_submit {
+ if {$confirmation} {
+ db_transaction {
+ db_dml delete_attributes {}
+ db_dml delete_types {}
+ db_dml delete_package {}
+ }
+ }
+} -after_submit {
+ ad_returnredirect .
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/package-delete.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/package-delete.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/package-delete.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+ select pretty_name
+ from pb_packages
+ where pkg_id = :pkg_id
+
+
+
+
+
+
+
+ delete from pb_attributes
+ where type_id in (select type_id
+ from pb_types
+ where pkg_id = :pkg_id)
+
+
+
+
+
+
+
+ delete from pb_types
+ where pkg_id = :pkg_id
+
+
+
+
+
+
+
+ delete from pb_packages
+ where pkg_id = :pkg_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/type-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-ae.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-ae.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,7 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
+
+
Index: openacs-4/packages/package-builder/www/type-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-ae.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-ae.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,76 @@
+ad_page_contract {
+ Form to add/edit an item type.
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @cvs-id $Id:
+} {
+ pkg_id:integer
+ type_id:integer,optional
+ {__new_p 0}
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+db_1row package_data {}
+
+if {![info exists type_id] || $__new_p} {
+ set page_title [_ package-builder.New_Type]
+} else {
+ set page_title [_ package-builder.Edit_Type]
+}
+
+set context_bar [ad_context_bar [list [export_vars -base type-list {pkg_id}] $package_name] $page_title]
+set package_id [ad_conn package_id]
+
+ad_form -name type_form -action type-ae -export {pkg_id} -form {
+ {type_id:key}
+ {name:text,optional {label "[_ package-builder.type_Name]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.type_Name_help]"}}
+ {pretty_name:text {label "[_ package-builder.type_Pretty_Name]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.type_Pretty_Name_help]"}}
+ {pretty_plural:text,optional {label "[_ package-builder.type_Pretty_Plural]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.type_Pretty_Plural_help]"}}
+ {tablename:text,optional {label "[_ package-builder.type_Tablename]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.type_Tablename_help]"}}
+ {id_column:text,optional {label "[_ package-builder.type_Id_Column]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.type_Id_Column_help]"}}
+ {name_pretty:text,optional {label "[_ package-builder.type_Name_Pretty]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.type_Name_Pretty_help]"}}
+ {title_pretty:text,optional {label "[_ package-builder.type_Title_Pretty]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.type_Title_Pretty_help]"}}
+ {descr_pretty:text,optional {label "[_ package-builder.type_Descr_Pretty]"} {html {size 80 maxlength 200}} {help_text "[_ package-builder.type_Descr_Pretty_help]"}}
+} -new_request {
+ set name ""
+ set pretty_name ""
+ set pretty_plural ""
+ set tablename ""
+ set id_column ""
+ set name_pretty ""
+ set title_pretty ""
+ set descr_pretty ""
+} -edit_request {
+ db_1row type_data {}
+} -on_submit {
+ if {[empty_string_p $name]} {
+ regsub -all { } [string tolower $pretty_name] {_} name
+ set name "$package_short\_$name"
+ }
+ if {[empty_string_p $pretty_plural]} {
+ set pretty_plural "${pretty_name}s"
+ }
+ if {[empty_string_p $tablename]} {
+ set tablename "${name}s"
+ }
+ if {[empty_string_p $id_column]} {
+ regsub -all { } [string tolower $pretty_name] {_} id_column
+ set id_column "$id_column\_id"
+ }
+} -new_data {
+ set sort_order [db_string max_sort_order {}]
+ if {[empty_string_p $sort_order]} {
+ set sort_order 0
+ }
+ incr sort_order
+ db_dml insert_type {}
+} -edit_data {
+ db_dml update_type {}
+} -after_submit {
+ ad_returnredirect [export_vars -base type-list {pkg_id}]
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/type-ae.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-ae.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-ae.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+ select pretty_name as package_name, short_name as package_short
+ from pb_packages
+ where pkg_id = :pkg_id
+
+
+
+
+
+
+
+ select name, pretty_name, pretty_plural, tablename, id_column, name_pretty,
+ title_pretty, descr_pretty
+ from pb_types
+ where type_id = :type_id
+
+
+
+
+
+
+
+ select max(sort_order)
+ from pb_types
+ where pkg_id = :pkg_id
+
+
+
+
+
+
+
+ insert into pb_types (type_id, pkg_id, name, pretty_name, pretty_plural, tablename,
+ id_column, name_pretty, title_pretty, descr_pretty, sort_order)
+ values (:type_id, :pkg_id, :name, :pretty_name, :pretty_plural, :tablename,
+ :id_column, :name_pretty, :title_pretty, :descr_pretty, :sort_order)
+
+
+
+
+
+
+
+ update pb_types
+ set name = :name,
+ pretty_name = :pretty_name,
+ pretty_plural = :pretty_plural,
+ tablename = :tablename,
+ id_column = :id_column,
+ name_pretty = :name_pretty,
+ title_pretty = :title_pretty,
+ descr_pretty = :descr_pretty
+ where type_id = :type_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/type-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-delete.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-delete.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,7 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
+
+
Index: openacs-4/packages/package-builder/www/type-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-delete.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-delete.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,39 @@
+ad_page_contract {
+ Confirmation form to delete an item type.
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @cvs-id $Id:
+} {
+ pkg_id:integer
+ type_id:integer
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+db_1row package_data {}
+
+set page_title "[_ package-builder.Delete_Type]"
+set context_bar [ad_context_bar [list [export_vars -base type-list {pkg_id}] $package_name] $page_title]
+
+set confirm_options [list [list "[_ package-builder.continue_with_delete]" t] [list "[_ package-builder.cancel_and_return]" f]]
+
+ad_form -name type_delete_confirm -action type-delete -export { pkg_id } -form {
+ {type_id:key}
+ {pretty_name:text(inform) {label "[_ package-builder.Delete_Type]"}}
+ {from:text(inform) {label "[_ package-builder.From_Package]"} {value $package_name}}
+ {confirmation:text(radio) {label " "} {options $confirm_options} {value f}}
+} -select_query_name {type_name} \
+-on_submit {
+ if {$confirmation} {
+ db_transaction {
+ db_dml delete_attributes {}
+ db_dml delete_type {}
+ }
+ }
+} -after_submit {
+ ad_returnredirect [export_vars -base type-list {pkg_id}]
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/type-delete.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-delete.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-delete.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+ select pretty_name as package_name
+ from pb_packages
+ where pkg_id = :pkg_id
+
+
+
+
+
+
+
+ select pretty_name
+ from pb_types
+ where type_id = :type_id
+
+
+
+
+
+
+
+ delete from pb_attributes
+ where type_id = :type_id
+
+
+
+
+
+
+
+ delete from pb_types
+ where type_id = :type_id
+
+
+
+
+
Index: openacs-4/packages/package-builder/www/type-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-list.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-list.adp 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,5 @@
+
+@page_title;noquote@
+@context_bar;noquote@
+
+
Index: openacs-4/packages/package-builder/www/type-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-list.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-list.tcl 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,36 @@
+ad_page_contract {
+
+ @author Timo Hentschel (timo@timohentschel.de)
+ @creation-date 2005-01-08
+} {
+ pkg_id:integer
+} -properties {
+ context_bar:onevalue
+ page_title:onevalue
+}
+
+set page_title "[_ package-builder.Types]"
+set context_bar [ad_context_bar $page_title]
+
+set actions [list "[_ package-builder.New_Type]" [export_vars -base type-ae {pkg_id}] "[_ package-builder.New_Type2]"]
+
+db_multirow -extend {edit_link delete_link} types types {} {
+ set edit_link [export_vars -base type-ae {pkg_id type_id}]
+ set delete_link [export_vars -base type-delete {pkg_id type_id}]
+}
+
+list::create \
+ -name types \
+ -key type_id \
+ -no_data "[_ package-builder.None]" \
+ -elements {
+ pretty_name {
+ label "[_ package-builder.Name]"
+ link_url_eval "[export_vars -base attribute-list { pkg_id type_id }]"
+ }
+ action {
+ display_template {#package-builder.Edit# #package-builder.Delete#}
+ }
+ } -actions $actions
+
+ad_return_template
Index: openacs-4/packages/package-builder/www/type-list.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/package-builder/www/type-list.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/package-builder/www/type-list.xql 8 Feb 2005 11:48:13 -0000 1.1
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ select pkg_id, type_id, pretty_name
+ from pb_types
+ where pkg_id = :pkg_id
+ order by sort_order
+
+
+
+
+