Index: openacs-4/packages/categories/lib/tree-form.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/lib/tree-form.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/lib/tree-form.adp 14 Dec 2003 15:40:04 -0000 1.1
@@ -0,0 +1 @@
+
Index: openacs-4/packages/categories/lib/tree-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/lib/tree-form.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/lib/tree-form.tcl 14 Dec 2003 15:40:04 -0000 1.1
@@ -0,0 +1,37 @@
+set package_id [ad_conn package_id]
+
+set languages [lang::system::get_locale_options]
+
+ad_form -name tree_form -mode [ad_decode [ad_form_new_p -key tree_id] 1 edit display] -action tree-form -export { locale object_id } -form {
+ {tree_id:key}
+ {tree_name:text {label "Name"} {html {size 50 maxlength 50}}}
+ {language:text(select) {label "Language"} {options $languages}}
+ {description:text(textarea),optional {label "Description"} {html {rows 5 cols 80}}}
+} -new_request {
+ permission::require_permission -object_id $package_id -privilege category_admin
+ set language $locale
+} -edit_request {
+ permission::require_permission -object_id $tree_id -privilege category_tree_write
+ set action Edit
+ util_unlist [category_tree::get_translation $tree_id $locale] tree_name description
+ set language $locale
+} -on_submit {
+ set description [util_close_html_tags $description 4000]
+} -new_data {
+ db_transaction {
+ category_tree::add -tree_id $tree_id -name $tree_name -description $description -locale $language -context_id $package_id
+ if { [info exists object_id] } {
+ category_tree::map -tree_id $tree_id -object_id $object_id
+ set return_url [export_vars -base one-object { locale object_id }]
+ } else {
+ set return_url [export_vars -base tree-view { tree_id locale }]
+ }
+ }
+} -edit_data {
+ category_tree::update -tree_id $tree_id -name $tree_name -description $description -locale $language
+ set return_url [export_vars -base tree-view { tree_id locale object_id }]
+} -after_submit {
+ ad_returnredirect $return_url
+ ad_script_abort
+}
+
Index: openacs-4/packages/categories/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/index.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/categories/www/index.adp 23 Apr 2003 12:29:27 -0000 1.1
+++ openacs-4/packages/categories/www/index.adp 14 Dec 2003 15:39:52 -0000 1.2
@@ -3,7 +3,9 @@
@context_bar;noquote@
- Category Administration
+
Select Trees for browsing:
@@ -13,8 +15,8 @@
- |
- @trees.tree_name@ |
+ |
+ |
| |
Index: openacs-4/packages/categories/www/cadmin/category-delete-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-2.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/category-delete-2.tcl 11 Dec 2003 21:40:00 -0000 1.2
+++ openacs-4/packages/categories/www/cadmin/category-delete-2.tcl 14 Dec 2003 15:36:57 -0000 1.3
@@ -6,15 +6,17 @@
@cvs-id $Id:
} {
tree_id:integer
- category_id:integer
+ category_id:integer,multiple
{locale ""}
object_id:integer,optional
}
permission::require_permission -object_id $tree_id -privilege category_tree_write
db_transaction {
- category::delete $category_id
+ foreach id $category_id {
+ category::delete $id
+ }
category_tree::flush_cache $tree_id
} on_error {
ad_return_complaint 1 "Error Deleting NodeThis node contains leaf (child) nodes. If you really want to delete those leaf nodes, plesae delete them first. Thank you."
Index: openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql 23 Apr 2003 12:29:27 -0000 1.1
+++ openacs-4/packages/categories/www/cadmin/category-delete-oracle.xql 14 Dec 2003 15:36:57 -0000 1.2
@@ -8,7 +8,7 @@
select case when count(*) = 0 then 0 else 1 end from dual
where exists (select 1 from category_object_map
- where category_id = :category_id)
+ where category_id = :id)
Index: openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql 23 Apr 2003 12:29:27 -0000 1.1
+++ openacs-4/packages/categories/www/cadmin/category-delete-postgresql.xql 14 Dec 2003 15:36:57 -0000 1.2
@@ -8,7 +8,7 @@
select case when count(*) = 0 then 0 else 1 end
where exists (select 1 from category_object_map
- where category_id = :category_id)
+ where category_id = :id)
Index: openacs-4/packages/categories/www/cadmin/category-delete.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/category-delete.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/category-delete.adp 22 May 2003 14:25:54 -0000 1.2
+++ openacs-4/packages/categories/www/cadmin/category-delete.adp 14 Dec 2003 15:36:57 -0000 1.3
@@ -3,11 +3,19 @@
@context_bar;noquote@
@locale;noquote@
-
-This category is still mapped to some objects.
-
-Are you sure you want to delete category "@category_name@"?
+
+ Are you sure you want to delete these categories:
+
+
+
+ -
+ @categories.name@
+ (Still mapped to objects)
+
+
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/master.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/master.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/master.tcl 27 Apr 2003 11:37:12 -0000 1.2
+++ openacs-4/packages/categories/www/cadmin/master.tcl 14 Dec 2003 15:36:58 -0000 1.3
@@ -19,6 +19,9 @@
set locale [ad_parameter DefaultLocale acs-lang "en_US"]
}
+# TODO: Refactor to use lang::system::get_locale_options and ad_form
+# so we don't hit the DB on every request
+
db_multirow languages get_locales ""
set current_page [ad_conn url]
Index: openacs-4/packages/categories/www/cadmin/tree-form.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-form.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/tree-form.adp 22 May 2003 14:25:54 -0000 1.2
+++ openacs-4/packages/categories/www/cadmin/tree-form.adp 14 Dec 2003 15:36:58 -0000 1.3
@@ -2,7 +2,8 @@
@page_title;noquote@
@context_bar;noquote@
f
+tree_form.tree_name
-
+
Index: openacs-4/packages/categories/www/cadmin/tree-form.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-form.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/tree-form.tcl 27 Apr 2003 11:37:12 -0000 1.2
+++ openacs-4/packages/categories/www/cadmin/tree-form.tcl 14 Dec 2003 15:36:58 -0000 1.3
@@ -12,55 +12,18 @@
page_title:onevalue
}
-set user_id [ad_maybe_redirect_for_registration]
-set package_id [ad_conn package_id]
+auth::require_login
-if {[info exists tree_id]} {
+if { ![ad_form_new_p -key tree_id] } {
set page_title "Edit tree"
} else {
set page_title "Add tree"
}
-if {[info exists object_id]} {
+if { [info exists object_id] } {
set context_bar [list [category::get_object_context $object_id] [list "one-object?[export_url_vars locale object_id]" "Category Management"]]
} else {
set context_bar [list [list ".?[export_url_vars locale]" "Category Management"]]
}
lappend context_bar $page_title
-set languages [db_list_of_lists get_ad_locales ""]
-
-ad_form -name tree_form -action tree-form -export { locale object_id } -form {
- {tree_id:key}
- {tree_name:text {label "Name"} {html {size 50 maxlength 50}}}
- {language:text(select) {label "Language"} {value $locale} {options $languages}}
- {description:text(textarea),optional {label "Description"} {html {rows 5 cols 80}}}
-} -new_request {
- permission::require_permission -object_id $package_id -privilege category_admin
- set tree_name ""
- set description ""
-} -edit_request {
- permission::require_permission -object_id $tree_id -privilege category_tree_write
- set action Edit
- util_unlist [category_tree::get_translation $tree_id $locale] tree_name description
-} -on_submit {
- set description [util_close_html_tags $description 4000]
-} -new_data {
- db_transaction {
- category_tree::add -tree_id $tree_id -name $tree_name -description $description -locale $language -context_id $package_id
- if { [info exists object_id] } {
- category_tree::map -tree_id $tree_id -object_id $object_id
- set return_url "one-object?[export_url_vars locale object_id]"
- } else {
- set return_url ".?[export_url_vars locale]"
- }
- }
-} -edit_data {
- category_tree::update -tree_id $tree_id -name $tree_name -description $description -locale $language
- set return_url "tree-view?[export_url_vars tree_id locale object_id]"
-} -after_submit {
- ad_returnredirect $return_url
- ad_script_abort
-}
-
-ad_return_template
Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/categories/www/cadmin/tree-form.xql'.
Fisheye: No comparison available. Pass `N' to diff?
Index: openacs-4/packages/categories/www/cadmin/tree-order-update.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-order-update.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-order-update.tcl 14 Dec 2003 15:36:58 -0000 1.1
@@ -0,0 +1,80 @@
+ad_page_contract {
+ Update sort order
+
+ @author Timo Hentschel (thentschel@sussdorff-roy.com)
+ @author Lars Pind (lars@collaboraid.biz)
+ @cvs-id $Id:
+} {
+ tree_id:integer
+ sort_key:array
+ {locale ""}
+ object_id:integer,optional
+}
+
+permission::require_permission -object_id $tree_id -privilege category_tree_write
+
+array set tree [category_tree::get_data $tree_id $locale]
+
+db_transaction {
+
+ set count 0
+ db_foreach get_tree "" {
+ incr count 10
+ if {[empty_string_p $parent_id]} {
+ # need this as an anchor for toplevel categories
+ set parent_id -1
+ }
+ if {[info exists sort_key($category_id)]} {
+ lappend child($parent_id) [list $sort_key($category_id) $category_id 0 0]
+ } else {
+ lappend child($parent_id) [list $count $category_id 0 0]
+ }
+ }
+ set last_ind [expr ($count / 5) + 1]
+
+ set count 1
+ set stack [list]
+ set done_list [list]
+ # put toplevel categories on stack
+ if {[info exists child(-1)]} {
+ set stack [lsort -integer -index 0 $child(-1)]
+ }
+
+ while {[llength $stack] > 0} {
+ set next [lindex $stack 0]
+ set act_category [lindex $next 1]
+ set stack [lrange $stack 1 end]
+ if {[lindex $next 2]>0} {
+ ## the children of this parent are done, so this category is also done
+ lappend done_list [list $act_category [lindex $next 2] $count]
+ } elseif {[info exists child($act_category)]} {
+ ## put category and all children back on stack
+ set next [lreplace $next 2 2 $count]
+ set stack [linsert $stack 0 $next]
+ set stack [concat [lsort -integer -index 0 $child($act_category)] $stack]
+ } else {
+ ## this category has no children, so it is done
+ lappend done_list [list $act_category $count [expr $count + 1]]
+ incr count 1
+ }
+ incr count 1
+ }
+
+ if {$count == $last_ind} {
+ # we do this so that there is no conflict in the old left_inds and the new ones
+ db_dml reset_category_index ""
+
+ foreach category $done_list {
+ util_unlist $category category_id left_ind right_ind
+ db_dml update_category_index ""
+ }
+ }
+ category_tree::flush_cache $tree_id
+}
+
+if {$count != $last_ind} {
+ ad_return_complaint 1 "Error during update: $done_list"
+ return
+}
+ad_returnredirect "tree-view?[export_url_vars tree_id locale object_id]"
+
Index: openacs-4/packages/categories/www/cadmin/tree-order-update.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-order-update.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/categories/www/cadmin/tree-order-update.xql 14 Dec 2003 15:36:58 -0000 1.1
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ select category_id, parent_id
+ from categories
+ where tree_id = :tree_id
+ order by left_ind
+
+
+
+
+
+
+
+
+ update categories
+ set left_ind = -left_ind,
+ right_ind = -right_ind
+ where tree_id = :tree_id
+
+
+
+
+
+
+
+
+ update categories
+ set left_ind = :left_ind,
+ right_ind = :right_ind
+ where category_id = :category_id
+
+
+
+
+
+
Index: openacs-4/packages/categories/www/cadmin/tree-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-view.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/tree-view.adp 22 May 2003 14:25:54 -0000 1.2
+++ openacs-4/packages/categories/www/cadmin/tree-view.adp 14 Dec 2003 15:36:58 -0000 1.3
@@ -3,96 +3,6 @@
@context_bar;noquote@
@locale;noquote@
-
-
- Tree Name | @tree_name@ |
- Description | @tree_description@ |
-
-
+
-
-
-
-
-
-
-
-
-
-
- no categories have been created...
-
+
Index: openacs-4/packages/categories/www/cadmin/tree-view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-view.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/categories/www/cadmin/tree-view.tcl 23 Apr 2003 12:29:27 -0000 1.1
+++ openacs-4/packages/categories/www/cadmin/tree-view.tcl 14 Dec 2003 15:36:58 -0000 1.2
@@ -55,4 +55,105 @@
template::multirow append one_tree $category_name $sort_key $category_id $deprecated_p $level [category::repeat_string " " [expr ($level-1)*5]]
}
-ad_return_template
+
+
+#----------------------------------------------------------------------
+# List builder
+#----------------------------------------------------------------------
+
+multirow extend one_tree edit_url delete_url usage_url set_parent_url add_child_url phase_in_url phase_out_url
+multirow foreach one_tree {
+ set usage_url [export_vars -base category-usage { category_id tree_id locale object_id }]
+ if { $can_write_p } {
+ set edit_url [export_vars -base category-form { category_id tree_id locale object_id }]
+ set delete_url [export_vars -base category-delete { category_id tree_id locale object_id }]
+ set set_parent_url [export_vars -base category-set-parent { category_id tree_id locale object_id }]
+ set add_child_url [export_vars -base category-form { { parent_id $category_id } tree_id locale object_id }]
+ if { [template::util::is_true $deprecated_p] } {
+ set phase_in_url [export_vars -base category-phase-out { category_id { phase_out_p 0 } tree_id locale object_id }]
+ } else {
+ set phase_out_url [export_vars -base category-phase-out { category_id { phase_out_p 1 } tree_id locale object_id }]
+ }
+ }
+}
+
+set elements [list]
+
+if { $can_write_p } {
+ lappend elements edit {
+ sub_class narrow
+ display_template {
+
+ }
+ link_url_col edit_url
+ }
+}
+
+lappend elements category_name {
+ label "Category"
+ display_template {
+ @one_tree.left_indent;noquote@@one_tree.category_name@
+ (Deprecated - Restore)
+ }
+}
+
+if { $can_write_p } {
+ lappend elements add_child {
+ sub_class narrow
+ display_template {
+
+ }
+ link_url_col add_child_url
+ link_html { title "Add subcategory" }
+ }
+ lappend elements sort_key {
+ label "Ordering"
+ display_template {
+
+ }
+ }
+ lappend elements actions {
+ label "Actions"
+ display_template {
+ Choose a new parent
+ }
+ }
+
+ lappend elements delete {
+ sub_class narrow
+ display_template {
+
+ }
+ link_url_col delete_url
+ link_html { title "Delete category and all subcategories" }
+ }
+}
+
+set actions [list]
+set bulk_actions [list]
+if { $can_write_p } {
+ set bulk_actions {
+ "Delete" "category-delete" "Delete checked categories"
+ "Deprecate" "category-phase-out" "Deprecate checked categories"
+ "Restore" "category-phase-in" "Restore checked categories"
+ "Update ordering" "tree-order-update" "Update ordering from values in list"
+ }
+ set actions [list \
+ "Add root category" [export_vars -base category-form { tree_id locale object_id }] "Add category at the root level" \
+ "Copy tree" [export_vars -base tree-copy { tree_id locale object_id }] "Copy categories from other tree" \
+ "Delete tree" [export_vars -base tree-delete { tree_id locale object_id }] "Delete this category tree" \
+ "Applications" [export_vars -base tree-usage { tree_id locale object_id }] "Applications using this tree"]
+
+ if { $can_grant_p } {
+ lappend actions "Permissions" [export_vars -base permission-manage { tree_id locale object_id }] "Manage permissions for tree"
+ }
+
+}
+
+template::list::create \
+ -name one_tree \
+ -elements $elements \
+ -key category_id \
+ -actions $actions \
+ -bulk_actions $bulk_actions \
+ -bulk_action_export_vars { tree_id locale object_id }
\ No newline at end of file