xotcl.wu-wien.ac.at
Begin main content
Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]

::xowiki::IncludeletClass[i] ::xowiki::includelet::categories

Class Hierarchy of ::xowiki::includelet::categories

  • ::xotcl::Object[i]
    Meta-class:
    ::xotcl::Class[i]
    Methods for instances:
    __api_make_doc, __api_make_forward_doc, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, check, classC, cleanupC, configureC, containsC, copyC, db_0or1rowC, db_1rowC, debug, defaultmethodC, destroyC, destroy_on_cleanup, ds, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearch, forward, hasclass, incrC, infoC, init, instvarC, invarC, isclass, ismetaclass, ismixin, isobject, istype, lappendC, log, method, mixinC, mixinguardC, moveC, msg, noinitC, objectparameter, parametercmdC, proc, procsearch, qn, requireNamespaceC, residualargsC, self, serialize, setC, set_instance_vars_defaults, show-object, substC, traceC, unknown, unsetC, uplevelC, upvarC, volatileC, vwait
    Methods to be applied on the class (in addition to the methods provided by the meta-class):
    getExitHandler, setExitHandler, unsetExitHandler
    • ::xo::Context[i]
      Meta-class:
      ::xotcl::Class[i]
      Parameter for instances:
      actual_query (default " "), locale, package_id (default "0"), parameter_declaration (default "")
      Methods for instances:
      exists_query_parameter, export_vars, get_all_query_parameter, get_parameters, initialize, original_url_and_query, process_query_parameter, query_parameter
      Methods to be applied on the class:
      Methods provided by the meta-class
      • ::xowiki::Includelet[i]
        Meta-class:
        ::xotcl::Class[i]
        Parameter for instances:
        __decoration (default "portlet"), id, name (default ""), parameter_declaration (default ""), title (default "")
        Methods for instances:
        category_clause, get_page_order, include_head_entries, initialize, js_name, resolve_page_name, screen_name
        Methods to be applied on the class (in addition to the methods provided by the meta-class):
        available_includelets, describe_includelets, glob_clause, html_encode, html_id, html_to_text, js_encode, js_name, listing, locale_clause, parent_id_clause, publish_status_clause, require_YUI_CSS, require_YUI_JS
        • ::xowiki::includelet::categories[i]
          Meta-class:
          ::xowiki::IncludeletClass[i]
          Parameter for instances:
          parameter_declaration (default " {-tree_name ""} {-tree_style:boolean 1} {-no_tree_name:boolean 0} {-count:boolean 0} {-summary:boolean 0} {-locale ""} {-open_page ""} {-order_items_by "title,asc"} {-style "mktree"} {-category_ids ""} {-except_category_ids ""} {-allow_edit false} {-ordered_composite} "), title (default "Categories")
          Methods for instances:
          category_tree_edit_button, category_tree_missing, include_head_entries, initialize, render
          Methods to be applied on the class:
          Methods provided by the meta-class

Class Relations

  • superclass: ::xowiki::Includelet[i]
::xowiki::IncludeletClass create ::xowiki::includelet::categories \
     -superclass ::xowiki::Includelet \
     -parameter {{parameter_declaration {
          {-tree_name ""}
          {-tree_style:boolean 1}
          {-no_tree_name:boolean 0}
          {-count:boolean 0}
          {-summary:boolean 0}
          {-locale ""}
          {-open_page ""}
          {-order_items_by "title,asc"}
          {-style "mktree"}
          {-category_ids ""}
          {-except_category_ids ""}
          {-allow_edit false}
          {-ordered_composite}
        }} {title "Categories"}}

