%3 ::xowiki::includelet::PageReorderSupport ::xowiki::includelet::PageReorderSupport page_reorder_check_allow page_reorder_init_vars page_reorder_item_id page_reorder_open_ul ::xotcl::Object ::xotcl::Object ::xowiki::includelet::PageReorderSupport->::xotcl::Object ::xowiki::includelet::book ::xowiki::includelet::book render render_images render_item render_items ::xowiki::includelet::book->::xowiki::includelet::PageReorderSupport instmixin ::xowiki::Includelet ::xowiki::Includelet ::xowiki::includelet::book->::xowiki::Includelet ::xowiki::includelet::slidy ::xowiki::includelet::slidy render_items ::xowiki::includelet::slidy->::xowiki::includelet::book ::xowiki::includelet::jquery-spacegallery ::xowiki::includelet::jquery-spacegallery render_items ::xowiki::includelet::jquery-spacegallery->::xowiki::includelet::book ::xowiki::includelet::jquery-infinite-carousel ::xowiki::includelet::jquery-infinite-carousel render_items ::xowiki::includelet::jquery-infinite-carousel->::xowiki::includelet::book ::xowiki::includelet::jquery-cloud-carousel ::xowiki::includelet::jquery-cloud-carousel render_items ::xowiki::includelet::jquery-cloud-carousel->::xowiki::includelet::book ::xowiki::includelet::jquery-carousel ::xowiki::includelet::jquery-carousel render_items ::xowiki::includelet::jquery-carousel->::xowiki::includelet::book

Class ::xowiki::includelet::book

::xowiki::includelet::book[i] create ... \
           [ -__decoration (default "plain") ] \
           [ -parameter_declaration (default " {-category_id} {-menu_buttons edit} {-folder_mode false} {-locale ""} {-range ""} {-allow_reorder ""} {-orderby "page_order,asc"} {-with_footer "false"} {-publish_status "ready"} ") ]

Show contents in book mode.
Defined in /var/www/openacs.org/packages/xowiki/tcl/includelet-procs.tcl

Class Relations

  • class: ::xowiki::IncludeletClass[i]
  • superclass: ::xowiki::Includelet[i]
  • instmixin: ::xowiki::includelet::PageReorderSupport[i]
  • subclass: ::xowiki::includelet::slidy[i], ::xowiki::includelet::jquery-spacegallery[i], ::xowiki::includelet::jquery-infinite-carousel[i], ::xowiki::includelet::jquery-cloud-carousel[i], ::xowiki::includelet::jquery-carousel[i]
::xowiki::IncludeletClass create ::xowiki::includelet::book \
     -superclass ::xowiki::Includelet \
     -instmixin ::xowiki::includelet::PageReorderSupport

Methods (to be applied on instances)

  • __decoration (setter)

  • parameter_declaration (setter)

  • render (scripted)

    :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
  • render_images (scripted)

    #
    # 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
  • render_item (scripted)

    $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 "&nbsp;"]
    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
  • render_items (scripted)

    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