category::get_name (public)

 category::get_name category_id [ locale ]

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

Gets the category name in the specified language, if available. Use default language otherwise.

Parameters:
category_id (required)
category_id or list of category_id's for which to get the name.
locale (optional)
language in which to get the name. [ad_conn locale] used by default.
Returns:
list of names corresponding to the supplied category_id.
Author:
Timo Hentschel <timo@timohentschel.de>

Partial Call Graph (max 5 caller/called nodes):
%3 test_category_crud category_crud (test categories) category::get_name category::get_name test_category_crud->category::get_name test_category_get_procs category_get_procs (test categories) test_category_get_procs->category::get_name test_category_tree_procs category_tree_procs (test categories) test_category_tree_procs->category::get_name ad_conn ad_conn (public) category::get_name->ad_conn lang::system::locale lang::system::locale (public) category::get_name->lang::system::locale lang::util::default_locale_from_lang lang::util::default_locale_from_lang (public) category::get_name->lang::util::default_locale_from_lang parameter::get parameter::get (public) category::get_name->parameter::get Class ::xowiki::includelet::categories-recent Class ::xowiki::includelet::categories-recent (public) Class ::xowiki::includelet::categories-recent->category::get_name category::get_data category::get_data (public) category::get_data->category::get_name category::get_names category::get_names (public) category::get_names->category::get_name category::list::prepare_display category::list::prepare_display (public) category::list::prepare_display->category::get_name category_tree::get_tree category_tree::get_tree (public) category_tree::get_tree->category::get_name

Testcases:
category_crud, category_get_procs, category_tree_procs
Source code:
    if {[nsv_names categories] eq "" ||
        ![nsv_exists categories $category_id]} {
        return [list]
    }

    set cat_lang [lindex [nsv_get categories $category_id] 1]

    # Try specified locale or the one from the connection
    if {$locale eq ""} {
        set locale [ad_conn locale]
    }
    if {[dict exists $cat_lang $locale]} {
        return [dict get $cat_lang $locale]
    }

    # Try default locale for this language
    set language [lindex [split $locale "_"] 0]
    set locale [lang::util::default_locale_from_lang $language]
    if {[dict exists $cat_lang $locale]} {
        return [dict get $cat_lang $locale]
    }

    # Try system locale for package (or site-wide)
    set locale [lang::system::locale]
    if {[dict exists $cat_lang $locale]} {
        return [dict get $cat_lang $locale]
    }

    # Try site-wide system locale
    set locale [lang::system::locale -site_wide]
    if {[dict exists $cat_lang $locale]} {
        return [dict get $cat_lang $locale]
    }

    # Resort to en_US
    set locale [parameter::get -parameter DefaultLocale -default en_US]
    if {[dict exists $cat_lang $locale]} {
        return [dict get $cat_lang $locale]
    }

    # tried default locale, but nothing found
    return [list]
XQL Not present:
Generic
PostgreSQL XQL file:
packages/categories/tcl/categories-procs-postgresql.xql

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

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