Methods

  • instproc category_tree_edit_button

    ::522557 instproc category_tree_edit_button {-object_id:integer -locale {-allow_edit false} -tree_id:integer} {
        set allow_p [::xo::cc permission -object_id $object_id -privilege admin -party_id [::xo::cc set untrusted_user_id]]
        if {$allow_edit && $allow_p} {
          if {[info exists tree_id]} {
            #
            # If a tree_id is given, edit directly the category tree ...
            #
            set href "[[my package_id] package_url]?edit-category-tree&object_id=$object_id&tree_id=$tree_id"
            return [[my set __including_page] include  [list edit-item-button -link $href -title "Edit Category Tree" -target _blank]]
          } else {
            #
            # ... otherwise, manage categories (allow defining new category trees, map/unmap, etc.)
            #
            set href "[[my package_id] package_url]?manage-categories&object_id=$object_id"
            return [[my set __including_page] include  [list edit-item-button -link $href -title "Manage Categories" -target _blank]]]
          }
        }
        return ""
      }
    
  • instproc category_tree_missing

    ::522557 instproc category_tree_missing {{-name ""} -edit_html} {
        # todo i18n
        if {$name eq ""} {
          #set msg "No category tree found."
          # maybe it is better to stay quiet in case, no category name was provided
          set msg ""
        } else {
          set msg "No category tree with name '$name' found."
        }
        [my package_id] flush_page_fragment_cache -scope agg
        set html "<div class='errorMsg'>$msg</div>"
        if {$edit_html ne ""} {
          return "$html Manage Categories? $edit_html"
        }
        return $html
      }
    
  • instproc include_head_entries

    ::522557 instproc include_head_entries {} {
        ::xowiki::Tree include_head_entries -renderer [my set style]
      }
    
  • instproc initialize

    ::522557 instproc initialize {} {
        my get_parameters
        if {!$tree_style} {
          set style sections
        }
        my set style $style
      }
    
  • instproc render

    ::522557 instproc render {} {
        my get_parameters
    
        set content ""
        set folder_id [$package_id folder_id]
        set open_item_id [expr {$open_page ne "" ?
                    [::xo::db::CrClass lookup -name $open_page -parent_id $folder_id] : 0}]
    
        foreach {locale locale_clause}  [::xowiki::Includelet locale_clause -revisions r -items ci $package_id $locale] break
    
        set trees [::xowiki::Category get_mapped_trees -object_id $package_id -locale $locale  -names $tree_name  -output {tree_id tree_name}]
    
        #my msg "[llength $trees] == 0 && $tree_name"
        if {[llength $trees] == 0 && $tree_name ne ""} {
          # we have nothing left from mapped trees, maybe the tree_names are not mapped; 
          # try to get these
          foreach name $tree_name {
            #set tree_id [lindex [category_tree::get_id $tree_name $locale] 0]
            set tree_id [lindex [category_tree::get_id $tree_name] 0]
            if {$tree_id ne ""} {
              lappend trees [list $tree_id $name]
            }
          }
        }
    
        set edit_html [my category_tree_edit_button -object_id $package_id -allow_edit $allow_edit]
        if {[llength $trees] == 0} {
          return [my category_tree_missing -name $tree_name -edit_html $edit_html]
        }
    
        if {![my exists id]} {my set id [::xowiki::Includelet html_id [self]]}
    
        foreach tree $trees {
          foreach {tree_id my_tree_name ...} $tree {break}
    
          set edit_html [my category_tree_edit_button -object_id $package_id  -allow_edit $allow_edit -tree_id $tree_id]
          #append content "<div style='float:right;'>$edit_html</div>\n"
    
          if {!$no_tree_name} {
            append content "<h3>$my_tree_name $edit_html</h3>"
          } elseif {$edit_html ne ""} {
            append content "$edit_html<br>"
          }
          set categories [list]
          set pos 0
          set cattree(0) [::xowiki::Tree new -volatile -orderby pos  -id [my id]-$my_tree_name -name $my_tree_name]
    
          set category_infos [::xowiki::Category get_category_infos  -locale $locale -tree_id $tree_id]
          foreach category_info $category_infos {
            foreach {cid category_label deprecated_p level} $category_info {break}
            set c [::xowiki::TreeNode new -orderby pos   -level $level -label $category_label -pos [incr pos]]
            set cattree($level) $c
            set plevel [expr {$level -1}]
            $cattree($plevel) add $c
            set category($cid) $c
            lappend categories $cid
          }
    
          if {[llength $categories] == 0} {
            return $content
          }
    
          if {[info exists ordered_composite]} {
            set items [list]
            foreach c [$ordered_composite children] {lappend items [$c item_id]}
    
            # If we have no item, provide a dummy one to avoid sql error
            # later
            if {[llength $items]<1} {set items -4711}
    
            if {$count} {
              set sql "category_object_map c
                 where c.object_id in ([join $items ,]) "
            } else {
              # TODO: the non-count-part for the ordered_composite is not
              # tested yet. Although "ordered compostite" can be used
              # only programmatically for now, the code below should be
              # tested. It would be as well possible to obtain titles and
              # names etc. from the ordered composite, resulting in a
              # faster SQL like above.
              set sql "category_object_map c, cr_items ci, cr_revisions r
                where c.object_id in ([join $items ,])
                  and c.object_id = ci.item_id and 
                  and r.revision_id = ci.live_revision 
               "
            }
          } else {
            set sql "category_object_map c, cr_items ci, cr_revisions r, xowiki_page p  where c.object_id = ci.item_id and ci.parent_id = $folder_id  and ci.content_type not in ('::xowiki::PageTemplate')  and c.category_id in ([join $categories ,])  and r.revision_id = ci.live_revision  and p.page_id = r.revision_id  and ci.publish_status <> 'production'"
          }
    
          if {$except_category_ids ne ""} {
            append sql  " and not exists (select * from category_object_map c2  where ci.item_id = c2.object_id  and c2.category_id in ($except_category_ids))"
          }
          #ns_log notice "--c category_ids=$category_ids"
          if {$category_ids ne ""} {
            foreach cid [split $category_ids ,] {
              append sql " and exists (select * from category_object_map  where object_id = ci.item_id and category_id = $cid)"
            }
          }
          append sql $locale_clause
          
          if {$count} {
            db_foreach [my qn get_counts]  "select count(*) as nr,category_id from $sql group by category_id" {
                  $category($category_id) set count $nr
                  set s [expr {$summary ? "&summary=$summary" : ""}]
                  $category($category_id) href [ad_conn url]?category_id=$category_id$s
                  $category($category_id) open_tree
    	  }
            append content [$cattree(0) render -style [my set style]]
          } else {
            foreach {orderby direction} [split $order_items_by ,]  break     ;# e.g. "title,asc"
            set increasing [expr {$direction ne "desc"}]
    	set order_column ", p.page_order" 
    
            db_foreach [my qn get_pages]  "select ci.item_id, ci.name, ci.parent_id, r.title, category_id $order_column from $sql" {
                  if {$title eq ""} {set title $name}
                  set itemobj [Object new]
                  set prefix ""
                  set suffix ""
                  foreach var {name title prefix suffix page_order} {$itemobj set $var [set $var]}
    	      $itemobj set href [::$package_id pretty_link -parent_id $parent_id $name]              
                  $cattree(0) add_item  -category $category($category_id)  -itemobj $itemobj  -orderby $orderby  -increasing $increasing  -open_item [expr {$item_id == $open_item_id}]
                }
            append content [$cattree(0) render -style [my set style]]
          }
        }
        return $content
      }
    

Variables

::xowiki::includelet::categories set __default_metaclass ::xotcl::Class
::xowiki::includelet::categories set __default_superclass ::xotcl::Object
::xowiki::includelet::categories set aggregating true
::xowiki::includelet::categories set cacheable true
::xowiki::includelet::categories set localized true
::xowiki::includelet::categories set personalized false

Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]