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.16 -r1.17 --- openacs-4/packages/xowiki/tcl/category-procs.tcl 4 Jan 2009 19:24:39 -0000 1.16 +++ openacs-4/packages/xowiki/tcl/category-procs.tcl 13 May 2009 13:23:27 -0000 1.17 @@ -31,21 +31,17 @@ } CatTree instproc open_tree {} {;} - CatTree instproc render {{-tree_style:boolean false}} { - set content "" - if {$tree_style} { - #::xo::Page requireCSS "/resources/acs-templating/mktree.css" - ::xo::Page requireCSS "/resources/xowiki/cattree.css" - ::xo::Page requireJS "/resources/acs-templating/mktree.js" - - foreach c [my children] {append content [$c render] \n} - return "" - } else { - Category instmixin Category::section_style - foreach c [my children] {append content [$c render] \n} - Category instmixin "" - return $content + CatTree instproc render {{-style mktree}} { + set renderer CategoryStyle=$style + if {![my isclass $renderer]} { + error "No such renderer $renderer (avalialble [info cmd ::xowiki::CategoryStyle=*]" } + + Category instmixin $renderer + set content [$renderer render [self]] + Category instmixin "" + + return $content } # @@ -91,15 +87,23 @@ # # These are the list-specific rendering functions # - - Category instproc render_item {{-highlight:boolean false} item} { + Class create CategoryStyle=mktree + CategoryStyle=mktree proc render {cattree} { + #::xo::Page requireCSS "/resources/acs-templating/mktree.css" + ::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 "" + } + CategoryStyle=mktree instproc render_item {{-highlight:boolean false} item} { if {$highlight} { return "
  • $item
  • \n" } else { return "
  • $item
  • \n" } } - Category instproc render_category {{-open:boolean false} cat_content} { + CategoryStyle=mktree instproc render_category {{-open:boolean false} cat_content} { set open_state [expr {[my set open_requests]>0?"class='liOpen'" : "class='liClosed'"}] set c [expr {[my exists count] ? "([my count])" : ""}] return "
  • [my label] $c\n \n" @@ -108,16 +112,21 @@ # # These are the section-specific rendering functions # - - Class Category::section_style - Category::section_style instproc render_item {{-highlight:boolean false} item} { + + Class create CategoryStyle=sections + CategoryStyle=sections proc render {cattree} { + set content "" + foreach c [$cattree children] {append content [$c render] \n} + return $content + } + CategoryStyle=sections instproc render_item {{-highlight:boolean false} item} { if {$highlight} { return "$item
    \n" } else { return "$item
    \n" } } - Category::section_style instproc render_category {{-open:boolean false} cat_content} { + CategoryStyle=sections instproc render_category {{-open:boolean false} cat_content} { set section [expr {[my level] + 2}] return "[my label]\n

    \

    $cat_content
    \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.111 -r1.112 --- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 8 May 2009 09:12:15 -0000 1.111 +++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 13 May 2009 13:23:27 -0000 1.112 @@ -606,6 +606,7 @@ {-locale ""} {-open_page ""} {-order_items_by "title,asc"} + {-style "mktree"} {-category_ids ""} {-except_category_ids ""} {-allow_edit false} @@ -765,6 +766,10 @@ } 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" { @@ -773,7 +778,7 @@ $category($category_id) href [ad_conn url]?category_id=$category_id$s $category($category_id) open_tree } - append content [$cattree(0) render -tree_style $tree_style] + append content [$cattree(0) render -style $style] } else { foreach {orderby direction} [split $order_items_by ,] break ;# e.g. "title,asc" set increasing [expr {$direction ne "desc"}] @@ -794,7 +799,7 @@ -increasing $increasing \ -open_item [expr {$item_id == $open_item_id}] } - append content [$cattree(0) render -tree_style $tree_style] + append content [$cattree(0) render -style $style] } } return $content @@ -865,7 +870,7 @@ } $cattree add_to_category -category $categories($category_id) -itemobj $itemobj } - return [$cattree render] + return [$cattree render -style sections] } }