attribute::array_for_type (public)

 attribute::array_for_type [ -start_with start_with ] \
    [ -include_storage_types include_storage_types ] array_name \
    enum_array_name object_type

Defined in packages/acs-subsite/tcl/attribute-procs.tcl

Fills in 2 arrays used for displaying attributes

Switches:
-start_with
(defaults to "acs_object") (optional)
-include_storage_types
(defaults to "type_specific") (optional)
Parameters:
array_name - The name of the array to hold the basic attribute information. The attributes defined are: * array_name(pretty_name:$name) The pretty_name of the attribute * array_name(id:$name) The attribute_id of the attribute * array_name(datatype:$name) The datatype of the attribute
enum_array_name - The name of the array to hold the pretty name of the values of an enumeration. This is only used when the datatype of the attribute_name is enumeration. This array is a mapping from "$attribute_name:enum_value" to value_pretty_name.
object_type - The object for which we are looking up attributes
Returns:
A list of all the names of attributes we looked up. This list can be used to iterated through the arrays:
            set attr_list [attribute::array_for_type attr_props enum_values "group"]
            foreach key $attr_list {
                set attribute_id $attr_props(id:$attribute_name)
                ...
            }
        
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
1/8/2001

Partial Call Graph (max 5 caller/called nodes):
%3 attribute::multirow attribute::multirow (public) attribute::array_for_type attribute::array_for_type attribute::multirow->attribute::array_for_type packages/acs-subsite/www/admin/relations/one.tcl packages/acs-subsite/ www/admin/relations/one.tcl packages/acs-subsite/www/admin/relations/one.tcl->attribute::array_for_type db_foreach db_foreach (public) attribute::array_for_type->db_foreach

Testcases:
No testcase defined.
Source code:
        upvar $array_name attr_props
        upvar $enum_array_name enum_values
        set attr_list [list]

        if {$include_storage_types ne ""} {
            set storage_clause "and a.storage in ([ns_dbquotelist $include_storage_types])"
        } else {
            set storage_clause ""
        }

        db_foreach select_attributes [subst -nocommands {
            with recursive object_type_hierarchy as (
                select object_type,
                       0 as type_level
                  from acs_object_types
                 where object_type = :start_with

                union all

                select t.object_type,
                       h.type_level + 1 as type_level
                  from acs_object_types t,
                       object_type_hierarchy h
                 where t.supertype = h.object_type
            )
            select coalesce(a.column_name, a.attribute_name) as name,
                   a.pretty_name,
                   a.attribute_id,
                   a.datatype,
                   v.enum_value,
                   v.pretty_name as value_pretty_name
            from acs_object_type_attributes a left outer join
                   acs_enum_values v using (attribute_id),
                   object_type_hierarchy t
             where a.object_type = :object_type
               and t.object_type = a.ancestor_type $storage_clause
            order by t.type_level, a.sort_order
        }] {
            # Enumeration values show up more than once...
            if {$name ni $attr_list} {
                lappend attr_list $name
                set attr_props(pretty_name:$name$pretty_name
                set attr_props(datatype:$name$datatype
                set attr_props(id:$name$attribute_id
            }
            if {$datatype eq "enumeration"} {
                set enum_values($name:$enum_value$value_pretty_name
            }
        }
        return $attr_list
Generic XQL file:
packages/acs-subsite/tcl/attribute-procs.xql

PostgreSQL XQL file:
packages/acs-subsite/tcl/attribute-procs-postgresql.xql

Oracle XQL file:
packages/acs-subsite/tcl/attribute-procs-oracle.xql

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