Class ::xowiki::includelet::book (public)
::xowiki::IncludeletClass ::xowiki::includelet::book
Defined in /var/www/openacs.org/packages/xowiki/tcl/includelet-procs.tcl
Show contents in book mode.
- Testcases:
- No testcase defined.
Source code: namespace eval ::xowiki::includelet {} ::nsf::object::alloc ::xowiki::IncludeletClass ::xowiki::includelet::book {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object set :aggregating false set :cacheable false set :localized true set :personalized true} ::xowiki::includelet::book instproc render {} { :get_parameters lappend ::xowiki_page_item_id_rendered [${:__including_page} item_id] ${:__including_page} set __is_book_page 1 set allow_reorder [:page_reorder_check_allow $allow_reorder] lassign [split $orderby ,] order_attribute order_direction if {$order_attribute ni {page_order title}} { ns_log warning "book includelet: ignore invalid page order '$orderby'" set order_attribute page_order set order_direction asc } set page_order_clause [expr {$order_attribute eq "page_order" ? "and not page_order is NULL" : ""}] set extra_where_clause "" set cnames "" if {[info exists category_id]} { lassign [:category_clause $category_id] cnames extra_where_clause } lassign [::xowiki::Includelet locale_clause -revisions p -items p $package_id $locale] locale locale_clause set publish_status_clause [expr {[info exists publish_status] ? [::xowiki::Includelet publish_status_clause -base_table p $publish_status] : ""}] 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 sql "select page_id, page_order, name, title, item_id from xowiki_page_live_revision p where parent_id = [ns_dbquotevalue $parent_id] $page_order_clause $extra_where_clause $locale_clause $publish_status_clause [::xowiki::Page container_already_rendered item_id]" set pages [::xowiki::Page instantiate_objects -sql $sql] $pages orderby -order [expr {$order_direction in {asc ""} ? "increasing" : "decreasing"}] -type [ad_decode $order_attribute page_order index dictionary] $order_attribute # # filter range # if {$range ne ""} { lassign [split $range -] from to 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 "<p>No pages with parent object [$p name], page_order not NULL and an appropriate publish status found</p>\n" } else { set output [:render_items -menu_buttons $menu_buttons -with_footer $with_footer -pages $pages -cnames $cnames -allow_reorder $allow_reorder] } return $output } ::xowiki::includelet::book instproc render_items {-pages:required {-cnames ""} {-allow_reorder ""} -menu_buttons {-with_footer "false"}} { set output "" if {$cnames ne ""} { append output "<div class='filter'>Filtered by categories: $cnames</div>" } :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 page_id set level [expr {[regsub -all -- {[.]} $page_order _ page_order_js] + 1}] if {$allow_reorder ne ""} { # # Build a (nested) list structure mirroring the hierarchy # implied by the page_order. In essence, we provide CSS # classes for the ULs and provide IDs for ULs and LI elements, # and pass the associated page_order to javascript. # if {![regexp {^(.*)[.][^.]+$} $page_order _ prefix]} {set prefix ""} # First, insert the appropriate opening and closing of ULs. We # could handle here prefix changes as well as different lists # (e.g. 1.1 1.2 2.1) # if {$last_level != $level} { for {set l $last_level} {$l > $level} {incr l -1} {append output "</ul>\n" } for {set l $last_level} {$l < $level} {incr l} { regsub -all -- {[.]} $prefix _ prefix_js append output [:page_reorder_open_ul -min_level $min_level -ID $ID -prefix_js $prefix_js $l] } set last_level $level set last_prefix $prefix } # Pass the page_order for the element to JavaScript and add # the li element for the section. set item_id [:page_reorder_item_id -ID $ID -prefix_js $prefix_js -page_order $page_order js] append output "<li id='[ns_quotehtml $item_id]'>" } set p [::xo::db::CrClass get_instance_from_db -item_id 0 -revision_id $page_id] $p references clear #$p set render_adp 0 switch [$p info class] { ::xowiki::Form { set content [$p render] } default { set content [$p render -with_footer false] #set content [string map [list "\{\{" "\\\{\{"] $content] } } append output [:render_item -menu_buttons $menu_buttons -content $content -object $p -level $level] if {$with_footer} { append output [$p htmlFooter -content $content] } } if {$allow_reorder ne ""} { for {set l $last_level} {$l > 0} {incr l -1} {append output "</ul>\n" } append output "<script type='text/javascript' nonce='[security::csp::nonce]'>$js</script>\n" } return $output } ::xowiki::includelet::book instproc render_images {-addClass pages} { # # Return a list of the rendered images in HTML markup. The page # content is reduced to a bare image. Note that this function # does not return "pages" not containing images. # set imageList {} foreach o [$pages children] { set p [::xo::db::CrClass get_instance_from_db -item_id 0 -revision_id [$o set page_id]] set html [$p render -with_footer false] if {[regsub -nocase {^(.*)(<img\s*[^>]+>)(.*)$} $html {\2} html] < 1} continue if {[info exists addClass]} { regsub -nocase {class\s*=\s*'([^']+)'} $html "class='\\1 $addClass'" html } lappend imageList $html } return $imageList } ::xowiki::includelet::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 commands ::xowiki::includelet::$b] eq ""} { set b $b-item-button } set html [$object include [list $b -book_mode true]] if {$html ne ""} {lappend menu $html} } set menu [join $menu " "] if {$menu ne ""} { # <div> not allowed in h*: style='float: right; position: relative; top: -32px set menu "<span class='book-item-menu'>$menu</span>" } set label "$page_order $title" append output "<h$level class='book'>" $menu "<a name='[ns_quotehtml [toc anchor $name]]'></a>[ns_quotehtml $label]</h$level>" $content } ::xowiki::includelet::book instparametercmd parameter_declaration ::xowiki::includelet::book instparametercmd __decoration ::nsf::relation::set ::xowiki::includelet::book superclass ::xowiki::Includelet ::nsf::relation::set ::xowiki::includelet::book class-mixin ::xowiki::includelet::PageReorderSupport ::nx::slotObj -container slot ::xowiki::includelet::book ::xowiki::includelet::book::slot eval {set :__parameter { {__decoration plain} {parameter_declaration { {-category_id} {-menu_buttons edit} {-folder_mode false} {-locale ""} {-range ""} {-allow_reorder ""} {-orderby "page_order,asc"} {-with_footer "false"} {-publish_status "ready"} }} }} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::book::slot::__decoration {set :accessor public set :configurable true set :convert false set :default plain set :defaultmethods {} set :disposition alias set :domain ::xowiki::includelet::book set :incremental 0 set :manager ::xowiki::includelet::book::slot::__decoration set :methodname __decoration set :multiplicity 1..1 set :name __decoration set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::book::slot::parameter_declaration {set :accessor public set :configurable true set :convert false set :default { {-category_id} {-menu_buttons edit} {-folder_mode false} {-locale ""} {-range ""} {-allow_reorder ""} {-orderby "page_order,asc"} {-with_footer "false"} {-publish_status "ready"} } set :defaultmethods {} set :disposition alias set :domain ::xowiki::includelet::book set :incremental 0 set :manager ::xowiki::includelet::book::slot::parameter_declaration set :methodname parameter_declaration set :multiplicity 1..1 set :name parameter_declaration set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init}XQL Not present: Generic, PostgreSQL, Oracle