category_tree::get_tree (public)

 category_tree::get_tree [ -all ] [ -subtree_id subtree_id ] tree_id \
    [ locale ]

Defined in packages/categories/tcl/category-trees-procs.tcl

Get all categories of a category tree from the cache.

Switches:
-all (optional, boolean)
-subtree_id (optional)
Parameters:
tree_id (required)
category tree to get the categories of.
locale (optional)
language in which to get the categories. [ad_conn locale] used by default.
Options:
-all
Indicates that phased_out categories should be included.
-subtree_id
Return only categories of the given subtree.
Returns:
Tcl list of lists: category_id category_name deprecated_p level
Author:
Timo Hentschel <timo@timohentschel.de>

Partial Call Graph (max 5 caller/called nodes):
%3 test_category_crud category_crud (test categories) category_tree::get_tree category_tree::get_tree test_category_crud->category_tree::get_tree category::get_name category::get_name (public) category_tree::get_tree->category::get_name category::relation::get_widget category::relation::get_widget (public) category::relation::get_widget->category_tree::get_tree category_tree::get_multirow category_tree::get_multirow (public) category_tree::get_multirow->category_tree::get_tree packages/categories/lib/tree-code.tcl packages/categories/ lib/tree-code.tcl packages/categories/lib/tree-code.tcl->category_tree::get_tree packages/categories/www/cadmin/category-link-add-2.tcl packages/categories/ www/cadmin/category-link-add-2.tcl packages/categories/www/cadmin/category-link-add-2.tcl->category_tree::get_tree packages/categories/www/cadmin/category-parent-change.tcl packages/categories/ www/cadmin/category-parent-change.tcl packages/categories/www/cadmin/category-parent-change.tcl->category_tree::get_tree

Testcases:
category_crud
Source code:
        if {[nsv_names category_trees] eq "" ||
            ![nsv_exists category_trees $tree_id]} {
            return [list]
        }

        set tree [nsv_get category_trees $tree_id]

        set result [list]
        if {$subtree_id eq ""} {
            foreach category $tree {
                lassign $category category_id deprecated_p level
                if {$all_p || $deprecated_p == "f"} {
                    lappend result [list $category_id [category::get_name $category_id $locale$deprecated_p $level]
                }
            }
        } else {
            set in_subtree_p 0
            set subtree_level 0
            foreach category $tree {
                lassign $category category_id deprecated_p level
                if {$level <= $subtree_level} {
                    set in_subtree_p 0
                }
                if {$in_subtree_p && $deprecated_p == "f"} {
                    lappend result [list $category_id [category::get_name $category_id $locale$deprecated_p [expr {$level - $subtree_level}]]
                }
                if {$category_id == $subtree_id} {
                    set in_subtree_p 1
                    set subtree_level $level
                }
            }
        }

        return $result
XQL Not present:
Generic
PostgreSQL XQL file:
packages/categories/tcl/category-trees-procs-postgresql.xql

Oracle XQL file:
packages/categories/tcl/category-trees-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: