Index: openacs-4/packages/categories/categories.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/categories.info,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/categories/categories.info 15 May 2007 20:14:23 -0000 1.11
+++ openacs-4/packages/categories/categories.info 28 Aug 2007 16:30:03 -0000 1.12
@@ -8,15 +8,15 @@
f
categories
-
+
timo@timohentschel.de
Manage categories in category trees and let users map objects to categories.
2006-02-12
Datamodel for category trees with supporting API and management pages. Provides a widget for
general categorization of arbitrary objects and tracks which package instances use which category trees. Also supports localization.
0
-
+
Index: openacs-4/packages/categories/tcl/category-form-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/category-form-procs.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/categories/tcl/category-form-procs.tcl 26 Jan 2005 00:27:26 -0000 1.4
+++ openacs-4/packages/categories/tcl/category-form-procs.tcl 28 Aug 2007 16:30:03 -0000 1.5
@@ -27,7 +27,7 @@
set category_trees [category_tree::get_mapped_trees $container_object_id]
foreach tree $category_trees {
- util_unlist $tree tree_id name subtree_id assign_single_p require_category_p
+ util_unlist $tree tree_id name subtree_id assign_single_p require_category_p widget
if {[lsearch -exact $excluded_trees $tree_id] > -1} {
continue
}
@@ -46,6 +46,7 @@
{category_object_id {[value_if_exists categorized_object_id]}} \
{category_assign_single_p $assign_single_p} \
{category_require_category_p $require_category_p} \
+ {category_widget $widget} \
{help_text $help_text} \
]]
@@ -66,7 +67,7 @@
set category_trees [category_tree::get_mapped_trees $container_object_id]
set category_ids [list]
foreach tree $category_trees {
- util_unlist $tree tree_id name subtree_id assign_single_p require_category_p
+ util_unlist $tree tree_id name subtree_id assign_single_p require_category_p widget
upvar #[template::adp_level] \
__category__ad_form__$element_name\_${tree_id} my_category_ids
if {[info exists my_category_ids]} {
Index: openacs-4/packages/categories/tcl/category-trees-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/category-trees-procs-oracle.xql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/categories/tcl/category-trees-procs-oracle.xql 31 Mar 2004 21:22:32 -0000 1.4
+++ openacs-4/packages/categories/tcl/category-trees-procs-oracle.xql 28 Aug 2007 16:30:03 -0000 1.5
@@ -12,7 +12,8 @@
subtree_category_id => :subtree_category_id,
tree_id => :tree_id,
assign_single_p => :assign_single_p,
- require_category_p => :require_category_p);
+ require_category_p => :require_category_p
+ widget => :widget);
end;
Index: openacs-4/packages/categories/tcl/category-trees-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/category-trees-procs-postgresql.xql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/categories/tcl/category-trees-procs-postgresql.xql 31 Mar 2004 21:22:34 -0000 1.6
+++ openacs-4/packages/categories/tcl/category-trees-procs-postgresql.xql 28 Aug 2007 16:30:03 -0000 1.7
@@ -10,7 +10,9 @@
:tree_id,
:subtree_category_id,
:assign_single_p,
- :require_category_p)
+ :require_category_p,
+ :widget
+ )
Index: openacs-4/packages/categories/tcl/category-trees-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/category-trees-procs.tcl,v
diff -u -r1.20 -r1.21
--- openacs-4/packages/categories/tcl/category-trees-procs.tcl 21 Dec 2006 11:52:25 -0000 1.20
+++ openacs-4/packages/categories/tcl/category-trees-procs.tcl 28 Aug 2007 16:30:03 -0000 1.21
@@ -32,6 +32,7 @@
{-subtree_category_id ""}
{-assign_single_p f}
{-require_category_p f}
+ {-widget ""}
} {
Map a category tree to a package (or other object).
@@ -67,6 +68,7 @@
-object_id:required
{-assign_single_p f}
{-require_category_p f}
+ {-widget ""}
} {
Edit the parameters of a mapped category tree.
@@ -209,7 +211,7 @@
set result [list]
db_foreach get_mapped_trees "" {
- lappend result [list $tree_id [get_name $tree_id $locale] $subtree_category_id $assign_single_p $require_category_p]
+ lappend result [list $tree_id [get_name $tree_id $locale] $subtree_category_id $assign_single_p $require_category_p $widget]
}
return $result
@@ -221,36 +223,18 @@
@param object_id_list list of object to get the mapped category trees.
@param locale language in which to get the name. [ad_conn locale] used by default.
@return tcl list of lists: tree_id tree_name subtree_category_id
- assign_single_p require_category_p
+ assign_single_p require_category_p widget
@author Jade Rubick (jader@bread.com)
} {
set result [list]
db_foreach get_mapped_trees_from_object_list "" {
- lappend result [list $tree_id [get_name $tree_id $locale] $subtree_category_id $assign_single_p $require_category_p]
+ lappend result [list $tree_id [get_name $tree_id $locale] $subtree_category_id $assign_single_p $require_category_p $widget]
}
return $result
}
- ad_proc -public get_mapped_trees_from_object_list { object_id_list {locale ""}} {
- Get the category trees mapped to a list of objects.
-
- @param object_id_list list of object to get the mapped category trees.
- @param locale language in which to get the name. [ad_conn locale] used by default.
- @return tcl list of lists: tree_id tree_name subtree_category_id
- assign_single_p require_category_p
- @author Jade Rubick (jader@bread.com)
- } {
- set result [list]
-
- db_foreach get_mapped_trees_from_object_list "" {
- lappend result [list $tree_id [get_name $tree_id $locale] $subtree_category_id $assign_single_p $require_category_p]
- }
-
- return $result
- }
-
ad_proc -public get_tree {
-all:boolean
{-subtree_id ""}
Index: openacs-4/packages/categories/tcl/category-trees-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/Attic/category-trees-procs.xql,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/categories/tcl/category-trees-procs.xql 31 Jul 2006 20:31:11 -0000 1.8
+++ openacs-4/packages/categories/tcl/category-trees-procs.xql 28 Aug 2007 16:30:03 -0000 1.9
@@ -17,7 +17,8 @@
update category_tree_map
set assign_single_p = :assign_single_p,
- require_category_p = :require_category_p
+ require_category_p = :require_category_p,
+ widget = :widget
where tree_id = :tree_id
and object_id = :object_id
@@ -52,7 +53,7 @@
select tree_id, subtree_category_id, assign_single_p,
- require_category_p
+ require_category_p, widget
from category_tree_map
where object_id = :object_id
@@ -64,7 +65,7 @@
select tree_id, subtree_category_id, assign_single_p,
- require_category_p
+ require_category_p, widget
from category_tree_map
where object_id in ([join $object_id_list ", "])
Index: openacs-4/packages/categories/tcl/widget-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/widget-procs.tcl,v
diff -u -r1.19 -r1.20
--- openacs-4/packages/categories/tcl/widget-procs.tcl 31 Jul 2006 20:31:11 -0000 1.19
+++ openacs-4/packages/categories/tcl/widget-procs.tcl 28 Aug 2007 16:30:03 -0000 1.20
@@ -48,6 +48,7 @@
set subtree_id {}
set assign_single_p f
set require_category_p f
+ set widget {}
if { [exists_and_not_null element(value)] && [llength $element(value)] == 2 } {
# Legacy method for passing parameters
@@ -72,6 +73,9 @@
if { [exists_and_not_null element(category_require_category_p)] } {
set require_category_p $element(category_require_category_p)
}
+ if { [exists_and_not_null element(category_require_category_p)] } {
+ set widget $element(category_widget)
+ }
}
if { [empty_string_p $package_id] } {
set package_id [ad_conn package_id]
@@ -94,19 +98,19 @@
set mapped_trees [category_tree::get_mapped_trees $package_id]
} else {
set mapped_trees {}
- foreach one_tree $tree_id one_subtree $subtree_id assign_single $assign_single_p require_category $require_category_p {
+ foreach one_tree $tree_id one_subtree $subtree_id assign_single $assign_single_p require_category $require_category_p widget $widget {
if {[empty_string_p $assign_single]} {
set assign_single f
}
if {[empty_string_p $require_category]} {
set require_category f
}
- lappend mapped_trees [list $one_tree [category_tree::get_name $one_tree] $one_subtree $assign_single $require_category]
+ lappend mapped_trees [list $one_tree [category_tree::get_name $one_tree] $one_subtree $assign_single $require_category $widget]
}
}
foreach mapped_tree $mapped_trees {
- util_unlist $mapped_tree tree_id tree_name subtree_id assign_single_p require_category_p
+ util_unlist $mapped_tree tree_id tree_name subtree_id assign_single_p require_category_p widget
set tree_name [ad_quotehtml [lang::util::localize $tree_name]]
set one_tree [list]
@@ -134,10 +138,24 @@
if { $require_category_p == "f" } {
set one_tree [concat [list [list "" ""]] $one_tree]
}
- append output [template::widget::menu $element(name) $one_tree $mapped_categories attributes $element(mode) $display_widget]
+ # we default to the select widget unless the valid option of radio was provided
+ ns_log notice "template::widget::menu $element(name) $one_tree $mapped_categories [array get attributes] $element(mode) $widget $display_widget [info exists element(display_widget)]"
+
+ if { $widget eq "radio" && ![info exists element(display_widget)] } {
+ # checkbox was specified at mapping and the display widget was not explicitly defined code
+ append output [template::widget::menu $element(name) $one_tree $mapped_categories attributes $element(mode) radio]
+ } else {
+ append output [template::widget::menu $element(name) $one_tree $mapped_categories attributes $element(mode) $display_widget]
+ }
} else {
- # multiselect widget (if user didn't override with single option)
- append output [template::widget::menu $element(name) $one_tree $mapped_categories ms_attributes $element(mode) $display_widget]
+ ns_log notice "template::widget::menu $element(name) $one_tree $mapped_categories [array get ms_attributes] $element(mode) $widget $display_widget [info exists element(display_widget)]"
+ # we default to the multiselect widget (if user didn't override with single option) or select checkbox
+ if { $widget eq "checkbox" && ![info exists element(display_widget)] } {
+ # checkbox was specified at mapping and the display widget was not explicitly defined in code
+ append output [template::widget::menu $element(name) $one_tree $mapped_categories ms_attributes $element(mode) checkbox]
+ } else {
+ append output [template::widget::menu $element(name) $one_tree $mapped_categories ms_attributes $element(mode) $display_widget]
+ }
}
if { [llength $mapped_trees] > 1 } {
append output ""
Index: openacs-4/packages/categories/www/cadmin/object-map.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/object-map.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/categories/www/cadmin/object-map.tcl 1 Mar 2005 00:01:26 -0000 1.2
+++ openacs-4/packages/categories/www/cadmin/object-map.tcl 28 Aug 2007 16:30:03 -0000 1.3
@@ -26,15 +26,15 @@
set page_title "Category Management"
set context_bar [list $context_bar $page_title]
-template::multirow create mapped_trees tree_name tree_id site_wide_p assign_single_p require_category_p view_url unmap_url edit_url
+template::multirow create mapped_trees tree_name tree_id site_wide_p assign_single_p require_category_p widget view_url unmap_url edit_url
db_foreach get_mapped_trees "" {
set tree_name [category_tree::get_name $tree_id $locale]
if {![empty_string_p $subtree_category_id]} {
append tree_name " :: [category::get_name $subtree_category_id $locale]"
}
template::multirow append mapped_trees $tree_name $tree_id $site_wide_p \
- $assign_single_p $require_category_p \
+ $assign_single_p $require_category_p $widget \
[export_vars -no_empty -base tree-view { tree_id locale object_id }] \
[export_vars -no_empty -base tree-unmap { tree_id locale object_id }] \
[export_vars -no_empty -base tree-map-2 { tree_id locale object_id {edit_p 1}}]
@@ -67,7 +67,8 @@
}
flags {
display_template {
- (Site-Wide Tree,
+ (Site-Wide Tree,
+ @mapped_trees.widget@,
single, multiple,
required) optional)
}
Index: openacs-4/packages/categories/www/cadmin/object-map.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/object-map.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/categories/www/cadmin/object-map.xql 11 Feb 2004 11:44:00 -0000 1.1
+++ openacs-4/packages/categories/www/cadmin/object-map.xql 28 Aug 2007 16:30:03 -0000 1.2
@@ -5,7 +5,7 @@
select t.tree_id, t.site_wide_p, m.subtree_category_id,
- m.assign_single_p, m.require_category_p
+ m.assign_single_p, m.require_category_p, m.widget
from category_trees t, category_tree_map m
where m.object_id = :object_id
and m.tree_id = t.tree_id
Index: openacs-4/packages/categories/www/cadmin/tree-map-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-map-2.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/categories/www/cadmin/tree-map-2.tcl 1 Mar 2005 00:01:27 -0000 1.3
+++ openacs-4/packages/categories/www/cadmin/tree-map-2.tcl 28 Aug 2007 16:30:03 -0000 1.4
@@ -40,20 +40,40 @@
}
ad_form -name tree_map_form -action tree-map-2 -export { tree_id category_id locale object_id edit_p } -form {
- {assign_single_p:text(radio) {label "Let users assign multiple categories?"} {options {{"Yes" f} {"No" t}}}}
+ {widget:text(radio) {label "Widget"} {options {
+ {"Select" select}
+ {"Multiselect - let users assign multiple categories" multiselect}
+ {"Radio" radio}
+ {"Checkbox - let users assign multiple categories" checkbox}
+ }}}
{require_category_p:text(radio) {label "Require users to assign at least one category?"} {options {{"Yes" t} {"No" f}}}}
} -on_request {
if {$edit_p} {
db_1row get_mapping_parameters ""
+ if { $widget eq "" } {
+ # this is pre-widget selection and we default to the same
+ # look and feel as before
+ if { $assign_single_p } {
+ set widget "select"
+ } else {
+ set widget "multiselect"
+ }
+ }
} else {
- set assign_single_p f
+ # we default to the default before widgets could be selected
+ set widget multiselect
set require_category_p f
}
} -on_submit {
+ if { $widget eq "select" || $widget eq "radio" } {
+ set assign_single_p t
+ } else {
+ set assign_single_p f
+ }
if {$edit_p} {
- category_tree::edit_mapping -tree_id $tree_id -object_id $object_id -assign_single_p $assign_single_p -require_category_p $require_category_p
+ category_tree::edit_mapping -tree_id $tree_id -object_id $object_id -assign_single_p $assign_single_p -require_category_p $require_category_p -widget $widget
} else {
- category_tree::map -tree_id $tree_id -subtree_category_id $category_id -object_id $object_id -assign_single_p $assign_single_p -require_category_p $require_category_p
+ category_tree::map -tree_id $tree_id -subtree_category_id $category_id -object_id $object_id -assign_single_p $assign_single_p -require_category_p $require_category_p -widget $widget
}
} -after_submit {
ad_returnredirect [export_vars -no_empty -base object-map {locale object_id}]
Index: openacs-4/packages/categories/www/cadmin/tree-map-2.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/cadmin/tree-map-2.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/categories/www/cadmin/tree-map-2.xql 11 Feb 2004 09:35:31 -0000 1.1
+++ openacs-4/packages/categories/www/cadmin/tree-map-2.xql 28 Aug 2007 16:30:03 -0000 1.2
@@ -16,7 +16,7 @@
- select assign_single_p, require_category_p
+ select assign_single_p, require_category_p, widget
from category_tree_map
where tree_id = :tree_id
and object_id = :object_id