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.173 -r1.174
--- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 26 Oct 2011 01:53:04 -0000 1.173
+++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 27 Dec 2011 15:30:29 -0000 1.174
@@ -2394,7 +2394,9 @@
return $inner_html$save_form
}
+}
+namespace eval ::xowiki::includelet {
#############################################################################
# book style
#
@@ -2414,62 +2416,50 @@
}}
}
- book instproc render {} {
- my get_parameters
- my instvar __including_page
- lappend ::xowiki_page_item_id_rendered [$__including_page item_id]
- $__including_page set __is_book_page 1
-
- set allow_reorder [my page_reorder_check_allow $allow_reorder]
-
- set extra_where_clause ""
- set cnames ""
- if {[info exists category_id]} {
- foreach {cnames extra_where_clause} [my category_clause $category_id] break
+ book instproc render_item {
+ -menu_buttons
+ -content:required
+ -object:required
+ -level:required
+ } {
+ $object instvar page_order title name
+ set menu [list]
+ foreach b $menu_buttons {
+ if {[info command ::xowiki::includelet::$b] eq ""} {
+ set b $b-item-button
+ }
+ set html [$object include [list $b -book_mode true]]
+ if {$html ne ""} {lappend menu $html}
}
-
- foreach {locale locale_clause} \
- [::xowiki::Includelet locale_clause -revisions p -items p $package_id $locale] break
-
- if {$folder_mode} {
- # TODO just needed for michael aram?
- set parent_id [$__including_page item_id]
- } else {
- #set parent_id [$package_id folder_id]
- set parent_id [$__including_page parent_id]
+ set menu [join $menu " "]
+ if {$menu ne ""} {
+ #
not allowed in h*: style='float: right; position: relative; top: -32px
+ set menu "
$menu"
}
+ append output \
+ "
" $menu \
+ "$page_order $title" \
+ $content
+ }
- set pages [::xowiki::Page instantiate_objects -sql \
- "select page_id, page_order, name, title, item_id \
- from xowiki_page_live_revision p \
- where parent_id = $parent_id \
- and not page_order is NULL $extra_where_clause \
- $locale_clause \
- [::xowiki::Page container_already_rendered item_id]" ]
- $pages mixin add ::xo::OrderedComposite::IndexCompare
- $pages orderby page_order
-
+ book instproc render_items {
+ -pages:required
+ {-cnames ""}
+ {-allow_reorder ""}
+ -menu_buttons
+ {-with_footer "false"}
+ } {
set output ""
if {$cnames ne ""} {
append output "
Filtered by categories: $cnames
"
}
- set return_url [::xo::cc url]
- if {$range ne ""} {
- foreach {from to} [split $range -] break
- foreach p [$pages children] {
- if {[$pages __value_compare [$p set page_order] $from 0] == -1
- || [$pages __value_compare [$p set page_order] $to 0] > 0} {
- $pages delete $p
- }
- }
- }
-
my page_reorder_init_vars -allow_reorder $allow_reorder js last_level ID min_level
+ set renderer default
foreach o [$pages children] {
- $o instvar page_order title page_id name title
+ $o instvar page_order page_id
set level [expr {[regsub -all {[.]} $page_order _ page_order_js] + 1}]
if {$allow_reorder ne ""} {
@@ -2513,25 +2503,12 @@
#set content [string map [list "\{\{" "\\\{\{"] $content]
}
}
- set menu [list]
- foreach b $menu_buttons {
- if {[info command ::xowiki::includelet::$b] eq ""} {
- set b $b-item-button
- }
- set html [$p include [list $b -book_mode true]]
- if {$html ne ""} {lappend menu $html}
- }
- set menu [join $menu " "]
- if {$menu ne ""} {
- #
not allowed in h*: style='float: right; position: relative; top: -32px
- set menu "
$menu"
- }
-
- append output \
- "
" $menu \
- "$page_order $title" \
- $content
-
+
+ append output [my render_item \
+ -menu_buttons $menu_buttons \
+ -content $content \
+ -object $p \
+ -level $level]
if {$with_footer} {
append output [$p htmlFooter -content $content]
}
@@ -2541,12 +2518,137 @@
for {set l $last_level} {$l > 0} {incr l -1} {append output "\n" }
append output "\n"
}
+ return $output
+ }
+ book instproc render {} {
+ my get_parameters
+
+ my instvar __including_page
+ lappend ::xowiki_page_item_id_rendered [$__including_page item_id]
+ $__including_page set __is_book_page 1
+
+ set allow_reorder [my page_reorder_check_allow $allow_reorder]
+
+ set extra_where_clause ""
+ set cnames ""
+ if {[info exists category_id]} {
+ foreach {cnames extra_where_clause} [my category_clause $category_id] break
+ }
+
+ foreach {locale locale_clause} \
+ [::xowiki::Includelet locale_clause -revisions p -items p $package_id $locale] break
+
+ if {$folder_mode} {
+ # TODO just needed for michael aram?
+ set parent_id [$__including_page item_id]
+ } else {
+ #set parent_id [$package_id folder_id]
+ set parent_id [$__including_page parent_id]
+ }
+
+ set pages [::xowiki::Page instantiate_objects -sql \
+ "select page_id, page_order, name, title, item_id \
+ from xowiki_page_live_revision p \
+ where parent_id = $parent_id \
+ and not page_order is NULL $extra_where_clause \
+ $locale_clause \
+ [::xowiki::Page container_already_rendered item_id]" ]
+ $pages mixin add ::xo::OrderedComposite::IndexCompare
+ $pages orderby page_order
+
+ #
+ # filter range
+ #
+ if {$range ne ""} {
+ foreach {from to} [split $range -] break
+ foreach p [$pages children] {
+ if {[$pages __value_compare [$p set page_order] $from 0] == -1
+ || [$pages __value_compare [$p set page_order] $to 0] > 0} {
+ $pages delete $p
+ }
+ }
+ }
+
+ if {[llength [$pages children]] < 1} {
+ #
+ # Provide a hint why not pages were found
+ #
+ set p [::xo::db::CrClass get_instance_from_db -item_id $parent_id]
+ set output "
No pages with parent object [$p name], page_order not NULL and an appropriate publish status found
\n"
+ } else {
+ set output [my render_items \
+ -menu_buttons $menu_buttons \
+ -with_footer $with_footer \
+ -pages $pages \
+ -cnames $cnames \
+ -allow_reorder $allow_reorder]
+ }
return $output
}
}
namespace eval ::xowiki::includelet {
+ #############################################################################
+ # book style
+ #
+ ::xowiki::IncludeletClass create slidy \
+ -superclass ::xowiki::includelet::book \
+ -parameter {
+ {__decoration plain}
+ {parameter_declaration {
+ {-category_id}
+ {-menu_buttons edit}
+ {-folder_mode false}
+ {-locale ""}
+ {-range ""}
+ {-allow_reorder ""}
+ {-with_footer "false"}
+ }}
+ }
+ slidy instproc render_items {
+ -pages:required
+ {-cnames ""}
+ {-allow_reorder ""}
+ -menu_buttons
+ {-with_footer "false"}
+ } {
+ if {$cnames ne "" || $allow_reorder ne "" || $with_footer ne "false"} {
+ error "ignoring cnames, allow_reorder, and with_footer for the time being"
+ }
+
+ my instvar __including_page
+
+ set output [subst {
+
+
[$__including_page title]
+
+
+
+
+ }]
+ append output "\n"
+ foreach o [$pages children] {
+ $o instvar page_order page_id
+ set p [::xo::db::CrClass get_instance_from_db -item_id 0 -revision_id $page_id]
+
+ set content [$p render -with_footer false]
+
+ append output "
\n" $content "\n
\n"
+ }
+ append output "\n"
+ ns_return 200 text/html $output
+ ad_script_abort
+ #return $output
+ }
+}
+
+#############################################################################
+# item-button
+#
+namespace eval ::xowiki::includelet {
::xowiki::IncludeletClass create item-button \
-superclass ::xowiki::Includelet \
-parameter {
@@ -2736,8 +2838,6 @@
-object_type $object_type]
}
}
-
-
}