xowiki::includelet::toc instproc build_toc
<instance of xowiki::includelet::toc> build_toc
Defined in
- Testcases:
-
includelet_toc, xowiki
Source code:
:get_parameters
array set :navigation {parent "" position 0 current ""}
set extra_where_clause ""
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 order_direction asc
set order_attribute page_order
if {$source ne ""} {
:get_page_order -source $source
set page_order_clause "and name in ([ns_dbquotelist [array names :page_order]])"
set page_order_att ""
} elseif {$orderby ne ""} {
lassign [split $orderby ,] order_attribute order_direction
if {$order_attribute ni {page_order title}} {
ns_log warning "toc includelet: ignore invalid page order '$orderby'"
set order_attribute page_order
set order_direction asc
set page_order_att "page_order,"
set page_order_clause "and not page_order is NULL"
} else {
set page_order_att "page_order,"
set page_order_clause ""
append extra_where_clause " and page_id != [${:__including_page} revision_id]"
}
} else {
set page_order_clause "and not page_order is NULL"
set page_order_att "page_order,"
}
if {$folder_mode} {
set parent_id [${:__including_page} item_id]
} else {
set parent_id [${:__including_page} parent_id]
}
set sql [::xo::dc select -vars "page_id, $page_order_att name, title" -from "xowiki_page_live_revision p" -where "parent_id = :parent_id $page_order_clause $extra_where_clause $locale_clause"]
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
if {$range ne "" && $page_order_att 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 {$source ne ""} {
foreach p [$pages children] {
$p set page_order [set :page_order([$p set name])]
}
}
return $pages
XQL Not present:Generic, PostgreSQL, Oracle
[
hide source ]
| [
make this the default ]