Index: openacs-4/packages/xowiki/tcl/category-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/category-procs.tcl,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/xowiki/tcl/category-procs.tcl 13 May 2009 13:40:36 -0000 1.18
+++ openacs-4/packages/xowiki/tcl/category-procs.tcl 15 May 2009 07:05:19 -0000 1.19
@@ -4,7 +4,24 @@
#
Class CatTree -superclass ::xo::OrderedComposite -parameter {{name ""}}
+ #
+ # Class methods
+ #
+ CatTree proc renderer {style} {
+ set renderer CategoryRenderer=$style
+ if {![my isclass $renderer]} {
+ error "No such renderer $renderer (avalialble [info cmd ::xowiki::CategoryRenderer=*]"
+ }
+ return $renderer
+ }
+ CatTree proc include_head_entries {{-style mktree}} {
+ [my renderer $style] include_head_entries
+ }
+
+ #
+ # Instance methods
+ #
CatTree instproc add_to_category {
-category
-orderby
@@ -30,13 +47,8 @@
}
}
CatTree instproc open_tree {} {;}
-
CatTree instproc render {{-style mktree}} {
- set renderer CategoryRenderer=$style
- if {![my isclass $renderer]} {
- error "No such renderer $renderer (avalialble [info cmd ::xowiki::CategoryRenderer=*]"
- }
-
+ set renderer [[self class] renderer $style]
Category instmixin $renderer
set content [$renderer render [self]]
Category instmixin ""
@@ -85,17 +97,30 @@
}
#
+ # Define a meta class for the category renderers with the common
+ # behavior.
+ #
+ Class create CategoryRenderer -superclass Class
+ CategoryRenderer instproc include_head_entries {} {
+ # to be overloaded
+ }
+ CategoryRenderer instproc render {cattree} {
+ set content ""
+ foreach c [$cattree children] {append content [$c render] \n}
+ return $content
+ }
+
+ #
# These are the list-specific rendering functions
#
- Class create CategoryRenderer=mktree
- CategoryRenderer=mktree proc render {cattree} {
- #::xo::Page requireCSS "/resources/acs-templating/mktree.css"
+ CategoryRenderer create CategoryRenderer=mktree
+ CategoryRenderer=mktree proc include_head_entries {} {
::xo::Page requireCSS "/resources/xowiki/cattree.css"
::xo::Page requireJS "/resources/acs-templating/mktree.js"
-
- foreach c [$cattree children] {append content [$c render] \n}
- return "
"
}
+ CategoryRenderer=mktree proc render {cattree} {
+ return ""
+ }
CategoryRenderer=mktree instproc render_item {{-highlight:boolean false} item} {
if {$highlight} {
return "$item\n"
@@ -113,12 +138,7 @@
# These are the section-specific rendering functions
#
- Class create CategoryRenderer=sections
- CategoryRenderer=sections proc render {cattree} {
- set content ""
- foreach c [$cattree children] {append content [$c render] \n}
- return $content
- }
+ CategoryRenderer create CategoryRenderer=sections
CategoryRenderer=sections instproc render_item {{-highlight:boolean false} item} {
if {$highlight} {
return "$item
\n"
Index: openacs-4/packages/xowiki/tcl/includelet-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/includelet-procs.tcl,v
diff -u -r1.112 -r1.113
--- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 13 May 2009 13:23:27 -0000 1.112
+++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 15 May 2009 07:05:19 -0000 1.113
@@ -614,6 +614,18 @@
}}
}
+ categories instproc initialize {} {
+ my get_parameters
+ if {!$tree_style} {
+ set style sections
+ }
+ my set style $style
+ }
+
+ categories instproc include_head_entries {} {
+ ::xowiki::CatTree include_head_entries -style [my set style]
+ }
+
categories instproc category_tree_edit_button {-object_id:integer -locale {-allow_edit false} -tree_id:integer} {
set allow_p [::xo::cc permission -object_id $object_id -privilege admin -party_id [::xo::cc set untrusted_user_id]]
if {$allow_edit && $allow_p} {
@@ -766,10 +778,6 @@
}
append sql $locale_clause
- if {!$tree_style} {
- set style sections
- }
-
if {$count} {
db_foreach [my qn get_counts] \
"select count(*) as nr,category_id from $sql group by category_id" {
@@ -778,7 +786,7 @@
$category($category_id) href [ad_conn url]?category_id=$category_id$s
$category($category_id) open_tree
}
- append content [$cattree(0) render -style $style]
+ append content [$cattree(0) render -style [my set style]]
} else {
foreach {orderby direction} [split $order_items_by ,] break ;# e.g. "title,asc"
set increasing [expr {$direction ne "desc"}]
@@ -799,7 +807,7 @@
-increasing $increasing \
-open_item [expr {$item_id == $open_item_id}]
}
- append content [$cattree(0) render -style $style]
+ append content [$cattree(0) render -style [my set style]]
}
}
return $content
@@ -829,6 +837,14 @@
}}
}
+ categories-recent instproc initialize {} {
+ my set style sections
+ }
+
+ categories-recent instproc include_head_entries {} {
+ ::xowiki::CatTree include_head_entries -style [my set style]
+ }
+
categories-recent instproc render {} {
my get_parameters
@@ -870,7 +886,7 @@
}
$cattree add_to_category -category $categories($category_id) -itemobj $itemobj
}
- return [$cattree render -style sections]
+ return [$cattree render -style [my set style]]
}
}